CSCI 297 Assignment F
Summing a series
This program is concerned with functions expressed using the sum of a power series. In theory, such a series is infinite. As we have only a limited amount of precision available in FORTRAN, we will compute partial sums until the difference of two consecutive partial sums is less than some cutoff value.
That is, we have a series:
F(X) = A0 + A1 * X + A2 * X**2 + A3 * X**3 + A4 * X**4 + ...
and for a given value of X we will compute partial sums S1, S2, S3, ... until the difference of two consecutive partial sums is less than, say, 0.0001.
We are going to work with several functions as described next. For all of these, we need a variable:
REAL :: CUTOFF = 0.0001
e**X
The power series for e**X looks like this:
1 + X / 1! + X**2 / 2! + X**3 / 3! + X**4 / 4! + ...
where we are using the factorial function n! = 1 * 2 * 3 * ...* n.
This series converges for all values of X, as the factorials eventually are growing faster than X**n.
We will compute this for X = 0.0, X = 1.0, X = 20.0 and X = -5.0.
ln(X)
We will calculate ln(X) as follows: find a number Y such that X = (1 + Y) / (1 - Y) and then use the series:
ln((1 + Y) / (1 - Y)) = 2 * Y *( 1 + Y**2 / 3 + Y**4 / 5 + Y**6 / 7 + ...
which will converge for values of Y between -1 and +1, as the powers of Y keep getting smaller and the denominators keep getting larger.
Specifically we need Y = (X - 1) / (X + 1).
We will compute this for X = 2.0, X = 5.0 and X = 20.0.
(1 + X)**(0.5)
This is an example of a binomial series:
(1 + B)**N = 1 +
N * X / 1! +
N * (N - 1) * X**2 / 2! +
N * (N - 1) * (N - 2) * X**3 / 3! + ...
If we use N = 0.5, we get the following (first few terms):
(1 + X)**0.5 = 1 - X / 2 - X**2 / 8 - X**3 / 16 - 5 * X**4 / 128 - ...
This again converges for X between -1 and +1.
We will compute this for X = 0.44, X = 0.96 and X = -0.75.
What to do
For each of these, use the series to compute the indicated values. You should be able to use FORTRAN library functions to compute each as well.
Your program should show its work. Print out the partial sums and the difference between the latest partial sum and its predecessor. Stop when the difference is less than CUTOFF.
Also print out the values calculated by the library functions.
Format the output neatly. Make clear which numbers you calculated and which numbers the library functions calculated.
What should be turned in?
As in the preceding assignments, you need to compile and link your program, correcting any errors. Name your program "progF.f90".