reset();

x := [0, 1, 2, 3, 4];
y := map(x,x->f(x));

[0, 1, 2, 3, 4]
[f(0), f(1), f(2), f(3), f(4)]

S1:=numeric::cubicSpline(x,y,Natural,Symbolic);

`proc S1(z) ... end`

S1(t,0);

f(0) - t*(((17*f(1))/28 - (15*f(0))/56 - (3*f(2))/7 + (3*f(3))/28 - f(4)/56)*t^2 + (71*f(0))/56 - (45*f(1))/28 + (3*f(2))/7 - (3*f(3))/28 + f(4)/56)

S2:=numeric::cubicSpline(x,y,Complete=[f'(0),f'(4)],Symbolic);

`proc S2(z) ... end`

S2(t,0);

f(0) + t*(D(f)(0) - t*((123*f(0))/56 - (39*f(1))/14 + (3*f(2))/4 - (3*f(3))/14 + (3*f(4))/56 + (97*D(f)(0))/56 - D(f)(4)/56 - t*((41*D(f)(0))/56 + (67*f(0))/56 - D(f)(4)/56 + (3*f(4))/56 - (25*f(1))/14 + (3*f(2))/4 - (3*f(3))/14)))

S3:=numeric::cubicSpline(x,y,NotAKnot,Symbolic);

`proc S3(z) ... end`

S3(t,0);

f(0) - t*((23*f(0))/12 - (10*f(1))/3 + 2*f(2) - (2*f(3))/3 + f(4)/12 - t*((9*f(0))/8 - 3*f(1) + (11*f(2))/4 - f(3) + f(4)/8 - t*((5*f(0))/24 - (2*f(1))/3 + (3*f(2))/4 - f(3)/3 + f(4)/24)))

S4:=numeric::cubicSpline([op(x),x[1]],[op(y),y[1]],Periodic,Symbolic);

`proc S4(z) ... end`

S4(t,0);

f(0) - t*((5*f(0))/3 - (7*f(1))/3 + f(2)/2 + f(3)/3 - f(4)/6 - t*((11*f(0))/16 - (5*f(1))/4 + f(2)/8 + (3*f(3))/4 - (5*f(4))/16 - t*(f(0)/48 + f(1)/12 - (3*f(2))/8 + (5*f(3))/12 - (7*f(4))/48)))

 

f:=x->(x+1)/(x^2+1);

x -> (x + 1)/(x^2 + 1)

plot(
 
plot::Function2d(S1(t), t=0..4, Color = RGB::Black,Legend="Natural"),
  plot::Function2d(S2(t), t=0..4, Color = RGB::Red,Legend="Complete"),
  plot::Function2d(S3(t), t=0..4, Color = RGB::Blue,Legend="Not a Knot"),
  plot::Function2d(S4(t), t=0..4, Color = RGB::Orange,Legend="periodic"),
  plot::Function2d(f(t), t=0..4, Color = RGB::Green,Legend="f")
);

MuPAD graphics