An Interpolation problem.

Definition: A function f is said to interpolate the point [x1,y1] if f(x1) = y1. This is a fancy way of saying the graph of f passes through the point [x1,y1].

Problem. Find the line which interpolates the points [0,4] and [1,6].

Solution. Here f(x) = a*x + b. The equations are f(0) = b = 4 and f(1) = a + b = 6. So a = 6 - b = 2. The line is f(x) = 2*x + 4.

Problem. Find the quadratic polynomial which interpolates [2,0], [6,1], and [8,0]

Solution start. Let [Maple Math] . The the equations are {f(2)=0, f(6)=1, f(8)=0}. This is 3 linear equations in the 3 unknowns a,b and c.

Solve this by hand and/or with maple.

Problem. (This is the one I gave in class last Thursday) Find the polynomial of [Maple Math] which interpolates (ie, passes through) the points [2,3],[0,2],[5,7],[-12,14],[7,13],[a,10]

Solution. Set up the polynomial function. The coefficients c1 through c6 are the unknowns.

> f := x->c1+c2*x + c3*x^2 + c4*x^3 +c5*x^4 + c6*x^5 ;

[Maple Math]

Set up the equations that the polynomial must satisfy. There are 4 values given, so there are 4 equations.

> data:=[ [2,3],[0,2],[5,7],[-12,14],[7,13],[a,10]];

[Maple Math]

> eqns := [seq(f(data[i][1])=data[i][2],i=1..nops(data))];

[Maple Math]
[Maple Math]
[Maple Math]

Convert to a matrix equation. (This is not really necessary, but is one way to do it. See the alternative below.)

alternative

>

> A:=linalg[genmatrix](eqns,[c1,c2,c3,c4,c5,c6],B);evalm(B);

[Maple Math]

[Maple Math]

The equation looks like this.

> evalm(A)*convert(vector( [c1,c2,c3,c4,c5,c6] ),matrix) = convert(B,matrix);

[Maple Math]

Solve the equation, by multiplying both sides by the inverse of A. The components of the solution vector are the values for the coefficients a,b, c, and d.

> soln:=simplify(evalm(linalg[inverse](A)&* B));

[Maple Math]
[Maple Math]
[Maple Math]

Substitute in the values for a,b,c, and d.

> g := subs({c1=soln[1],c2=soln[2],c3=soln[3],c4=soln[4],c5=soln[5],c6=soln[6]},op(f));

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

> fsolve(numer(simplify(coeff(g(x),x,5))),a,complex);

[Maple Math]

So there are two real values for a that make the polynomial a 4th degree polynomial.

> g1 := subs(a=-11.03470064,op(g));

[Maple Math]

> g2 := subs(a=6.149705360,op(g));

[Maple Math]

Note that both values for a

To check, plot the polynomial and the points to see that the points are interpolated by the polynomial.

> data;

[Maple Math]

> pl1 :=plot(subs(a=6.149705360,data),style=point,color=blue,symbol=circle):

> pl2:=plot(subs(a=-11.03470064,data),style=point,color=blue,symbol=circle):

> plots[display]([pl1,pl2,plot(g1(x) ,x=-14..8,color=red),plot(g2(x) ,x=-14..8,color=black)],scaling=constrained);

[Maple Plot]

Problem. Change the last point [a,10] to [10,a] and resolve the problem above. Is the value for a unique?