You are on page 1of 2

Consider the function p[x] = 1/ (1+x^2).

Fit a natural cubic spline to this function by

using an even number of segments (at least four). I am using a set of line segments, and

each line segment will fit to the given data over a subinterval. This approximation is

continuous, but it has a first derivative with discontinuities at the interval ends, the

corners (Scheid 71).

As I have to use at least four numbers of segments, I will have four segments, which are:

f1[X_]:=a1*(X^3)+b1*(X^2)+c1*X+d1;

f2[X_]:=a2*(X^3)+b2*(X^2)+c2*X+d2;

f3[X_]:=a3*(X^3)+b3*(X^2)+c3*X +d3;

f4[X_]:=a4*(X^3)+b4*(X^2)+c4*X+d4;

Together, the spline function and the original function look like the following:

At the above graph, the blue colored curve is p[x] = 1/ (1+x^2), and the red line is the

spline function, which is made of small line segments.

Let the spline function to be f(x). The maximum difference that happens between f(x) and

p(x) is, about, at the following interval: x = -2 to -3 and x = 2 to 3. There are differences

also from x = -1.5 to 0 and to


x = 1.5 to 0, but the maximum differences happens at x = -2 to -3 and x = 2 to 3.

Now, we will evaluate the square of the both functions first derivative, which is:

∑( p(x)-f(x))^2 dx , from x = -3 to 3.

The difference that I get is -0.188088.

By seeing the graph and by see the difference, it can be said that there is much difference,

gap, between the two graphs, the spline one and the original one.

Work Cited

Scheid, Francis. Numerical Analysis. 2nd ed. McGraw: NY,1989

You might also like