Numerical methods and F90, fall 2015

Exercise 2

Return your answers by noon of Wed, Sep 23.

1. Write a program that finds the prime numbers in a given range using the sieve of Eratosthenes.

2. Write a function that calculates cosine from its Taylor series and a main program that will utilize the function. Think how each term of the series can be calculated from the previous one using just a few floating-point operations.

3. Modify the harmonic series program so that the series is calculated by a function. The number of terms is given as a parameter. If an optional parameter giving the minimum value of terms is given the calculation is terminated also when this limit is reached.

4. Assume we have an array a(100). Write statements that:
a) will find the sum of the elements whose index is even.
b) set all negative elements to zero
c) replace all nonzero elements by their inverse.