I'm A Shameless Exponent of MatLab (LOL!)

Mike Hewson
Mike Hewson
Moderator
Joined: 1 Dec 05
Posts: 6594
Credit: 339987198
RAC: 346322

Recalling the Liebniz series

Recalling the Liebniz series for tan-1(x) :

tan-1(x) = x - x3/3 + x5/5 - x7/7 + ... (-1)n*x2n+1/2n+1 + ...

it seems reasonable to try a value of x closer to zero, hoping that it will converge quicker than it did for PI/4. If you consider the angle PI/6 then it's tangent is 1/sqrt(3), so if you use x = 1/sqrt(3) in the above series you get :

PI/6 = 1/sqrt(3)[1 - 1/9 + 1/45 - 1/189 + ..... + (-1)n*(1/3)n/(2n+1) + ... ]

OR

PI = 2*sqrt(3)[1 - 1/9 + 1/45 - 1/189 + ..... + (-1)n*(1/3)n/(2n+1) + ... ]

this is called Sharp's Formula and is circa 1717. Putting that into MATLAB gives :

this gives 15 correct digits of PI after only 30 terms. Very rapid convergence indeed ! It would continue to give a new correct digit for each two new included terms except for the fundamental float representation of MATLAB. Plus you also need the sqrt(3) correspondingly accurate. Which raises the question of how do they produce PI to some hundreds, thousands or millions of decimal places .... 

Cheers, Mike.

( edit ) When you see tan-1(x) that reads in English as 'that angle whose tangent is x'. As an aside I see that to calculate the circumference of the known universe from it's radius ( say ~ 1025 metres ), to a precision within the width of a hydrogen atom, then you need to know PI to about 40 decimal digits. 

I have made this letter longer than usual because I lack the time to make it shorter ...

... and my other CPU is a Ryzen 5950X :-) Blaise Pascal

Mike Hewson
Mike Hewson
Moderator
Joined: 1 Dec 05
Posts: 6594
Credit: 339987198
RAC: 346322

I'd be a happy fellow, now

I'd be a happy fellow, now that I have the following :

.... after wrestling the MATLAB Variable Precision Arithmetic into line. This time using PI/12 as the angle of interest - it's tangent is, analytically, the sqrt((1-sqrt(3)/2)/(1+sqrt(3)/2)). Now the above three numbers are all equal and accurate to the book value @ 100 decimal places for (a) the intrinsic MATLAB tan-1 function atan, (b) the roll-my-own high precision version arctan and (c) the intrinsic PI constant that MATLAB produces by whatever algorithm. The key MATLAB language point is to use the vpa type declarations on the innermost elements of an expression, the language interpreter/parser causes the rest of the constructs to follow that precision. A stunning feature actually. If you want more precision then change max_digits and wait for a longer time ( tic starts a timer, toc and reads it out ).

It's all there, for your cosmic measuring needs .... LOL :-)

Cheers, Mike.

I have made this letter longer than usual because I lack the time to make it shorter ...

... and my other CPU is a Ryzen 5950X :-) Blaise Pascal

Mike Hewson
Mike Hewson
Moderator
Joined: 1 Dec 05
Posts: 6594
Credit: 339987198
RAC: 346322

Then there is the Chudnovsky

Then there is the Chudnovsky brothers' algorithm which was used to break a world record number of PI digits last year. It has this arcane formula at it's centre :

..... which can be more or less readily coded into MATLAB. This doesn't converge very fast and in any event calculates the reciprocal of PI. One could multiply this by the MATLAB inbuilt PI value ( accurate to some number of digits as before ) and see how close to one you get :

... around 15 digits good, using 1000 digits of precision and 1000 iterations. Not real flash but what do you want in 20 seconds ? Wolfram MathWorld has quite a few more PI formulas. I think I'll move on .... enough of this particular rabbit hole. :-)

ASIDE : This may be old news to some but : about two weeks ago I had the Abbott Freestyle Libre device attached to my left arm. For the purpose of familiarisation and testing. It's about the size of a draughts playing piece and has a tiny filament that pierces the skin and measures the interstitial/tissue glucose level. It is straightforward and painless to apply. It can report to one's mobile phone via an app. You just wave the phone ( on the aerial side ) over the device to load the last 8 hours of measurements. It samples the glucose once per minute and stores the results. It works for about two weeks before it turns itself off ( before it runs out of power I assume ). This is a wondrous device and is/will revolutionise the management of diabetes, not to mention avoid the painful pricking of fingers and the hassle/worry of glucometer calibration. When I get hold of all the data I'll use MATLAB to plot it and see what may be seen. 

Cheers, Mike.

I have made this letter longer than usual because I lack the time to make it shorter ...

... and my other CPU is a Ryzen 5950X :-) Blaise Pascal

Mike Hewson
Mike Hewson
Moderator
Joined: 1 Dec 05
Posts: 6594
Credit: 339987198
RAC: 346322

Another rabbit hole : prime

Another rabbit hole : prime numbers.

Fortunately MATLAB has a primes(n) command which returns ( as a vector ) the prime numbers less than or equal to the given number number n. On my machine I can get all the primes up to 10 billion before a resource limit is reached. What now ? Well I've always been fascinated by the fact that once you're past 10 then all primes have their last digit equal to 1 or 3 or 7 or 9. But what about having 4 primes in a given decade like 11, 13, 17, 19 or 5651, 5653, 5657, 5659 say. A group of four such as these are called a prime quadruplet. One  conjecture states that there is no highest quadruplet ie. it is an infinite set. Conjecture means it hasn't been proven one way or the other. An open problem.

So now here's some code that selects all the prime quadruplets up to 10 billion :

.... and saves the first prime from each quadruplet in a file to be later worked on. I've chosen, based on a Wikipedia page, to use these primes as additive factors in a particular ( analytically infinite ) series, like so :

.... but first doing a loglog plot of the distribution of these quadruplets. This reveals a straight line for sufficiently large numbers ( upper right side on the graphic below ). This is a clue that there may be a power law operating, and by eye it looks to have an exponent of about 4/3 :

... this hinting that there may be indeed no greatest prime quadruplet if said power law holds for all magnitudes. BTW if you take the total sum of the series, multiply it by ten and then add two : the result is very close to the natural logarithm base e. :-)

But all this is proof of nothing, just a muck-about. All I've shown is how to spend a pleasant afternoon on MATLAB. Mind you if one does prove that the prime quadruplets form an infinite set then you also prove, as a lemma on the side, the Twin Prime conjecture .... that pairs of primes differing by two also form an infinite set. Which is where other distributed projects like PrimeGrid come in.

Cheers, Mike.

I have made this letter longer than usual because I lack the time to make it shorter ...

... and my other CPU is a Ryzen 5950X :-) Blaise Pascal

Mike Hewson
Mike Hewson
Moderator
Joined: 1 Dec 05
Posts: 6594
Credit: 339987198
RAC: 346322

So I've seen the method that

So I've seen the method that Euler used to summate the following previously mentioned infinite series :

S = 1/12 + 1/22 + 1/32 + ....... + 1/k2 + ...... = 1 + 1/4 + 1/9 + 1/16 + ......

... which converges to PI2/6.

(a) He starts with a theorem that Weierstrass came up with regarding polynomials P, that is :

if P(0) = 1 and P(a) = 0, P(b) = 0 ...... P(f) = 0, ..... for some a,b ....f.... then one can write 

P(x) = (1 - x/a)*(1 - x/b)* ...... *(1-x/f) .....

... the idea here being one can factorise a polynomial in a 'nice' way so as to make the zeroes of the polynomial explicit.

(b) Now there is an infinite polynomial that represents sin(x) :

sin(x) = x - x3/3! + x5/5! - x7/7! + .... 

from which one can form the following polynomial :

Q(x) = sin(x)/x = (1/x)*(x - x3/3! + x5/5! - x7/7! + ...)

= 1 - x2/3! + x4/5! - x6/7! + .... 

where you will notice that if x = 0 then Q(x) = 1 and Q(x) = 0 when sin(x) = 0 ie. x = n*PI for any positive or negative integer n.

(c) That means Q(x) can also be alternately written according to part (a) as follows :

Q(x) = (1 - x/PI)*(1 + x/PI)*(1 - x/(2*PI))*(1 + x/(2*PI))*(1 - x/(3*PI))*(1 + x/(3*PI)) .....

= (1 - x2/PI2)*(1 - x2/(4*PI2))*( 1 - x2/(9*PI2)) ......

which, by expanding and gathering up all the x2 terms :

= 1 - x2(1/PI2 + 1/(4*PI2) + 1/(9*PI2) + .... ) + other stuff of x4 and higher terms

= 1 - x2/(PI2)*[1 + 1/4 + 1/9 + 1/16 + .... ] + other stuff

(d) And there you see the series of interest lurking as a coefficient of x2 in this series expansion of Q. Thus the coefficients of x2 must be equal across the two representations of the same polynomial, and hence

1/3! = 1/(PI2)*[1 + 1/4 + 1/9 + 1/16 + .... ]

or

1 + 1/4 + 1/9 + 1/16 + .... = PI2/6

as desired. In fact one can play the same trick with the coefficients of other even powers of x in the two alternate representations of Q and come up with formulae for other series too. What can I say ...... genius is as genius does I suppose.

There are open questions related to the infinite series summation of odd powers within the denominator eg.

S = 1/13 + 1/23 + 1/3+ 1/43 + .....

is expected to converge but no closed form has been found to solve it.

Also there is a connection b/w this work and that of Riemann : an unproven conjecture about a complex valued function that is the centre of attention in ( prime ) number theory, which BTW attracts a million dollar prize if it is solved. See the Riemann Hypothesis, but beware it takes some time to recognise precisely what it is that is being asked.

Cheers, Mike.

( edit ) Note that sin(x)/x has a limit of 1 as x tends to zero and thus the different expressions for Q(x) can be made to agree.

I have made this letter longer than usual because I lack the time to make it shorter ...

... and my other CPU is a Ryzen 5950X :-) Blaise Pascal

Mike Hewson
Mike Hewson
Moderator
Joined: 1 Dec 05
Posts: 6594
Credit: 339987198
RAC: 346322

The Riemann zeta function. It

The Riemann zeta function. It is defined as a series for that half of the complex number plane where Re(z) > 1 thus :

zeta(s) = 1 + 1/2s + 1/3s + 1/4s + .....

where s = x + iy is a complex variable. So one picks a value of s and then uses the formula to get the zeta value for that s. However the function doesn't use that series formula directly for Re(z) < 1 as it doesn't converge. But by a technique/trick of complex mathematics called analytic continuation there is effectively a 'mirroring' of the function values. That is, there is a formula connecting the regions either side of that line :

zeta(s) = 2s * PIs-1 * sin(PI*s/2) * gamma(1 - s) * zeta(1 - s)

 ...... and so one can evaluate the series when it converges and use the result to assign function values where the series directly couldn't otherwise apply. For example to evaluate for s = -3 using the above connecting formula one needs to calculate the series when s = 1-(-3) = 4, etc. The function gamma() is an extended definition of the factorial function for non-integer arguments. Also note that PI, again, turns up in the formula, almost without invitation as it were. I'm beginning to think of PI as some sort of universal constant in mathematics which, as an aside, also has something to do with circles ! :-0

Now zeta(s) has so-called trivial zeros when s = - 2, -4, -6 ...... because that makes sin(k*PI) = 0 for some integer k.

Now for the money shot. There are other zeros of the zeta function, not of the trivial type, and to date of all such non-trivial zeros discovered lie on the line Re(z) = 1/2. The Riemann Hypothesis is that all non-trivial zeros of the zeta function lie on the line Re(z) = 1/2. There have been discovered billions & billions of zeros - calculated on computers - which satisfy Re(s) = 1/2 and no exception to this rule has been found. If you can be the first person to prove that this must be so then you have yourself a million dollar prize. This has been offered by the Clay Mathematics Institute as one of it's millennium problems. Needless to say this question requires some acute understanding of complex analysis in order to even begin to appreciate what is being asked. I am working on that .... ;-)

Why the big deal then ? So what if the zeta function has some set of zeros all at Re(s) = 1/2 ? Sounds pretty arcane. Well there are hundreds of other important results in number theory that depend on the Riemann conjecture being true. In the several centuries since it was first mentioned many results in pure mathematics have assumed it to be true ie. mathematicians have ventured forth without the firm knowledge that this Riemann hypothesis is correct. So if one cracks this problem then a blizzard of other stuff becomes valid also. For example the error in the predicting the distribution of prime numbers is one of them. There has yet to be a general formula for prime numbers, you have to just go from one number to the next and test for it's multiplicative factors. 

Cheers, Mike.

( edit ) One warning about visualising complex functions : the zeta function, say, has a complex number as an input and a complex number as it's output. Because a complex number is defined as x + iy where x and y are real numbers then zeta is a two-input, two-output function. You can't graph it like an ordinary one-input/one-output function. You'd need four dimensions to get it right ....  and if you are familiar with the ordinary derivatives of real functions then even sensing what complex differentiation is, and is not, is difficult. It's probably not ideal to think of slopes, tangents and such-like for complex functions. Perhaps it is best to consider the first derivative as being the best linear approximation of the complex function near some point in it's domain. Differentiation of a complex function is weird. If you can take the first derivative - an adapted form of the limiting process in the real numbers - then you can take the derivative as many times as you like. One corollary is that a complex function can't be only differentiable a finite number of times, it either can't be done at all or if so then infinitely many times. Also integration is weird too, but that's another story ...

( edit ) You could legitimately ask : what is 1/2s when s is complex ? Well it follows the usual arithmetic of using powers with some base where s = x + i y ( both x and y real numbers ) :

1/2s = (1/2)x+iy = (1/2)x * (1/2)iy

with (1/2)x being an ordinary real number. However (1/2)iencodes a phase, or the angle in polar form with the positive real axis. If you vary x then the distance to the origin changes, if you vary y then that phase changes ie. it rotates around the origin. You may be more familiar with Euler's use of eiy, that is the natural logarithm base being used for the polar form of complex numbers. You can use other bases if you like - but it effectively changes the scaling of the y input. For example :

(1/3)iy = 3-iy = e-ln(3)*iy

.... where ln(3) is the natural logarithm of 3. Likewise for 1/ks generally. Indeed this is the core of the calculation with the zeta function ( and complex power series ) : it is the summation of lot's of vectors in the two dimensional ( Argand ) plane that are placed head to tail to achieve some resultant displacement from the origin. The series converges if that resultant vector settles down to some finite length and fixed direction. For a zero of the zeta function the chain of vectors goes around some path with the final vectors as close as possible to the centre of the Argand plane ie. 0 + i0. Hence the phrase 'zero of the function'. For the argument s = 1 = 1 + i0 it doesn't converge, as the magnitude will grow to be as big as one pleases ( see discussion here ), a slow crawl to infinity but unbounded nonetheless. There isn't anything one can do about that for the zeta function.

I have made this letter longer than usual because I lack the time to make it shorter ...

... and my other CPU is a Ryzen 5950X :-) Blaise Pascal

Mike Hewson
Mike Hewson
Moderator
Joined: 1 Dec 05
Posts: 6594
Credit: 339987198
RAC: 346322

FWIW I have inaugurated a

FWIW I have inaugurated a YouTube channel called Mathematics Bites, with a new video entitled Logarithms As A Technology.

Cheers, Mike.

I have made this letter longer than usual because I lack the time to make it shorter ...

... and my other CPU is a Ryzen 5950X :-) Blaise Pascal

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.