Home > Numerical methods calculators > Cubic spline interpolation example

Cubic spline interpolation example ( Enter your problem )
  1. Formula
  2. Example-1 (Fit 4 points)
  3. Example-2 (Fit 4 points)
  4. Example-3 (Fit 3 points)
  5. Example-4 (Fit 3 points)
  6. Example-5 (Fit 5 points)
  7. Example-6 (Fit 5 points)

3. Example-2 (Fit 4 points)
(Previous example)
5. Example-4 (Fit 3 points)
(Next example)

4. Example-3 (Fit 3 points)





1. Calculate Cubic Splines
X012
Y-5-43
y(0.5)


Solution:
x012
y-5-43

Cubic spline formula is
f(x)=(x_i-x)^3/(6h) M_(i-1) + (x-x_(i-1))^3/(6h) M_i + ((x_i-x))/h (y_(i-1)-h^2/6 M_(i-1)) + ((x-x_(i-1)))/h (y_i-h^2/6 M_i) ->(1)

We have, M_(i-1)+4M_(i)+M_(i+1)=6/h^2(y_(i-1)-2y_(i)+y_(i+1))->(2)

Here h=1,n=2

M_0=0,M_2=0

Substitute i=1 in equation (2)

M_0+4M_1+M_2=6/h^2(y_0-2y_1+y_2)

=>0+4M_1+0=6/1*(-5-2*-4+3)

=>4M_1=36

=>M_1=9

Substitute i=1 in equation (1), we get cubic spline in 1^(st) interval [x_0,x_1]=[0,1]

f_1(x)=(x_1-x)^3/(6h) M_0 + (x-x_0)^3/(6h) M_1 + ((x_1-x))/h (y_0-h^2/6 M_0)+((x-x_0))/h (y_1-h^2/6 M_1)

f_1(x)=(1-x)^3/6 *0 + (x-0)^3/6 *9 + ((1-x))/1 (-5-1/6 *0) + ((x-0))/1 (-4-1/6 *9)

f_1(x)=1/2(3x^3-x-10), for 0<=x<=1



Substitute i=2 in equation (1), we get cubic spline in 2^(nd) interval [x_1,x_2]=[1,2]

f_2(x)=(x_2-x)^3/(6h) M_1 + (x-x_1)^3/(6h) M_2 + ((x_2-x))/h (y_1-h^2/6 M_1)+((x-x_1))/h (y_2-h^2/6 M_2)

f_2(x)=(2-x)^3/6 *9 + (x-1)^3/6 *0 + ((2-x))/1 (-4-1/6 *9) + ((x-1))/1 (3-1/6 *0)

f_2(x)=1/2(-3x^3+18x^2-19x-4), for 1<=x<=2



For y(0.5), 0.5 in [0,1], so substitute x=0.5 in f_1(x), we get

f_1(0.5)=-5.0625


This material is intended as a summary. Use your textbook for detail explanation.
Any bug, improvement, feedback then Submit Here



3. Example-2 (Fit 4 points)
(Previous example)
5. Example-4 (Fit 3 points)
(Next example)





Share this solution or page with your friends.
 
 
Copyright © 2025. All rights reserved. Terms, Privacy
 
 

.