# A homework problem (sshh!, don't tell Flippy)

February 11 2012 at 9:11 AM

Dick and Jane want to know the value of Pi up to 8 decimal places, but they only have the number 2 to work with. Maybe you can help them. Can you write a program that calculates Pi and contains only the number 2 and no other numbers?

 Respond to this message

R

# * Pi# = 2 * 2 * ATN(2 / 2#)

February 11 2012, 9:30 AM
 Respond to this message
Tom Brown

# Re: * Pi# = 2 * 2 * ATN(2 / 2#)

February 11 2012, 11:06 AM
 You broke one of your cardinal rules for me, Flippy! Thanks Cheerio!
 Respond to this message
lawgin

# Careful, Tom

February 11 2012, 11:30 AM
 I think your teacher might have meant for you to use Viete's Formula to solve this problem. If you submit that simplistic trig representation of Flippy, you're likely to get an F. I encourage you to look-up Viete's Formula for Pi.
 Respond to this message

R

# * F as in Flippy :-P

February 11 2012, 3:31 PM

<img src="http://www.network54.com/images/tongue.gif" height="99" width="99" alt="tongue.gif">

 This message has been edited by burger2227 on Feb 11, 2012 3:42 PM

 Respond to this message
Tom Brown

# Jolly good, Lawgin

February 11 2012, 7:41 PM

I did as you suggested, found Viete Formula, plugged in 2, and out popped Pi.
Thanks to you.
******** to Flippy.

DEFDBL P, S
p = 2
DO
sn = SQR(2 + so)
p = p * 2 / sn
so = sn
LOCATE 1, 1
PRINT p
LOOP WHILE INKEY\$ = ""

 This message has been edited by MCalkins on Feb 12, 2012 8:38 AM

 Respond to this message

R

# You STILL get an F in my book

February 12 2012, 1:59 AM

Your teacher probably meant my code unless they taught you that formula in the class. It is well known.

Best worry about anybody helping you, the code will betray you...

 This message has been edited by burger2227 on Feb 12, 2012 3:03 AM

 Respond to this message
lawgin

# *Good luck at Rugby, Tom

February 12 2012, 8:30 AM
 Respond to this message
Billy Gates

# Certainly

February 12 2012, 3:54 PM
 Since d/dx sin(x) = cos(x), sin(x) is about equal to cos(pi) * (x - pi) for x close to pi. So we can do: x = EXP(2/2) x = x + sin(x) x = x + sin(x) x = x + sin(x) PRINT x or you could do: x = EXP(2/2) for i = 2 to 22: x = x + sin(x): next print x
 Respond to this message
EW Dijkstra

# Better

February 12 2012, 4:11 PM
 DEFDBL A-Z ' Approximates Gaussian integral ' e^(-x^2) from -infinity to +infinity = sqrt(pi) ' to calculate pi ' It is not difficult to prove this integral ' using complex analysis CLS zero = 2 - 2 a = zero b = 22 n = 22222 f = zero dx = (b - a) / n FOR x = a TO b STEP dx f = f + 2 * EXP(-x ^ 2) * dx NEXT f = (f - EXP(-a ^ 2) * dx - EXP(-b ^ 2) * dx) / 2 PRINT 2 * 2 * f * f
 Respond to this message
NoMathForYou

# Version for people who don't like math

February 12 2012, 4:15 PM
 DEFDBL A-Z zero = 2 - 2 one = 2 / 2 two = 2 three = 2 + one four = 2 * 2 five = four + one six = 2 + 2 + 2 seven = six + 1 eight = 2 * 2 * 2 nine = eight + one ten = five * 2 pi = three + one / ten + four / ten ^ 2 pi = pi + one / ten ^ three + five / ten ^ four pi = pi + nine / ten ^ five + two / ten ^ six pi = pi + six / ten ^ seven + five / ten ^ eight PRINT pi
 Respond to this message
Anonymous

# According to the Holy Bible

February 12 2012, 4:24 PM
 "And he made a molten sea, 2+2+2+2+2 cubits from the one rim to the other it was round all about, and...a line of 2^(2+2) + 2^(2+2) - 2 cubits did compass it round about....And it was an hand breadth thick...." — First Kings, chapter 2+2+2+2/2, verses 22+2/2 and 22+2+2 Hence pi = 2+2/2
 Respond to this message

R

# * WHO is "he"?

February 12 2012, 6:44 PM
 Respond to this message
Euclid