Calculation

Let us consider an example, using the MapleV command `spline()' which calculates the cubic spline for a given data set.

> for i from 0 to 7 do x.i:=i: od:

> y0:=1.73:y1:=0.89:y2:=1.47:y3:=0.92:y4:=1.95:y5:=1.38:y6:=1.69:y7:=0.53:

> readlib(spline):spl:=spline([x.(0..7)],[y.(0..7)],z,cubic);

[Maple Math]

> ip:=interp([x.(0..7)],[y.(0..7)],z);

[Maple Math]
[Maple Math]

> ll:=[]:for i from 0 to 7 do ll:=[op(ll),[x.i,y.i]]: od:

> ### WARNING: the definition of the type `symbol` has changed'; see help page for details
with(plots):pl1:=plot(ll,z=0..7,style=point,symbol=diamond,color=black):

> pl2:=plot(spl,z=0..7):

> pl3:=plot(ip,z=0..7,linestyle=2,color=blue):

> display({pl1,pl2,pl3});

[Maple Plot]

Here, the Lagrange polynomial is plotted as well to show the difference.