M371 - Alexiades
Problem Set 6: Interpolation
A standard way to test interpolation of function or tabulated values is to use
as nodes some of the values and then compare at unused points.
Do the following BY HAND.
1. Construct the (2nd degree) polynomial interpolant for the function
f(x) = √x at the nodes x0=0, x1=1, x2=4
i.e. with data points (xi , yi) where yi=f(xi).
a. using the Lagrange form [write formula, then plug in values!]
b. using the Newton form [write formula, then plug in values!]
c. Verify that they produce the same polynomial.
d. Evaluate the interpolant at x=1/4 and compare with the exact value.
e. Plot both f(x) and the interpolant on [0,4].
This can be done most easily in gnuplot (see Note below):
gnuplot> f(x)=sqrt(x) ; p(x) = (the polynomial you found)
gnuplot> plot [0:4] f(x) with lines lt 3, p(x) with lines lt 1
Does it look like a good interpolant ?
2. Here is a table of (measured) thermal conductivity data for Cu (copper)
as function of Temperature T (in Kelvin):
T (K) 250 300 350 400 500
k (W/m.K) 406 401 396 393 386
a. Using T = 250, 350, 400 as nodes, contstruct a polynomial interpolant of the data.
b. Evaluate the interpolant at T=300 and compare with the data value.
c. Evaluate the interpolant at T=500 and compare with the data value.
Is this interpolation ?
d. Which one does better? why ? should one ever do c. ?
e. Now use T = 250, 350, 400, 500 as interpolation nodes to construct
another polynomial interporpolant.
f. Evaluate the new interpolant at T=300 and compare with the data value.
Compare with b.
3. Should one use interpolation to represent experimentally obtained data ? why ?
Note: In Gnuplot, power is ** (not ^), as in Fortran and Python.
Also, it does correct integer arithmetic: 1/2 is 0,
use: 1.0/2 or 1./2 to force real arithmetic!
To see it, try: print 1/2 and print 1.0/2