Previous in Forum: Harmonic Problem Single Phase   Next in Forum: ALL ABOUT SARAH BOONE
Close
Close
Close
62 comments
Rating: Comments: Nested
Guru
Popular Science - Cosmology - Let's keep knowledge expanding Engineering Fields - Retired Engineers / Mentors - Hobbies - HAM Radio - New Member

Join Date: Dec 2006
Location: North America, Earth
Posts: 4528
Good Answers: 106

Number Theory - Calculations of PI

02/05/2008 12:20 AM

Of course PI (Π) can be determined by measuring a circle's circumference and diameter and dividing. The accuracy will be limited to a few digits. To get a lot of digits, other methods are used (why?). Some methods are much better than others. Vieta produced the first formula:

2/Π = √0.5 * √(0.5 + 0.5√0.5) * √(0.5 + 0.5V(0.5 + 0.5√0.5)) * ... (1)

This is another one:

Π2/6 = 1/12 + 1/22 + 1/33 … (2)

Wallis produced this one:

Π/4 = 2/3 * 4/3 * 4/5 * 6/5 * 6/7 * 8/7 * ... (3)

This one from Leibniz is a special case of a formula from James Gregory:

Π/4 = 1 - 1/3 + 1/5 - 1/7 + 1/9 ... (4)

With formulas like these, the more terms you use, the more accurate the results. Some of them give an answer that is too large, then too small, then too large, etc. with each added term. To implement these formulas effectively, you need to write a computer program. Computer programs follow a series of steps called an algorithm. The algorithms for these formulas need to loop back, adding one or more terms to the calculation each loop. This kind of process is called an iterative routine. Most computer languages have a fixed amount of accuracy or precision. Some give you a choice of two. Seven digits of accuracy is called single precision. You get 16 digits with double precision. For more digits than this you need special systems or special programming.

I implemented formula 3 with 2 terms averaged per loop. When done with single precision it converged on the number 3.141330, which is incorrect in the last 3 digits. This demonstrates the result of round-off error. With double precision it got the number 3.141514 after 10,000 loops. That number is correct to 5 digits. Formula 4 was implemented with 4 terms per loop. It got the number 3.141647 after 5,000 loops in single precision, and 3.141621 after 10,000 loops. In double precision it got 3.141618 after 10,000 loops. Formula 3 takes about 20 million terms to get single precision accuracy! Formulas 2 and 4 take about 4 million for the same. Each successive digit with these formulas takes 10 times longer to calculate than the previous one. With formula 4 it took 5 hours for the 10th digit on a Pentium 90 running Microsoft Quick-Basic.

This is a much faster formula that comes from the Hexadecimal expansion of PI:

Π = Σ(n=0 to ∞) {4/(8n +1) – 2/(8n+4) – 1/(8n+5) – 1/(8n+6)} * (1/16)n (5)

Formula 5 (above) achieves double precision accuracy almost instantly in 10 iterations! An even faster algorithm by Robert L. Brown based on arithmetic-geometric mean and circumscribed polygons of constant perimeter (originally discovered by Gauss) is shown below in BASIC language:

1 A = 1: X = 1: B = 1/SQR(2): C = 1/4

2 Y = A

3 A = (A + B) / 2

4 B = SQR(B * Y)

5 C = C - X * (A - Y) ^ 2

6 X = 2 * X

7 PI = ((A + B) ^ 2) / 4C

8 PRINT PI

9 GOTO 2

10 END

This method achieves single precision accuracy in 2 loops, and double precision accuracy in 3 loops! It is the 2nd fastest known method. In a system without accuracy limitations, it can compute PI to thousands of digits of accuracy.

__________________
“I would rather have questions that can't be answered than answers that can't be questioned.” - Richard Feynman
Register to Reply
Pathfinder Tags: pi
User-tagged by 2 users
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.

Good Answers:

These comments received enough positive votes to make them "good answers".

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Guru
Popular Science - Weaponology - New Member United Kingdom - Member - New Member

Join Date: May 2007
Location: Harlow England
Posts: 16512
Good Answers: 670
#1

Re: Number Theory - Calculations of PI

02/05/2008 2:53 AM

But wi ?

__________________
health warning: These posts may contain traces of nut.
Register to Reply Off Topic (Score 5)
Guru

Join Date: Nov 2007
Location: Sherwood Park, Alberta, Canada
Posts: 1212
Good Answers: 74
#10
In reply to #1

Re: Number Theory - Calculations of PI

02/06/2008 11:43 AM

wi not?

__________________
Bruce
Register to Reply Off Topic (Score 5)
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#2

Re: Number Theory - Calculations of PI

02/05/2008 5:27 AM

"It is the 2nd fastest known method"

OK - don't hold back on us. What's the fastest?

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply
Guru
Popular Science - Cosmology - Let's keep knowledge expanding Engineering Fields - Retired Engineers / Mentors - Hobbies - HAM Radio - New Member

Join Date: Dec 2006
Location: North America, Earth
Posts: 4528
Good Answers: 106
#6
In reply to #2

Re: Number Theory - Calculations of PI

02/05/2008 7:48 PM

Hi John,

I have been told that the Indian mathematician Ramanujan developed the fastest, but I don't have it. I was hoping some CR4 reader would share it. How about you, guest? You seem to be everywhere!

How did you post that big PI symbol? The CR4 editor won't take it from Microsoft Word, and the internal one looks crappy.

S

__________________
“I would rather have questions that can't be answered than answers that can't be questioned.” - Richard Feynman
Register to Reply
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#8
In reply to #6

Re: Number Theory - Calculations of PI

02/06/2008 2:42 AM

I cheated with the pi symbol. I also hate the CR4 version, so I ended up doing a Google image search, and grabbed the best-looking one.

Feel free to use it - it's not mine anyway! Right click - save picture as ...

Trouble is you have to insert it as an image, which is a pain.

John

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply Off Topic (Score 5)
Guru

Join Date: Nov 2007
Location: Sherwood Park, Alberta, Canada
Posts: 1212
Good Answers: 74
#33
In reply to #8

Re: Number Theory - Calculations of PI

02/08/2008 8:27 PM

The message to the right was written in Microsoft Word, then converted to a PDF, then a TIFF and finallly a JPEG file and brought into CR4 as one image.

I used the Universal Math text for the first three lines and an arbitrary text for the last line. (I think it was called minstral).

A bit of a pain, but you can get the pi you like.

Another way to do it would be to write your message in any word processor you like, then scan a hardcopy into the JPEG format and bring it in as an image.

Maybe someone else has a more practical suggestion.

__________________
Bruce
Register to Reply Off Topic (Score 5)
Guru
Popular Science - Cosmology - Let's keep knowledge expanding Engineering Fields - Retired Engineers / Mentors - Hobbies - HAM Radio - New Member

Join Date: Dec 2006
Location: North America, Earth
Posts: 4528
Good Answers: 106
#34
In reply to #33

Re: Number Theory - Calculations of PI

02/08/2008 10:36 PM

Hi ba/ael,

How did you convert the PDF to a TIFF? Was there another program involved? Please give me the whole details. Sparkstation has a thread about inserting graphics into CR4 posts. I have been trying to use IrFranView which he suggested. It's a pain too. I think that CR4 needs to find an editor that is more compatible with Microsoft Word.

You said you used the Universal Math text. Is that an add-on? I don't seem to have it in my Word.

S

__________________
“I would rather have questions that can't be answered than answers that can't be questioned.” - Richard Feynman
Register to Reply Off Topic (Score 5)
Guru

Join Date: Nov 2007
Location: Sherwood Park, Alberta, Canada
Posts: 1212
Good Answers: 74
#35
In reply to #34

Re: Number Theory - Calculations of PI

02/09/2008 12:09 AM

Hi StandardsGuy,

Yes, there was. I used Bluebeam Revu which is combined with my Microsoft Word to create the TIFF, then Irfanview reads the TIFF and makes the JPEG. The following is the result.

__________________
Bruce
Register to Reply Off Topic (Score 5)
Guru

Join Date: Nov 2007
Location: Sherwood Park, Alberta, Canada
Posts: 1212
Good Answers: 74
#36
In reply to #34

Re: Number Theory - Calculations of PI

02/09/2008 12:19 AM

This was a scan that I made from a paper copy, then brought it in as an image to the CR4 Editor. I'm not sure that it was worth all the trouble, but it does work and we can have whatever Greek letters we are able to generate on our word processor.


__________________
Bruce
Register to Reply Off Topic (Score 5)
Guru
Popular Science - Cosmology - Let's keep knowledge expanding Engineering Fields - Retired Engineers / Mentors - Hobbies - HAM Radio - New Member

Join Date: Dec 2006
Location: North America, Earth
Posts: 4528
Good Answers: 106
#39
In reply to #36

Re: Number Theory - Calculations of PI

02/09/2008 11:48 AM

This looks good. I may try it next time. I've posted my last Number Theory thread using IrFanView. I copied the formulas 1 by 1 to the clipboard, pasted them into IrFanView, then saved them as JPEG files. I then uploaded the Word file to CR4, then inserted the formulas with the camera symbol, and cleaned it up. The formulas take up most of a line this way, but that's OK. I used text size 16 and a bolder font for the formulas to make them show up better. I think your scanning idea would be simpler and quicker.

__________________
“I would rather have questions that can't be answered than answers that can't be questioned.” - Richard Feynman
Register to Reply Off Topic (Score 5)
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#42
In reply to #39

Re: Number Theory - Calculations of PI

02/09/2008 4:40 PM

This line includes the pi symbol p - p - from the Word 'Insert symbol' function. 1st version is 10pt (same as the text), it's a bit small, so second version is upped to 14pt.

The line (or two) above was written using Word, & copy'n'pasted into the CR4 New Comment box. No jpegs, tiffs or anything else - just the clipboard. I've surprised myself!

I was about to submit this - went to 'Preview Comment' - and found 'p' instead of the pi symbol (which is what, I suspect, you folks will see). This is what it looked like in the New Comment box before preview:

(This is a bit of screen-grab done using 'Jasc Paint Shop Pro')

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply Off Topic (Score 5)
Guru

Join Date: Mar 2007
Location: Etherville
Posts: 12362
Good Answers: 115
#37
In reply to #33

Re: Number Theory - Calculations of PI

02/09/2008 4:44 AM

פ') לאגור, לצבור לעת הצורך (כסף, מזון וכו')

I just copied this from a Hebrew translator, and it even backspaces left to right !

Hope it comes out the other side of the editor OK.

__________________
For sale - Signature space. Apply on self addressed postcard..
Register to Reply Off Topic (Score 5)
Guru

Join Date: Mar 2007
Location: Etherville
Posts: 12362
Good Answers: 115
#38
In reply to #37

Re: Number Theory - Calculations of PI

02/09/2008 4:48 AM

Yep, and I can copy from the above post to word, edit, and re-paste to CR4 as text;

אגורהצורך (כסף, מזון וכו'

__________________
For sale - Signature space. Apply on self addressed postcard..
Register to Reply Off Topic (Score 5)
Guru

Join Date: Nov 2007
Location: Sherwood Park, Alberta, Canada
Posts: 1212
Good Answers: 74
#40
In reply to #38

Re: Number Theory - Calculations of PI

02/09/2008 11:49 AM

Great Kris, but how does your π (pi) look?

__________________
Bruce
Register to Reply Off Topic (Score 5)
Guru

Join Date: Mar 2007
Location: Etherville
Posts: 12362
Good Answers: 115
#53
In reply to #40

Re: Number Theory - Calculations of PI

02/13/2008 3:37 AM

Ah, I see the dilema. Seems odd that it accepts all those funny lettering I used earlier. I need to re-read all the post you guys have made.......

__________________
For sale - Signature space. Apply on self addressed postcard..
Register to Reply Off Topic (Score 5)
Guru
Popular Science - Cosmology - Let's keep knowledge expanding Engineering Fields - Retired Engineers / Mentors - Hobbies - HAM Radio - New Member

Join Date: Dec 2006
Location: North America, Earth
Posts: 4528
Good Answers: 106
#41
In reply to #38

Re: Number Theory - Calculations of PI

02/09/2008 12:16 PM

Kris,

Things always look good when you paste them into the text box on CR4. It's when you review the text that everything goes bonkers.

S

__________________
“I would rather have questions that can't be answered than answers that can't be questioned.” - Richard Feynman
Register to Reply Off Topic (Score 5)
Guru
Popular Science - Cosmology - New Member United States - Member - New Member

Join Date: Apr 2007
Location: 33.49N, 84.19W
Posts: 1475
Good Answers: 3
#43
In reply to #38

Re: Number Theory - Calculations of PI

02/09/2008 8:25 PM

Hi Kris,

Now here is a large п and a small π. In addition we can insert any of numerous math symbols such as ω ψ χ φ and so on. This is not MS Word, but Open Office 2.3, which, in my opinion is much better than Word. It's also open source and free!

No conversions or any of that nonsense. Just copied it directly from OO2.3 directly into new comment editor.

Interesting that the small PI above looked just like the one in JohnDG's post (#8), before I previewed it. After that it looks as you see it above.

-John

__________________
All worthwhile programmers know that constants always vary.
Register to Reply
2
Guru

Join Date: Aug 2007
Location: Indiana, USA
Posts: 579
Good Answers: 61
#11
In reply to #6

Re: Number Theory - Calculations of PI

02/06/2008 1:17 PM

Ramanujan developed the convergent series shown below. More details are available at http://planetmath.org/encyclopedia/RamanujansFormulaForPi.html (Sorry, link no longer available.)

__________________
Experience: The knowledge you gain just AFTER you needed it.
Register to Reply Good Answer (Score 2)
Guru

Join Date: Mar 2007
Location: Etherville
Posts: 12362
Good Answers: 115
#14
In reply to #11

Re: Number Theory - Calculations of PI

02/06/2008 3:11 PM

Very cool . Have a point, it's a very good piece of input !

__________________
For sale - Signature space. Apply on self addressed postcard..
Register to Reply Off Topic (Score 5)
Guru
Popular Science - Cosmology - Let's keep knowledge expanding Engineering Fields - Retired Engineers / Mentors - Hobbies - HAM Radio - New Member

Join Date: Dec 2006
Location: North America, Earth
Posts: 4528
Good Answers: 106
#16
In reply to #11

Re: Number Theory - Calculations of PI

02/06/2008 6:44 PM

Thanks pwr2thepeople,

The formula looks familiar, so I think I have seen it before. Now I know where to find it. Did you see any programs that implemented it?

S

__________________
“I would rather have questions that can't be answered than answers that can't be questioned.” - Richard Feynman
Register to Reply
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#19
In reply to #16

Re: Number Theory - Calculations of PI

02/06/2008 8:07 PM

0! = 1 by (some strange) definition. Always puzzled me, to.

Can't see any irrational numbers in the denominator.

If you're thinking about √2 (in the numerator), you can find that to arbitrary precision by repeated application of the Newton-Raphson method (if my memory serves me well):

Take a guess. Divide into 2. Take average of the guess and the result. Call this new guess. Repeat.

Guess = 1

2/(1) = 2 (1+2)/2 = 1.5

2/(1.5) = 1.33.. (1.5+1.33)/2 = 1.415

2/(1.415) = 1.413 (1.415+1.413)/2 = 1.414 etc. Getting close!

[Edit: apologies - just re-read and saw (1/√2) in the approximation version. Newton-Raphson still applies.]

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply
Guru

Join Date: Nov 2007
Location: Sherwood Park, Alberta, Canada
Posts: 1212
Good Answers: 74
#20
In reply to #19

Re: Number Theory - Calculations of PI

02/06/2008 9:47 PM

Thanks JohnDG. I was not familiar with the Newton-Raphson method, but I will take a little time to think about it.

__________________
Bruce
Register to Reply
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#25
In reply to #20

Re: Number Theory - Calculations of PI

02/07/2008 6:37 AM

By coincidence, I was trying to explain it to my 11-year-old daughter the other day.

She had a set of homework questions like:

"Find two consecutive numbers such that, when they are multiplied together, they give the following results:

1) 812."

My idea was to get her to approximate the square root, then pick the nearest two consecutive numbers which, when multiplied, would give a result ending in 2.

800 = 40 x 20, so try 30 (somewhere in between).

812/30 ≈ 27, so √812 ≈ (30+27)/2 = 28.5

8 x 9 ends in 2, so try 28 x 29. Bingo!

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply Off Topic (Score 5)
Guru
Popular Science - Cosmology - Let's keep knowledge expanding Engineering Fields - Retired Engineers / Mentors - Hobbies - HAM Radio - New Member

Join Date: Dec 2006
Location: North America, Earth
Posts: 4528
Good Answers: 106
#28
In reply to #25

Re: Number Theory - Calculations of PI

02/07/2008 10:19 PM

Cool John,

My approach might have been:

divided 812 by 10 - gives 10 * 81. Too far apart.

Multiply and divide by 2 - gives 20 * 40. Still too far.

Add and subtract the same - gives 30 * 30. Not consecutive.

Try 29 * 30. Product is too big.

Try 28 * 29. Got it!

S

__________________
“I would rather have questions that can't be answered than answers that can't be questioned.” - Richard Feynman
Register to Reply Off Topic (Score 5)
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#31
In reply to #28

Re: Number Theory - Calculations of PI

02/08/2008 3:26 AM

We used a similar approach for the first few, then I wanted to bring in the square root idea (she'd already gone way past the required no. of problems on her sheet). Also the fact that the products ended in 0, 2 or 6, so it saved having to try some of the combinations. (e.g. 29 * 30 ends in 0, so must be wrong).

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply Off Topic (Score 5)
Guru

Join Date: Mar 2007
Location: Etherville
Posts: 12362
Good Answers: 115
#22
In reply to #19

Re: Number Theory - Calculations of PI

02/07/2008 2:31 AM

Re 0! = 1

(n!)(n+1) = (n+1)!

inserting 0

(0!)(1) = (1)!

0! = 1

__________________
For sale - Signature space. Apply on self addressed postcard..
Register to Reply
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#24
In reply to #22

Re: Number Theory - Calculations of PI

02/07/2008 6:23 AM

Oh, yea. All comes flooding back. Ta.

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply Off Topic (Score 5)
Guru

Join Date: Mar 2007
Location: Etherville
Posts: 12362
Good Answers: 115
#26
In reply to #24

Re: Number Theory - Calculations of PI

02/07/2008 12:22 PM

Thanks to you too John - I knew the square root iteration, but not it's name. It's very cool, because it zooms in real fast (even with a wild first guess).

__________________
For sale - Signature space. Apply on self addressed postcard..
Register to Reply Off Topic (Score 5)
Guru
Popular Science - Cosmology - Let's keep knowledge expanding Engineering Fields - Retired Engineers / Mentors - Hobbies - HAM Radio - New Member

Join Date: Dec 2006
Location: North America, Earth
Posts: 4528
Good Answers: 106
#27
In reply to #16

Re: Number Theory - Calculations of PI

02/07/2008 9:53 PM

Hi ba/ael,

Thanks for this. I noticed that it achieves more than single precision accuracy in 1 iteration. I wonder though if it is really faster (for elapsed time) for lots of digits than the 'second best' because of the complexity of the factorials. They would slow down the processing time. Any idea how Ramanujan came up with his formula?

S

__________________
“I would rather have questions that can't be answered than answers that can't be questioned.” - Richard Feynman
Register to Reply
Guru

Join Date: Nov 2007
Location: Sherwood Park, Alberta, Canada
Posts: 1212
Good Answers: 74
#29
In reply to #27

Re: Number Theory - Calculations of PI

02/07/2008 11:57 PM

Hi StandardsGuy,

I can't see how evaluating this expression would be easy or fast. It certainly wouldn't be for me! How he came up with his formula is not clear to me, but you can read more about it at: http://en.wikipedia.org/wiki/Pi.

The following is an excerpt:

In the beginning of the 20th century, the Indian mathematician Srinivasa Ramanujan found many new formulas for π, some remarkable for their elegance and mathematical depth.[23] One of his most famous formulas is the series

which can be derived using the theory of modular functions.[23] The series converges extraordinarily quickly, adding about eight decimals per term.[23] Due to scarce distribution of Ramanujan's published work, it was however not widely known until around 1985 when William Gosper used it to calculate 17 million decimals of π. Based on Ramanujan's ideas, Gregory and David Chudnovsky also found the formula

which delivers 14 digits per term.[23] The Chudnovsky brothers used this formula to set several π computing records in the end of the 1980s, including the first calculation of over one billion (1,011,196,691) decimals in 1989. It remains the formula of choice for π calculating software that runs on personal computers, as opposed to the supercomputers used to set modern records.

__________________
Bruce
Register to Reply Score 1 for Good Answer
Guru

Join Date: Nov 2007
Location: Sherwood Park, Alberta, Canada
Posts: 1212
Good Answers: 74
#30
In reply to #29

Re: Number Theory - Calculations of PI

02/08/2008 12:22 AM

Speaking of pi, which most of us pronounce "pie" but should in fact be pronounced "pee", the expression e = -1 is considered one of the most remarkable equations in mathematics, relating in one simple equation the base of natural logarithms, the imaginary part of a complex number and π (pi)


, Euler's identity, named after Leonhard Euler, is the equation

where

is Euler's number, the base of the natural logarithm, is the imaginary unit, one of the two complex numbers whose square is negative one (the other is ), and is pi, the ratio of the circumference of a circle to its diameter.

Euler's identity is also sometimes called Euler's equation.

__________________
Bruce
Register to Reply Score 1 for Good Answer
Guru
Popular Science - Cosmology - Let's keep knowledge expanding Engineering Fields - Retired Engineers / Mentors - Hobbies - HAM Radio - New Member

Join Date: Dec 2006
Location: North America, Earth
Posts: 4528
Good Answers: 106
#32
In reply to #29

Re: Number Theory - Calculations of PI

02/08/2008 4:40 PM

Wow, an even better one! You get a gold star. This one has 3 factorials instead of 2, but yields 14 digits per term instead of 8! Interesting stuff in both of your new posts.

S

__________________
“I would rather have questions that can't be answered than answers that can't be questioned.” - Richard Feynman
Register to Reply
Guru

Join Date: Mar 2007
Location: Etherville
Posts: 12362
Good Answers: 115
#3

Re: Number Theory - Calculations of PI

02/05/2008 6:17 AM

The current record for Pi is over a Trillion places. Forgive me for not posting them !

I like QBasic (), though I haven't tinkered with it for ages. I once set up a sub-routine to increase the precision ( Microsoft Excel couldn't deliver what I wanted) for some daft bit of curiosity research. QBasic seems to have a bit of a cult following.

What's with the Pentium 90 - Have you run Prog 4 on a fast processor, or you just having a bit of retro fun ?

__________________
For sale - Signature space. Apply on self addressed postcard..
Register to Reply
Guru
Popular Science - Cosmology - Let's keep knowledge expanding Engineering Fields - Retired Engineers / Mentors - Hobbies - HAM Radio - New Member

Join Date: Dec 2006
Location: North America, Earth
Posts: 4528
Good Answers: 106
#7
In reply to #3

Re: Number Theory - Calculations of PI

02/05/2008 11:02 PM

I think I had bought Quick-Basic before Qbasic came out, and Qbasic is less powerful, so I never used it much. Now I mostly use HP Basic for windows (now written by Transera). It has PI built in and uses double precision, so you don't need to define PI in your variables list.

"What's with the Pentium 90 - Have you run Prog 4 on a fast processor, or you just having a bit of retro fun ?

Although I have never had the latest and greatest, this was done a few years ago, and I have not run it recently. BTW, the number theory series was to be a chapter in a math book that has never been published.

S

__________________
“I would rather have questions that can't be answered than answers that can't be questioned.” - Richard Feynman
Register to Reply
Guru

Join Date: Mar 2007
Location: Etherville
Posts: 12362
Good Answers: 115
#9
In reply to #7

Re: Number Theory - Calculations of PI

02/06/2008 3:19 AM

Thanks S,

I shall have to go back and look at my version of Q-Basic. I think it shipped free with WFWG, and has Pi built in ( very possibly wrong - I sort of recall entering a value now I think about it. Finding work-rounds for it's shortcomings is half the fun. I've subsequently copied it across to newer computers, because it's so easy to use. It also does the job for stuff that I tinker with. I wouldn't want to do graphics with it (though I've seen some nice ones). VB just doesn't seem like programming to me, but I never invested any real time in playing with it.

Was the book you mention one that you've been working on ? It sounds interesting.

Kris

__________________
For sale - Signature space. Apply on self addressed postcard..
Register to Reply
Guru
Popular Science - Cosmology - Let's keep knowledge expanding Engineering Fields - Retired Engineers / Mentors - Hobbies - HAM Radio - New Member

Join Date: Dec 2006
Location: North America, Earth
Posts: 4528
Good Answers: 106
#17
In reply to #9

Re: Number Theory - Calculations of PI

02/06/2008 6:48 PM

"Was the book you mention one that you've been working on ? It sounds interesting."

No, I haven't for a while. I use it for notes when I forget how to do something.

__________________
“I would rather have questions that can't be answered than answers that can't be questioned.” - Richard Feynman
Register to Reply Off Topic (Score 5)
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#18
In reply to #7

Re: Number Theory - Calculations of PI

02/06/2008 7:38 PM

Coincidentally, I was over at the factory (I'm a solo (mostly) electronics/software guy, but they pay me - as in my biggest contractor) looking at a new build, when I was asked to look at an old bit of QB45 stuff I'd written years ago for up/downloading CNC progs to a Bridgeport mill.

They'd scrapped the Win95 machine & tried to run it on a "new" XP box (about 5 yrs old!). Clapped out with Error 76.

The old system accepted "C:\dirname\" as a valid path, but the new one would only take "C:\dirname".

"CD C:\dirname\" worked from the command line, but "CHDIR C:\dirname\" in the code gave the error 76. ??? Beats me.

Anyway, it works now.

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply Off Topic (Score 5)
Power-User

Join Date: Aug 2007
Posts: 479
Good Answers: 9
#4

Re: Number Theory - Calculations of PI

02/05/2008 8:25 AM

Pi = 3.14159265359. This should be close enough using CAS on an HP graphing calculator in approximate mode. Far better than double precision and no coding required. The CAS system on this calculator is very powerful and will exceed anything you are likely to code.

In exact mode, pi will be placed on the stack for use in subsequent calculations.

Register to Reply
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#5
In reply to #4

Re: Number Theory - Calculations of PI

02/05/2008 8:55 AM

Wow! I never knew finding was that easy! I must go out and buy one of them.

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply
Guru

Join Date: Aug 2005
Location: Hemel Hempstead, UK
Posts: 5826
Good Answers: 322
#23
In reply to #5

Re: Number Theory - Calculations of PI

02/07/2008 6:11 AM

I've got Russel Webb's RPN calculator on my ancient palm. It displays (and uses) ∏ to 16 digits.

Absolutely brilliant calculator! $29 (As long as you've a palm OS devise)

http://www.nthlab.com/

__________________
If you spend all your time looking for people and things to complain about: trust me, you will find plenty to complain about.
Register to Reply
Guru
Hobbies - DIY Welding - Wannabeabettawelda

Join Date: May 2007
Location: Annapolis, Maryland
Posts: 7940
Good Answers: 458
#12

Re: Number Theory - Calculations of PI

02/06/2008 3:03 PM

There is also the Monte Carlo method of approximating Pi using the unit circle inscribed within a unit square. Using random number generator to generate x and y coordinates between 0 and 1, count the number of instances where x^2 + y^2 <= 1, multiply that number by four, then divide by the total number iterations to get the approximation of Pi. Of course, this is not a speedy method, and the fidelity of the result will depend on using a large number of samples, and the randomness of the random number generator.

I guess we could use Pi as the basis of the random number generator -- D'oh !!

Register to Reply
Guru

Join Date: Mar 2007
Location: Etherville
Posts: 12362
Good Answers: 115
#13
In reply to #12

Re: Number Theory - Calculations of PI

02/06/2008 3:07 PM

This is just a cunning ruse to play blind-folded darts down the Pub. Excellent strategy Sir Robin !

__________________
For sale - Signature space. Apply on self addressed postcard..
Register to Reply Off Topic (Score 5)
Guru
Hobbies - DIY Welding - Wannabeabettawelda

Join Date: May 2007
Location: Annapolis, Maryland
Posts: 7940
Good Answers: 458
#15
In reply to #13

Re: Number Theory - Calculations of PI

02/06/2008 3:13 PM

Works for me !!

Register to Reply Off Topic (Score 5)
Power-User
Hobbies - CNC - New Member

Join Date: Nov 2007
Location: Bronkhorstspruit, Gauteng, South Africa
Posts: 128
Good Answers: 9
#21

Re: Number Theory - Calculations of PI

02/07/2008 12:44 AM

Why all the trouble?

For all practical engineering purposes pi= 22/7 is close enough.

22/7 = 3.1428571

pi= 3.1415927 according to my calculator.

__________________
Johan van Niekerk
Register to Reply
Guru
United Kingdom - Member - New Member Hobbies - Musician - New Member Engineering Fields - Mechanical Engineering - New Member Hobbies - Target Shooting - New Member Engineering Fields - Power Engineering - New Member Hobbies - Fishing - New Member

Join Date: Mar 2007
Location: South-east corner of Spain 50 48 49.24N 2 28 27.70W
Posts: 1508
Good Answers: 31
#44

Re: Number Theory - Calculations of PI

02/12/2008 9:56 AM

There is a lot more to pi than I thought! All my life I have thought pi was 22/7, the ratio of circumference to diameter! After reading the post, there have been various formula for getting a more accurate pi. They all come back with numbers around the 3.1416 with a few extra numbers after, so how do we actually know what is the true value of pi! My question is, 22/7, was this just a ball park figure thrown at us at school or what?

Just out of curiosity, I punched in 22/7 on the computer calculator and it came back with 3.1428571428571428571428571, it kept repeating the 1428571 sequence! How strange!!

Please remember, maths is not one of my fortes, so be kind

__________________
“It's kind of fun to do the impossible.” Walt Disney
Register to Reply
Guru

Join Date: Nov 2007
Location: Sherwood Park, Alberta, Canada
Posts: 1212
Good Answers: 74
#45
In reply to #44

Re: Number Theory - Calculations of PI

02/12/2008 10:50 AM

Not so strange when you consider that 21/7 = 3, so 22/7 is 3 + 1/7 and 1/7 is equal to the repeating fractional part which you found. You can see why if you do the division by hand. Similarly, 1/9 is 0.11111 ad infinitum.

The value of 22/7 for pi is an approximation which we were given at school, close enough for most purposes but not exact.

__________________
Bruce
Register to Reply
Guru
United Kingdom - Member - New Member Hobbies - Musician - New Member Engineering Fields - Mechanical Engineering - New Member Hobbies - Target Shooting - New Member Engineering Fields - Power Engineering - New Member Hobbies - Fishing - New Member

Join Date: Mar 2007
Location: South-east corner of Spain 50 48 49.24N 2 28 27.70W
Posts: 1508
Good Answers: 31
#46
In reply to #45

Re: Number Theory - Calculations of PI

02/12/2008 1:59 PM

Cheers Bruce, that all made good sense So all the formula above will give different answers when you start getting down to a few decimal points! This throws me a bit, how do we know what is the correct figure for ? Is a formula deemed correct if it gives π to 'n' decimal places? The pi you checked it against, how did you arrive at that figure? Could I state that pi=22/6 to no decimal places? (I would have a 3 to play with!)

I'm sorry if this is Basics for you guys but I have just had to chuck out my old pi!

__________________
“It's kind of fun to do the impossible.” Walt Disney
Register to Reply
Guru

Join Date: Nov 2007
Location: Sherwood Park, Alberta, Canada
Posts: 1212
Good Answers: 74
#47
In reply to #46

Re: Number Theory - Calculations of PI

02/12/2008 5:29 PM

The pi you checked it against, how did you arrive at that figure?

Most calculators have pi on them at the touch of a button. The expression 22/7 is 0.1000402*pi, so it is adequate for nearly all purposes.

Could I state that pi=22/6 to no decimal places?

Why not say pi = 3 to no decimal places? It's simpler and more accurate.

__________________
Bruce
Register to Reply
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#48
In reply to #47

Re: Number Theory - Calculations of PI

02/12/2008 8:35 PM

(22/7 is 0.1000402*pi - sorry to be picky - but I think you slipped a d.p., there. John.)

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply Off Topic (Score 5)
Guru

Join Date: Nov 2007
Location: Sherwood Park, Alberta, Canada
Posts: 1212
Good Answers: 74
#50
In reply to #48

Re: Number Theory - Calculations of PI

02/12/2008 8:51 PM

You are absolutely right JohnDG! I just wanted to see if you were paying attention. Actually 22/7 = 1.000402*pi.

__________________
Bruce
Register to Reply Off Topic (Score 5)
Guru
Popular Science - Cosmology - New Member United States - Member - New Member

Join Date: Apr 2007
Location: 33.49N, 84.19W
Posts: 1475
Good Answers: 3
#49
In reply to #47

Re: Number Theory - Calculations of PI

02/12/2008 8:50 PM

Here's an interesting little tidbit about Pi:

"it is known that most irrational numbers are
"normal," that is, every k-digit string appears "equally often," for
every positive integer k. (To make this rigorous is possible, but not
quite obvious.)

From these examples, it is clear that not every irrational number is
normal.

It is not known whether or not Pi is normal, although most
mathematicians probably believe this. It is extremely hard to prove
that any particular irrational number is normal. If Pi is normal, then
your friends are right, and somewhere down the line, there will be a
million 2's in a row. In fact, this will occur at infinitely many
different places in the decimal expansion of Pi. If Pi is not normal,
then a million 2's may or may not ever occur."
(from The Math Forum).

-John

__________________
All worthwhile programmers know that constants always vary.
Register to Reply
Guru
United Kingdom - Member - New Member Hobbies - Musician - New Member Engineering Fields - Mechanical Engineering - New Member Hobbies - Target Shooting - New Member Engineering Fields - Power Engineering - New Member Hobbies - Fishing - New Member

Join Date: Mar 2007
Location: South-east corner of Spain 50 48 49.24N 2 28 27.70W
Posts: 1508
Good Answers: 31
#55
In reply to #47

Re: Number Theory - Calculations of PI

02/14/2008 12:00 PM

Cheers again Bruce! I think I'll just sit back and watch the thread! My rainbow book 3 maths will have to do for the moment! I will leave the dilemmas of pi to you guys!

__________________
“It's kind of fun to do the impossible.” Walt Disney
Register to Reply
Guru
Popular Science - Cosmology - New Member United States - Member - New Member

Join Date: Apr 2007
Location: 33.49N, 84.19W
Posts: 1475
Good Answers: 3
#51
In reply to #46

Re: Number Theory - Calculations of PI

02/12/2008 8:52 PM

Only in Alabama...

__________________
All worthwhile programmers know that constants always vary.
Register to Reply
Guru
Popular Science - Cosmology - Let's keep knowledge expanding Engineering Fields - Retired Engineers / Mentors - Hobbies - HAM Radio - New Member

Join Date: Dec 2006
Location: North America, Earth
Posts: 4528
Good Answers: 106
#52
In reply to #51

Re: Number Theory - Calculations of PI

02/12/2008 11:17 PM

Good one, JJ.

It's not just in Alabama that the Bible is misinterpreted!

What would happen if someone baked a square pie? Would the universe explode?

S

__________________
“I would rather have questions that can't be answered than answers that can't be questioned.” - Richard Feynman
Register to Reply
Guru
Popular Science - Cosmology - New Member United States - Member - New Member

Join Date: Apr 2007
Location: 33.49N, 84.19W
Posts: 1475
Good Answers: 3
#54
In reply to #52

Re: Number Theory - Calculations of PI

02/13/2008 6:00 PM

No. PI R not square. PI are round and cornbread R square.

__________________
All worthwhile programmers know that constants always vary.
Register to Reply
Guru
Popular Science - Cosmology - Let's keep knowledge expanding Engineering Fields - Retired Engineers / Mentors - Hobbies - HAM Radio - New Member

Join Date: Dec 2006
Location: North America, Earth
Posts: 4528
Good Answers: 106
#56
In reply to #54

Re: Number Theory - Calculations of PI

02/15/2008 12:00 AM

R Squared =

__________________
“I would rather have questions that can't be answered than answers that can't be questioned.” - Richard Feynman
Register to Reply
Guru
Popular Science - Cosmology - New Member United States - Member - New Member

Join Date: Apr 2007
Location: 33.49N, 84.19W
Posts: 1475
Good Answers: 3
#57
In reply to #56

Re: Number Theory - Calculations of PI

02/15/2008 1:09 PM

Good one S.

Here's another take.

Hmmmmm... looks like R Squared = should be Pie Squared =

What's the value of () ^2?

-John

__________________
All worthwhile programmers know that constants always vary.
Register to Reply
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#58
In reply to #57

Re: Number Theory - Calculations of PI

02/15/2008 5:08 PM

Can't do that - but here's ...

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply
Guru
Popular Science - Cosmology - New Member United States - Member - New Member

Join Date: Apr 2007
Location: 33.49N, 84.19W
Posts: 1475
Good Answers: 3
#59
In reply to #58

Re: Number Theory - Calculations of PI

02/15/2008 6:23 PM

Good one.

Does √Evil = $, or does $² = √(Power)² ?

__________________
All worthwhile programmers know that constants always vary.
Register to Reply
Power-User

Join Date: Dec 2007
Location: Franklin, NC
Posts: 111
Good Answers: 5
#60

Re: Number Theory - Calculations of PI

03/31/2008 11:13 AM

Did you know that Ramanujen had only a highschool education and was working in a post office when he was brought to Trinity College? There was an excellent bio of him on public television several years ago called The Man Who Loved Numbers.

https://enterprise.maa.org/scripts/WA.EXE?A2=ind9910&L=MATH-HISTORY-LIST&D=1&T=0&P=4958

__________________
Peace be upon you.
Register to Reply
Guru
Popular Science - Cosmology - New Member United States - Member - New Member

Join Date: Apr 2007
Location: 33.49N, 84.19W
Posts: 1475
Good Answers: 3
#61
In reply to #60

Re: Number Theory - Calculations of PI

03/31/2008 11:29 AM

Hi Skelley,

The link you posted redirects to a Myfreeze.com error handling page.

-John

__________________
All worthwhile programmers know that constants always vary.
Register to Reply
Guru
United Kingdom - Member - Not a New Member Hobbies - Musician - New Member Hobbies - Fishing - New Member

Join Date: May 2006
Location: Reading, Berkshire, UK. Going under cover.
Posts: 9684
Good Answers: 468
#62
In reply to #60

Re: Number Theory - Calculations of PI

04/02/2008 6:16 PM

I get a "Certificate error - navigation blocked" message, giving dire warnings about the possible dangers of following the link.

BTW - I think I heard a program about this guy last year on BBC Radio 4. Searching the BBC site gets no hits, but there's a good entry on the U. of St. Andrews site.

__________________
"Love justice, you who rule the world" - Dante Alighieri
Register to Reply
Register to Reply 62 comments

Good Answers:

These comments received enough positive votes to make them "good answers".

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Copy to Clipboard

Users who posted comments:

ba/ael (11); Brave Sir Robin (2); Johan van Niekerk (1); JohnDG (12); Johnjohn (7); Kris (9); Mr. Truman Brain (3); pwr2thepeople (1); Randall (1); Skelley (1); StandardsGuy (12); user-deleted-1105 (1); user-deleted-9 (1)

Previous in Forum: Harmonic Problem Single Phase   Next in Forum: ALL ABOUT SARAH BOONE

Advertisement