QB / QB64 Discussion Forum      Other Subforums, Links and Downloads
  << Previous Topic | Next Topic >>Return to Index  

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

February 11 2012 at 9:11 AM
Tom Brown  (no login)

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   
AuthorReply

(Login burger2227)
R

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

February 11 2012, 9:30 AM 


 
 Respond to this message   
Tom Brown
(no login)

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
(no login)

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   

(Login burger2227)
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
(no login)

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   

(Login burger2227)
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
(no login)

*Good luck at Rugby, Tom

February 12 2012, 8:30 AM 


 
 Respond to this message   
Billy Gates
(no login)

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
(no login)

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
(no login)

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
(no login)

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   

(Login burger2227)
R

* WHO is "he"?

February 12 2012, 6:44 PM 


 
 Respond to this message   
Euclid
(no login)

Pi does equal 2+2/2 (in Alabama)

February 13 2012, 9:19 AM 

The Associalized Press

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.

 
 Respond to this message   
Current Topic - A homework problem (sshh!, don't tell Flippy)
  << Previous Topic | Next Topic >>Return to Index