# Using the InterpolatingPolynomial function

How can I find the interpolation polynomial for the function $f(x) = \frac{1}{1+2x^2}$ with interpolation knots $x_k = 1 + 0.2k , k=0,1,...,6$ using the InterpolatingPolynomial function ?

You can do it like this:

f[x_] := 1/(1 + 2 x^2)
pts = Table[With[{x = 1 + .2 k}, {x, f[x]}], {k, 0, 6}];
p[x_] = InterpolatingPolynomial[pts, x]

0.093633 +
(-0.19975 + (0.139123 + (-0.0669098 + (0.0386536 +
(-0.0136543 + 0.00134761 (-1.4 + x))
(-1.2 + x)) (-2. + x)) (-1.6 + x)) (-1. + x)) (-2.2 + x)


The result is given in a computationally efficient form. If you want something that looks more like traditional output, then

p[x] // Expand


1.47809 - 2.29614 x + 1.75093 x^2 - 0.771355 x^3 + 0.196779 x^4 - 0.0263218 x^5 + 0.00134761 x^6

• It should probably be noted that the example function being considered is the classical example for demonstrating the Runge phenomenon; that is, it is generally a bad idea to use equispaced interpolation points for approximating functions. – J. M.'s technical difficulties Dec 13 '15 at 18:39
• @J.M. +1. This was news to me. I had to look up "Runge phenomenon" to understand what you were referring to. Over the interval given by the OP, p[x] does not demonstrate the phenomenon -- the approximation is excellent – m_goldberg Dec 13 '15 at 18:57
• Yes, the interval is small enough in this case that the instability will not be seen; I was anticipating that the OP might eventually widen the interval being considered and then suddenly notice untoward behavior. As you might have already read, increasing the number of points will make it worse. – J. M.'s technical difficulties Dec 13 '15 at 19:03