You are on page 1of 1

Interpolation

Linear Interpolation

1. Given the three data points (x,y)= (1.0,8.0), (2.1,20.6) and (5.0,13.7), write a program to return the value of y for any arbitrary x in the range [1.0,5.0]. The program should exit if x is outside this range.

2. Generalize the above program to input data points from a data file points.dat (a sample program to read data from a data file is given here).

Polynomial Interpolation

3. Repeat problem 1. using a second order polynomial. Compare the y values from linear interpolation with those from the second order polynomial. 4. Plot the polynomial and the input data points for problem 3.

You might also like