ticalc.org
Basics Archives Community Services Programming
Hardware Help About Search Your Account
   Home :: Community :: Surveys :: Will you ever write a program to calculate pi?
Results
Choice Votes   Percent
Yes, but no more than 100 digits 23 12.5%   
Yes, but no more than 10,000 digits 7 3.8%   
Yes, but no more than 1,000,000 digits 3 1.6%   
Yes, but no more than 1,000,000,000 digits 8 4.3%   
Yes, and it will be the largest calculation of pi the world has ever seen! 52 28.3%   
How can you calculate pi with a computer? 74 40.2%   
Pi? Huh? 17 9.2%   

Survey posted 2005-03-14 06:29 by Jon.

Contribute ideas to surveys by sending a mail to survey@ticalc.org.

  Reply to this item

Re: Will you ever write a program to calculate pi?
Benjamin Moody  Account Info

Mine's limited to the size of the 83's memory (4 bytes per base-100 digit, or 2 bytes per decimal digit), so while it can do a few more than 10000, it can't come close to 1000000.

Reply to this comment    14 March 2005, 15:12 GMT


Re: Re: Will you ever write a program to calculate pi?
burntfuse  Account Info
(Web Page)

That just gave me an idea...how about a machine dedicated only to calculating pi? It could have a fast processor with an integrated FPU (to make the programming much easier), very accurate trig tables in the ROM, and HUGE amounts of RAM to store all the digits!

Reply to this comment    14 March 2005, 22:53 GMT

Re: Re: Re: Will you ever write a program to calculate pi?
quickgold Account Info

They already exist. Supercomputers have been reserved for the sole purpose of calculating pi.

Reply to this comment    15 March 2005, 03:30 GMT


Re: Re: Re: Re: Will you ever write a program to calculate pi?
LonePhoenix  Account Info
(Web Page)

what about my favorite number, e?

Reply to this comment    19 March 2005, 02:10 GMT


Re: Re: Re: Re: Re: Will you ever write a program to calculate pi?
CajunLuke  Account Info
(Web Page)

With high probability.

Reply to this comment    19 March 2005, 17:26 GMT

Re: Re: Re: Will you ever write a program to calculate pi?
Benjamin Moody  Account Info

"very accurate trig tables in the ROM"

Um.

Reply to this comment    15 March 2005, 03:55 GMT


Re: Re: Re: Re: Will you ever write a program to calculate pi?
burntfuse  Account Info
(Web Page)

Oh yeah, that is sort of stupid...forget about that part...

Reply to this comment    16 March 2005, 22:01 GMT


Re: Re: Re: Will you ever write a program to calculate pi?
CajunLuke  Account Info
(Web Page)

If you're going to go that far, dispense with software, and make pi calculations a processor function (like square root on the G5). Then write it to a text file on a large SAN setup all RAID 0'ed together. When it's dne, all you'd need to do was move the cable on the SAN to a computer and write a program to read through the file and perform whatever further calculations necessary.

Reply to this comment    15 March 2005, 13:47 GMT


Re: Re: Re: Re: Will you ever write a program to calculate pi?
burntfuse  Account Info
(Web Page)

That's an even better idea...pi calculations in hardware...use a few high-density FPGAs or something like that. :-p

Reply to this comment    19 March 2005, 23:12 GMT

[ ! ]
anykey  Account Info
(Web Page)

I tried, but I don't have the mad math skillz required. :^(

Reply to this comment    14 March 2005, 17:01 GMT

Re: Will you ever write a program to calculate pi?
Coolv  Account Info
(Web Page)

The largest you've ever seen!

Reply to this comment    14 March 2005, 20:03 GMT

Re: Will you ever write a program to calculate pi?
punkrockdude Account Info

Not to be a stupid idiot, but how would one go about writing a program to calculate Pi? (I usually write games, so this isn't really my field.)

Reply to this comment    14 March 2005, 21:27 GMT


Re: Re: Will you ever write a program to calculate pi?
burntfuse  Account Info
(Web Page)

Pi=integral(x=0 to 2,(4-x^2)^.5 dx)
Pi=1+sum(x=0 to infinity, increments of 2,-1/x)
Pi=4 Arccot 1
Pi=4(12 arccot 18 + 8 arccot 57 - 5 arccot 239)
(in the expressions involving infinity, just substitute a very large number - the larger the number, the greater the precision)

BTW, pi is NOT 22/7. (Hey, remember the time that guy said that it was, and we all spammed him with many digits of pi?)

Reply to this comment    14 March 2005, 22:50 GMT

[ ! ]
anykey  Account Info
(Web Page)

Good times...

Reply to this comment    15 March 2005, 00:36 GMT

Re: Re: Re: Will you ever write a program to calculate pi?
KD5PBO  Account Info

Not to be devious or anything, has anybody ever written a program to crash someone's calculator by calculating loadza digits of pi?

Reply to this comment    15 March 2005, 02:37 GMT

Re: Re: Re: Re: Will you ever write a program to calculate pi?
Ryan Nazaretian  Account Info

I don't think that could happen in BASIC, it would just stop and say Error Memory. It could probably happen in ASM, but I'm not sure, I don't program in ASM.

Reply to this comment    15 March 2005, 23:00 GMT


Re: Re: Re: Re: Will you ever write a program to calculate pi?
burntfuse  Account Info
(Web Page)

Do you mean overwriting their memory with digits of pi? It would be a lot easier and just as effective to overwrite it with all $00s or $FFs.

Reply to this comment    19 March 2005, 23:13 GMT


Re: Re: Re: Re: Re: Will you ever write a program to calculate pi?
W Hibdon  Account Info
(Web Page)

Style, buddy. It is all in the presentation and execution more than it is the end result. Yes, you will get the same result, but then you are not doing anything more than anyone else.

-W-

Reply to this comment    22 March 2005, 02:29 GMT

Re: Re: Re: Will you ever write a program to calculate pi?
quickgold Account Info

Can trig functions fairly be used? I'm not sure how they are derived but don't they NEED pi to function in the first place? (Just referring to the two latter examples.) Otherwise you could just type arccos(-1) Which of course is an apporximation.

Reply to this comment    15 March 2005, 03:36 GMT


Re: Re: Re: Re: Will you ever write a program to calculate pi?
burntfuse  Account Info
(Web Page)

No, I think many, if not all, trig functions use sums (the operation associated with those large pointy E-like symbols)...

Reply to this comment    16 March 2005, 22:05 GMT

Re: Re: Re: Re: Re: Will you ever write a program to calculate pi?
no_one_2000_  Account Info
(Web Page)

Ahh, really? I thought they used look-up tables to grab trig values. And that's why you can't calculate pi with arccos(-1). You'd only get as many digits as were stored in the calculator (usually 12, I think?). You'd have to use one of the formulas above (like you were saying; one of the sum formulas) if you wanted to get more than 12(?) digits.

Err, but I'm often wrong, so don't listen to me :-P

Reply to this comment    16 March 2005, 22:44 GMT

Re: Re: Re: Re: Re: Re: Will you ever write a program to calculate pi?
CajunLuke  Account Info
(Web Page)

Most machines probably do use trig tables, or have algorithms that have nothing to do with sigma summations.
But if you /did/ use sigmas to high accuracy, you could get pi with arccos(-1).

Reply to this comment    19 March 2005, 00:00 GMT


Re: Re: Re: Re: Re: Re: Will you ever write a program to calculate pi?
Jake Griffin  Account Info
(Web Page)

Calculators use look-up tables but only because it's quicker than calculating using the summation technique...the lookup tables were calculated using summation...

Reply to this comment    19 March 2005, 19:55 GMT


Re: Re: Re: Re: Re: Will you ever write a program to calculate pi?
CajunLuke  Account Info
(Web Page)

Your "large pointy E-like symbols" are sigmas.

Reply to this comment    18 March 2005, 23:57 GMT


Re: Re: Re: Re: Re: Re: Will you ever write a program to calculate pi?
burntfuse  Account Info
(Web Page)

Thanks, I keep on forgetting the name.

Reply to this comment    19 March 2005, 23:14 GMT

Re: Re: Re: Will you ever write a program to calculate pi?
JcN  Account Info
(Web Page)

Not to sound stupid either (I am also a game programmer), but how do we compute the nth digit of pi? We can get the first 10-ish digits of pi on a calculator, but how do we get the 100th? The 10000? The 3141592653589th digit? Moreover, how do we do it accurately, when registers on an FPU are only 128 bits at most? This we do not know.

Reply to this comment    15 March 2005, 06:03 GMT

Re: Re: Re: Re: Will you ever write a program to calculate pi?
Andree Chea  Account Info
(Web Page)

First Google hit (link)

You can calculate the nth hexit with it!

Reply to this comment    15 March 2005, 06:36 GMT


Re: Re: Re: Re: Will you ever write a program to calculate pi?
Andree Chea  Account Info
(Web Page)

Furthermore, Plouffe discovered a new algorithm to compute the nth digit of p in any base!

A nice pi chronology site (link).

Reply to this comment    15 March 2005, 06:42 GMT

Re: Re: Re: Will you ever write a program to calculate pi?
CajunLuke  Account Info
(Web Page)

But 22/7 is a fair approximation, only .001% less accurate than 3.14. I did the calculations of that myself, like five years ago.

Reply to this comment    15 March 2005, 13:52 GMT

Re: Re: Re: Re: Will you ever write a program to calculate pi?
BlackThunder  Account Info
(Web Page)

Wait...

Only 0.001% less accurate?

That would make (22/7+3.14)/2 an insanely accurate representation of pi.

Okay, not /that/ insanely accurate, but still insanely accurate enough for my purposes.

Reply to this comment    18 March 2005, 23:02 GMT


Re: Re: Re: Re: Re: Will you ever write a program to calculate pi?
CajunLuke  Account Info
(Web Page)

22/7 has a .0402499% error.

3.14 has a .0506957% error.

So I was wrong. 22/7 is better than 3.14. Oops. (I was remembering calculations I did years ago. I got them mixed up.)

The average [(3.14+22/7)/2 = 3.141428571] has a .0052228% error.

So it would be better to use pi.

Reply to this comment    19 March 2005, 17:34 GMT


Re: Re: Re: Re: Will you ever write a program to calculate pi?
burntfuse  Account Info
(Web Page)

Yes, it is accurate enough for most calculations, but it still looks like a huge difference to us nerds who memorize >50 digits of pi. ;-)

Reply to this comment    19 March 2005, 23:15 GMT


Re: Re: Re: Will you ever write a program to calculate pi?
jesse frey  Account Info

here is a c program that will calculate pi it is based on the formula:
PI/4 = 1/1 - 1/3 + 1/5 - 1/7 + ...
the more loops the more accurate.

float pi=1;
unsigned i;
for(i=0;i<100;i++){
float toadd=1/(float)(2*(i+1)+1);
if(i&1)pi+=toadd;
else pi-=toadd;
}
clrscr();
printf("%f",pi*4);
ngetchx();

Reply to this comment    15 March 2005, 22:54 GMT

Re: Re: Re: Re: Will you ever write a program to calculate pi?
burntfuse  Account Info
(Web Page)

That second equation of mine is obviously wrong, and I think the one you wrote is really what it's supposed to be...

Reply to this comment    16 March 2005, 22:03 GMT


Re: Re: Re: Re: Will you ever write a program to calculate pi?
no_one_2000_  Account Info
(Web Page)

Well, two things

I read somewhere that thid method of calculating pi was really inefficient. Like, it takes a ridiculous amount of loops just to get a few digits of accuracy. That does make sense though if you think about 1/n. (Please correct me here if I'm wrong) You'll only have accuracy in pi n digits after the decimal point after you get to the (10^n/2)th loop. So, for just eight digits of accuracy, you'd need 50 million loops. That would take forever.

The other problem with this is, floating points only hold so many digits. I forget how many it is, but they're limited. If you wanted to calculate a lot of digits of pi, you'd need a much larger variable type to work with. Perhaps if you could somehow allocate a large section of memory as a "long long long ..." unsigned integer... I don't know how to do that though. I thought of using a large string when I wanted to make a problem like this a while back, but then I realized that the conversion of numbers to and from the string would take too long and would slow the program down even more.

Anyway, the only real experience I have in calculating pi with a computer is with this program I made in Java a few years back, and if I remember correctly, I only got 7-8 digits of accuracy with it. Sometime in the future I'll come up with a better plan though.

Reply to this comment    16 March 2005, 23:04 GMT

Re: Re: Re: Re: Re: Will you ever write a program to calculate pi?
Jake Griffin  Account Info
(Web Page)

You're right...it does take a huge amount of time, and, without making a super precise class, it won't give you any more precision than the float class in Java anyway...you'd have to find some way to store the number in a string and calculate division of 1 by 5893 accurate to 1,000,000 decimals...ugh...

Reply to this comment    16 March 2005, 23:15 GMT


Re: Re: Re: Re: Re: Will you ever write a program to calculate pi?
burntfuse  Account Info
(Web Page)

Yeah, the entire thing can never be stored in one number, you have to calculate the digits separately or something like that...

Reply to this comment    19 March 2005, 23:17 GMT

1  2  3  4  

You can change the number of comments per page in Account Preferences.

  Copyright © 1996-2012, the ticalc.org project. All rights reserved. | Contact Us | Disclaimer