Pi approximation games

(snip, I wrote)

The ongoing project involves weighing and counting the number of atoms in a silicon sphere. When you figure out how many are in a kg, that could be, should be, an integer.

-- glen

Reply to
glen herrmannsfeldt
Loading thread data ...

pi/4 = 1 - 1/3 + 1/5 - 1/7 + ...

pi/4 = Sum [(-1)^p]/(2p+1) p = 0 to oo

max error =|[((-1)^p)/(2p+1)]-[(-1)^(p+1)]/(2(p+1)+1)|

for instance if I want to calculate pi to the nearest E = +/- 10^-50, the series will have to be carried out p times such that

10^-50 = |1/(2p+1)-1/(2p+3)|

E(2p+3)(2p+1)=(2p+3) - (2p+1)

E(4p^2 + 8p + 3) = 2

4p^2 + 8p + (3 - 2/E) = 0

p = (-2 +/-{4-(3-2/E)}^.5)/2

for E = 10^-50, p = 10^25

for E = 1/2^128 , p = 10^20

Reply to
Jon

g

ttdesign.com

I've recently discovered a program called Wolfram Alpha. If you have an obsessive interest in series expansions, you can spend hours with this program.

Bob

Reply to
Robert Adams

.

That's the British customary units, not English, that's the language you are confusing with the country which is Great Britain. another common mishtake made by americans.

Reply to
HardySpicer

Calculate pi using "infinite precision" numbers, and you get it to infinite precision. Obviously you can't print out the whole answer - but you can print out as much of the answer as you want, until the machine runs out of memory or time.

An "infinite precision number" is usually held as a list of digits, along with a method for calculating more digits. You can then write functions that can add, subtract, multiply and divide such numbers. It is particularly convenient to use a functional programming language for such tasks, as they are good at working with unlimited lists, and with manipulating functions (such as the digit generator function).

To calculate pi, the easiest way is to note that atan(1) = pi/4, and atan(x) = x - x^3 / 3 + x^5 / 5 - x^7 / 7 + ... Once you have the individual parts in place, the rest is easy. Of course, you end up with lots of unlimited lists of unlimited lists, etc.

Mathematically speaking, what you have is precise representation of /all/ the digits of pi. You can't display them all, as you have limited ram and time - but it /is/ precise and contains /all/ the digits - just as "0.33..." is a precise decimal representation of /all/ the digits of

1/3 (the "..." gives the method of producing any digits you want).
Reply to
David Brown

But that isn't how the trick was done. There is a cute expression for the Nth hexadecimal digit representation of pi detailed at:

formatting link

No-one in their right mind would start from that crude series today - its convergence for x=1 is absolutely hopeless. See for example:

formatting link

The algorithm that can supply the Nth digits of pi lazily *only* works for hexadecimal digits (or base 2^N for certain N).

It doesn't work at all for the *decimal* representation of pi.

--
Regards,
Martin Brown
Reply to
Martin Brown

I have in my hands an "Nelson's Encyclopedia" printed in 1951 (12 years before the international inch) it says the metre (then defined by scratches on a bar in Paris) is is about 1.0936143 yards (then defined by scratches on a bar in London)

1 / 36 / 1.0936143 comes to .025399977m

so, yes the American inch was the bigger of the two.

--
?? 100% natural

--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net
Reply to
Jasen Betts

I think you missed the earlier post in which I said that I /did/ do this, as a project at university. There may be other ways to calculate pi that are more efficient in base 16 - but that's a different matter entirely.

As I said, it was a university project. The aim was not to calculate pi, but to understand the usage of infinite lists, infinite precision numbers, ways to manipulate them, and ways to prove that the code to do so is correct. The rate of convergence is utterly irrelevant.

Just for fun, I figured out an alternative series that was faster to converge (possibly (atan(1/2) + atan(1/3)), though I can't remember for sure).

Nonsense. I did it, and I didn't find it particularly hard.

Perhaps you misunderstand what "lazy evaluation" actually is. The algorithm you reference is a way to calculate a hexadecimal digit of pi without having to calculate the previous digits - no such method is known for calculating the decimal digits (though that does not mean one does not exist). But that has nothing at all to do with lazy evaluation, which simply means that the relevant numbers are calculated when needed rather than in advance. It means you can work with an unlimited list, and treat it as though it were a fully calculated infinite list, without the computer actually having to calculate anything until the last minute.

Reply to
David Brown

We just have to slightly increase the value of 1, so pi will equal 3. :-)

-jm

Reply to
Jukka Marin

An YES answer to a question that I have had rattling around for a while, to wit -

Are there properties (aside from trivial ones) of base-n numbers not shared by base-a-different-n numbers.

*Why* can you skip ahead to a hex digit of pi but not a dec digit?

Is this unique to pi and base 2^x, or is it true for certain irrational numbers, or all? If only some, are there similar (lack of) algorithms for other combinations of base and irrational number(s)?

Reply to
xpzzzz

Proving properties of numbers, such as whether they are rational, irrational, transcendental, normal, etc., is generally very difficult. And many of their properties probably have no better explanation than coincidence.

Pi is known to be "normal", meaning that if you write out its "decimal expansion" in any base, the digits will be evenly distributed amongst all possible digits.

Reply to
David Brown

Because an infinite series expansion for PI is known where all the components being summed together are of the form sum ( 1/16^k.f(k) )

It is therefore possible to start from a chosen digit position and compute just the digits of interest from there on. The URL I posted describes a bit more of the details of the algorithm.

It is entirely possible that some other irrationals may have an elegant series expression in some base or other, but off hand I don't know of any other commonly known examples of this. A quick back of the envelope playing around suggests that the golden ratio phi may well have an expansion base 8 that is amenable to the same sort of trick.

phi = (1 + sqrt(5))/2 = 1/2 + sqrt(1 + 1/4)

series expansion for sqrt(1+x) with x = 1/4

1/2 + 1 + x/2 - x^2/2!/4 + 3x^3/3!/8 - ... 1 + 1/2 + 1/8 - sum[k=2,inf]{ 1/(-4^k) ((2k-3)!/((k-2)!k!) }

as ever subject to mistakes, typos and algebra errors.

--
Regards,
Martin Brown
Reply to
Martin Brown

You surely mean inhabitants of the United States of America. Mexicans, Argentinians and Cubans, though Americans themselves, don't confuse English and British. Another common mistake made by yankees :-)

Reply to
Ignacio G.T.

Interesting!

Taylor Maclaurin expansions are great for getting insight into nonlinear stuff.

formatting link

Of course MATLAB and such like will do this, but they don't work for free.

Reply to
Spehro Pefhany

formatting link

Scilab is free...

Reply to
Andre

I've some Canadian relatives who were very vocal on their right to be called American.

Reply to
Richard Owlett

Yeah, but you'd have an irrational number of fingers.

Jeroen Belleman

Reply to
Jeroen Belleman

Try sqrt(2). 7/5 is fair. 17/12 is good enough for carpentry. 41/29 has less than one fifth of that error, but 99/70 is much better yet. In fact, the best (in terms of accuracy per bit expended) have an odd numerator and an even denominator.

Jerry

--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reply to
Jerry Avins

BBP's original paper (link below) lists a number of other examples, including log(2), log (9/10), pi**2, many base 2 logs, ... Others have computed other constants (see Wiki article for links)

formatting link

formatting link

Reply to
Robert Wessel

formatting link

Octave is...

-- Les Cragill

Reply to
Les Cargill

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.