Computer Science Canada

pi

Author:  BenLi [ Tue Oct 24, 2006 8:25 pm ]
Post subject:  pi

This has to be the most retarded thing i've ever posted... but entertaining (and interesting) nonetheless

code:

setscreen ("graphics:max;max")

var x := 0

drawfilloval (maxx div 2, maxy div 2, maxy div 2, maxy div 2, black)

for i : 1 .. maxx
    for n : 1 .. maxy
        if whatdotcolor (i, n) = black then
            x += 1
        end if
    end for
end for
put "pi is: ", x / (maxy div 2) ** 2
[/quote]

Author:  ericfourfour [ Tue Oct 24, 2006 9:33 pm ]
Post subject: 

That was pretty funny. I didn't even go over the source before I ran it because it looked like another flashy program (it was like 10 lines with 1 draw in a loop) but then all I saw was a big black circle. Then I actually looked at the source and wow. That is one of the most original ways of finding pi ever.

Author:  Tony [ Tue Oct 24, 2006 9:42 pm ]
Post subject: 

well since the accurasy increases with the size of the circle, it would be interesting to see this done in a loop for circle radius from 1 to maxx/2, with something like

code:

put "Radius: ", i, " pi:", num, " Error: ", (PI - num)/PI


and perhaps some graphs of the resulting data Very Happy

Author:  Zacebdal [ Wed Oct 25, 2006 3:08 pm ]
Post subject:  Is it just me?

Is it just me, or maybe i just dont understand but if this is used to find the mathematical value of pi, it is incorrect. Pi, as far as i know and im proud of knowing it Smile,is approximately 3.14159265358979. so maybe im just doing something wrong but anyways....

Author:  BenLi [ Wed Oct 25, 2006 4:16 pm ]
Post subject: 

consider this: with 50 digits of pi, you are able to calculate the biggest circle possible in the observable universe down to the error margin of a single proton. The inversely, you would need a circle as big as the universe to calculate pi to 50 digits (unless you use a computer to simulate this). So obviously this program wouldn't be accurate since the circle is only the size of your moniter. Its accurate to tw digits though! lol

Author:  Clayton [ Wed Oct 25, 2006 4:16 pm ]
Post subject: 

It's because the circle isn't big enough to get that degree of accuracy. To get that good of a degree of accuracy you would have to have a HUGE circle to calculate from.

Author:  ZeroPaladn [ Thu Oct 26, 2006 12:46 pm ]
Post subject: 

googled it. not sure if it is a reliable source, but i found it cool anyways...

here it is, pi to a billion decimal places.

http://3.141592653589793238462643383279502884197169399375105820974944592.com/index1.html

Author:  Silent Avenger [ Thu Oct 26, 2006 3:45 pm ]
Post subject: 

Now how do you know that all those decimal places are correct? Now just for laughs I'm going to print off the first page and show it to my Geometry teacher.

Author:  iamcow [ Thu Oct 26, 2006 4:44 pm ]
Post subject: 

Quote:
not sure if it is a reliable source


i think that means he's not sure

Author:  Silent Avenger [ Thu Oct 26, 2006 6:00 pm ]
Post subject: 

I meant that question to be a rhetorical question, of course the site will most likely be unreliable.

Author:  [Gandalf] [ Thu Oct 26, 2006 6:59 pm ]
Post subject: 

Eh... What?
"Hmm... Why don't I make a website that outputs random numbers claiming to be pi.. Sounds good."

And, Zacebdal, just to show how much work it takes to calculate pi, here's the accuracy after just under one billion iterations of pi = 4 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11...:
3.141592652587059
Compared to the real approximation:
3.141592653589793

Author:  Silent Avenger [ Thu Oct 26, 2006 9:50 pm ]
Post subject: 

[Gandalf] wrote:
Eh... What?
"Hmm... Why don't I make a website that outputs random numbers claiming to be pi.. Sounds good."
I'm not saying it is an unreliable source but it could be. I also find the site has no real point to it because most people only really need pi to the accuracy of 8 decimal places. Now I'm not saying that everybody needs pi to only 8 decimal places because some could use more or less.

Author:  [Gandalf] [ Fri Oct 27, 2006 2:53 pm ]
Post subject: 

Silent Avenger wrote:
of course the site will most likely be unreliable.

Sounds pretty definite to me.

And why not have pi to some large number of decimal places? It's been computed, so why not make it available for everyone to use whenever? Even if it's just for curiosity.

Author:  Silent Avenger [ Fri Oct 27, 2006 10:48 pm ]
Post subject: 

I guess there is no reason to not have pi to a billion decimal places but who would use that many decimal places anyway? (this is a rhetorical question you don't actually need to answer)

Author:  Andy [ Sun Oct 29, 2006 5:00 am ]
Post subject: 

to find pi, just do an taylor expansion of tan(x). there are faster ways of approximating pi than that gandalf =P

Author:  Cervantes [ Sun Oct 29, 2006 10:17 am ]
Post subject: 

Andy wrote:
to find pi, just do an taylor expansion of tan(x). there are faster ways of approximating pi than that gandalf =P


I did that a while back, and I got 15 decimal places of accuracy just from Microsoft's calc.exe. I think 15 was the number of decimal places it displayed.

My question is, is this approach really valid? tan x = sinx / cosx. sinx and cosx come from circles, right? So aren't we using a bit of circular (oh, oh, pun!) reasoning here?

I know sinx and cosx can be approximated by a Taylor series, but my question still remains.

Author:  Windsurfer [ Mon Oct 30, 2006 7:06 pm ]
Post subject: 

Andy wrote:
to find pi, just do an taylor expansion of tan(x). there are faster ways of approximating pi than that gandalf =P

Ha. I've experienced that. On my Ti-83 Plus, I had a basic program that would use that one Gandolf said, and it would take forever to find the first 5 digits. I think it was like 500 iterations? Can't remember.
But then I implemented the taylor expansion method (or something similar) and my calc ran out of digits on the 12th or 14th iteration, so less than 2 seconds Razz

Author:  Andy [ Mon Oct 30, 2006 9:23 pm ]
Post subject: 

but cervantes, you're not using sin(x) and cos(x) to calculate values.

tan(x) = sin(x)/cos(x)

and sin(x) can be expanded into sin(x) = x - x3/3! + x5/5! - x7/7! + ...
and cos(x) into cos(x) = cos(x) = 1 - x2/2! + x4/4! - x6/6! + ...

then you just need to do a long division

so you're not cheating at all =P

Author:  Cervantes [ Tue Oct 31, 2006 12:37 am ]
Post subject: 

How did we get those series for sin(x) and cos(x)?

I think I detect sarcasm in your last sentence there, right? So this method is using circular reasoning, yes? Or does it matter? Since we don't necessarily need a value for pi to find values for sin(x). Or do we?

Author:  Andy [ Tue Oct 31, 2006 1:28 am ]
Post subject: 

you use taylor's theorum to get those series.

you dont actually need to know the value of pi to determine what sin(pi) and cos(pi) is.


: