Programming Languages assignment II

Assignment II

Due date Tuesday February 13.


This is a paper assignment, to be written in Ada95. Syntax matters: read the
text carefully. You don't need a compiler to write correct code :-)!

1.  From text: exercises 7.2 numbers 1 and 2 (Barnes p. 107)

2.  The sums of inverse powers of the integers have a number of interesting
properties. For example:
 
         Sum (1/n^4)  = (pi ^ 4) / 90,    n = 1, 2 ...

where pi  = 3.141592... and the operator "^" denotes exponentiation.

Write a code fragment (some declarations, and a loop) to verify that this
identity is correct. You have to use floating point numbers. Comparisons
with floating point are inexact, and you can only compute a finite number
of terms, so you must introduce a small epsilon (say 10.0E-9) and check
whether the sum is within epsilon of the expected value. Write the loop to
determine how many terms you need in the sum to get a result that is within
epsilon of the stated result.