Description
1. In your favorite programming language, implement a program that:
• takes as input two points — (x1, f(x1)) and (x2, f(x2)) — and another x value x∗
that is between x1 and x2, and
• computes f(x∗) using simple linear interpolation, as shown in the picture below:
f(x )
2 x x 1
f(x )1
f(x )2
x*
input points
output point
x
f(x)
*
(a) [5 pts] Dig around on the web and find some interesting decadal census data (e.g.,
of India, of your home city, of stray dogs in London, …) that covers at least the last
50 years and preferably the last century. Turn in a plot of your data and a link to the
webpage where you found it. Don’t forget to label your axes.
(b) [15 pts] Use your interpolation code to estimate the value of your chosen quantity
halfway through the most recent decade. (That is, say you know the population of
Cleveland in 2000 and 2010. What was that population in 2005?) If you have access to
yearly data, compare your interpolated result to the true population.
2. [10 pts] The same idea can be applied in order to extrapolate: that is, to find a value
for f(x∗) if x∗ is not between x1 and x2. Using the same data and the same code as in
problem 1, estimate the size of your chosen population in 2050. This will require making
an intelligent choice about what two points to feed your program, and perhaps removing
any “between” error checks that you may have incorporated.
1
3. [10 pts] Use the Lagrangian interpolating polynomial approach to fit a parabola to the
last three points in your data.
Use that polynomial to estimate the size of your population halfway through the last
decade. Compare that to the value that you got in problem 1. Which of the two interpolated values is better, do you think? Would that depend on the shape of the data?
2