Note: do not alter the interface RAT.h.
When we grade your program, we will use our version of
the file. It lists some interface functions that you
are not required to implement: these were included
for debugging, and to assist students doing the extra credit.
Checking your work and hints
|
There are many ways to compute pi, but the continued fraction
expansion given in the course packet appears to be one of the
simples and most useful for getting a good rational approximation.
x
arctan(x) = ---------------------
1 + x^2
----------
3 + (2x)^2
---------
5 + (3x)^2
--------
...
For the extra credit, you will probably want to implement some of the optional
interface functions in
RAT.h.
However, you may not add your own.
There are other ways to compute rational approximations to
e and π. The following are accurate to an amazing 16 decimal places:
e = 28245729/10391023, π = 245850922/78256779.
There are lots of
interesting Web sites on π
including
computing the value of π and a
history of π calculations.
Kevin Wayne