Solutions

In[31]:=

(*1 --4*)A = Table[{x, 1/(25x^2 + 1)}, {x, -1, 1, 0.2}] ; poly = Interpolati ... on[A] ; Plot[{poly, intf[x]}, {x, -1, 1}, PlotStyle {Hue[0], Hue[1/3]}] 

[Graphics:../HTMLFiles/ex03_solutions_65.gif]

Out[34]=

⁃Graphics⁃

It appears that the interpolating polynomial overshoots the function very badly, at least near the edges of the interpolation area. A finer spacing only makes the problem worse. A piecewise interpolation works much better for this case.

In[35]:=

A = Table[{x, 1/(25x^2 + 1)}, {x, -1, 1, 0.1}] ;

poly = InterpolatingPolynomial[A, x] ;

intf = Interpolation[A] ;

Plot[{poly, intf[x]}, {x, -1, 1}]

[Graphics:../HTMLFiles/ex03_solutions_71.gif]

Out[38]=

⁃Graphics⁃

Let's next compare the functions Interpolation and SplineFit:

In[44]:=

<<NumericalMath`SplineFit`

splf = SplineFit[A, Cubic]

ParametricPlot[splf[x], {x, 0, 20}, PlotStyle {Hue[0]}, DisplayFunctionIdentity] ;

Plot[intf[x], {x, -1, 1}, PlotStyle {Hue[2/3]}, DisplayFunctionIdentity] ;

Show[%, %%, DisplayFunction$DisplayFunction]

Out[45]=

SplineFunction[Cubic,  {0., 20.} , <>]

[Graphics:../HTMLFiles/ex03_solutions_79.gif]

Out[48]=

⁃Graphics⁃


Created by Mathematica  (April 10, 2007) Valid XHTML 1.1!