Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 pi
Index -> Programming, Turing -> Turing Submissions
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
BenLi




PostPosted: 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]
Sponsor
Sponsor
Sponsor
sponsor
ericfourfour




PostPosted: Tue Oct 24, 2006 9:33 pm   Post subject: (No 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.
Tony




PostPosted: Tue Oct 24, 2006 9:42 pm   Post subject: (No 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Zacebdal




PostPosted: 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....
BenLi




PostPosted: Wed Oct 25, 2006 4:16 pm   Post subject: (No 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
Clayton




PostPosted: Wed Oct 25, 2006 4:16 pm   Post subject: (No 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.
ZeroPaladn




PostPosted: Thu Oct 26, 2006 12:46 pm   Post subject: (No 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
Silent Avenger




PostPosted: Thu Oct 26, 2006 3:45 pm   Post subject: (No 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.
Sponsor
Sponsor
Sponsor
sponsor
iamcow




PostPosted: Thu Oct 26, 2006 4:44 pm   Post subject: (No subject)

Quote:
not sure if it is a reliable source


i think that means he's not sure
Silent Avenger




PostPosted: Thu Oct 26, 2006 6:00 pm   Post subject: (No subject)

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




PostPosted: Thu Oct 26, 2006 6:59 pm   Post subject: (No 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
Silent Avenger




PostPosted: Thu Oct 26, 2006 9:50 pm   Post subject: (No 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.
[Gandalf]




PostPosted: Fri Oct 27, 2006 2:53 pm   Post subject: (No 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.
Silent Avenger




PostPosted: Fri Oct 27, 2006 10:48 pm   Post subject: (No 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)
Andy




PostPosted: Sun Oct 29, 2006 5:00 am   Post subject: (No subject)

to find pi, just do an taylor expansion of tan(x). there are faster ways of approximating pi than that gandalf =P
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 20 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: