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?
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.
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
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
"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
HUNTSVILLE, Ala. -- NASA engineers and mathematicians in this high-tech city are stunned and infuriated after the Alabama state legislature narrowly passed a law yesterday [March 30, 1998] redefining pi, a mathematical constant used in the aerospace industry. The bill to change the value of pi to exactly three was introduced without fanfare by Leonard Lee Lawson (R, Crossville), and rapidly gained support after a letter-writing campaign by members of the Solomon Society, a traditional values group. Governor Guy Hunt says he will sign it into law on Wednesday.
The law took the state's engineering community by surprise. "It would have been nice if they had consulted with someone who actually uses pi," said Marshall Bergman, a manager at the Ballistic Missile Defense Organization. According to Bergman, pi (p) is a Greek letter that signifies the ratio of the circumference of a circle to its diameter. It is often used by engineers to calculate missile trajectories.