Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cubic Spline Interpolation. Cubic Splines attempt to solve the problem of the smoothness of a graph as well as reduce error. Polynomial interpolation.

Similar presentations


Presentation on theme: "Cubic Spline Interpolation. Cubic Splines attempt to solve the problem of the smoothness of a graph as well as reduce error. Polynomial interpolation."— Presentation transcript:

1 Cubic Spline Interpolation

2 Cubic Splines attempt to solve the problem of the smoothness of a graph as well as reduce error. Polynomial interpolation uses a single polynomial to meet all data points, while splines use several low degree polynomials. Cubic splines consist of polynomials of degree 3. Cubic splines add curvature to an interpolation that would otherwise be only line segments.

3 Base points for cubic splines are called knots. Every sections of a spline begins and ends with a knot. A natural cubic spline also fulfills the conditions: S’’ 1 (x 1 ) = 0 and S’’ n-1 (x n ) = 0. In other words, both endpoints 2 nd derivative must be 0.

4 Splines are made up of the equations: – S 1 (x) = y 1 + b 1 (x - x 1 ) + c 1 (x - x 1 ) ^2 + d 1 (x - x 1 ) ^3 – S 2 (x) = y 2 + b 2 (x - x 2 ) + c 2 (x - x 2 ) ^2 + d 2 (x - x 2 ) ^3 – … – S n-1 (x) = y n-1 + b n-1 (x - x n-1 ) + c n-1 (x – x n-1 ) ^2 + dn-1(x – x n- 1 )^3 With the following properties: S i (x i ) = y i and S i (x i+1 ) = y i+1 for i = 1,…,n - 1 – Guarantees that the spline interpolates the data points S’ i-1 (x i ) = S’ i (x i ) for i = 2,…,n - 1 – Forces the slopes of the parts of the spline to meet S’’ i-1 (x i ) = S’’ i (x i ) for i = 2,…,n - 1 – Forces the curvature to agree

5 So what we are looking to solve are the coefficients of the cubic spline, a,b,c,d. To solve for these, we use the formula: – S i (x) = y i + b i (x – x i ) + c i (x – x i ) ^2 + d i (x – x i ) ^3 for n – 1 equations, where n = number of points. The following finds the coefficients for the equation: – a i = y i – δ i = x i+1 - x i – Δ i = y i+1 - y i – d i = (c i+1 – c i ) / 3δ i – b i = Δ i / δ i - δ i / 3 (2c i + c i+1 )

6 To find c, we need to first make an nxn matrix with n solutions of c. We also need to make a vector of c values as well as a vector that they equal to. The first and last rows are always of this form. Remember: δ i = x i+1 - x i

7 C1C1 C2C2 C3C3 … CnCn This is our vector of c values. 0 3(Δ 2 / δ 2 – Δ 1 / δ 1 ) … 3(Δ n-1 / δ n-1 – Δ n-2 / δ n-2 0 This is the vector that they are set equal to. The first and last rows are always 0. To solve c, we multiply the inverse of the matrix that we created with the vector that we created. 100…… δ1δ1 2δ 1 + 2δ 2 δ2δ2 0… 0δ2δ2 2δ 2 + 2δ 3 δ3δ3 … 00……… …0001 C1C1 C2C2 C3C3 … CnCn 0 3(Δ 2 / δ 2 – Δ 1 / δ 1 ) … 3(Δ n-1 / δ n-1 – Δ n-2 / δ n-2 0 =

8 When multiplied together we get a vector of c values. We now plug in the c values to solve for the b and d values. – d i = (c i+1 – c i ) / 3δ i – b i = Δ i / δ i - δ i / 3 (2c i + c i+1 ) 100…… δ1δ1 2δ 1 + 2δ 2 δ2δ2 0… 0δ2δ2 2δ 2 + 2δ 3 δ3δ3 … 00……… …0001 C1C1 C2C2 C3C3 … CnCn 0 3(Δ 2 / δ 2 – Δ 1 / δ 1 ) … 3(Δ n-1 / δ n-1 – Δ n-2 / δ n-2 0 =

9 We now plug in all of our values into our equation to find the n-1 equations for our cubic spline. S 1 (x) = y 1 + b 1 (x - x 1 ) + c 1 (x - x 1 ) ^2 + d 1 (x - x 1 ) ^3 S 2 (x) = y 2 + b 2 (x - x 2 ) + c 2 (x - x 2 ) ^2 + d 2 (x - x 2 ) ^3 … S n-1 (x) = y n-1 + b n-1 (x - x n-1 ) + c n-1 (x – x n-1 ) ^2 + dn-1(x – x n-1 ) ^3

10 Advantages: Algorithm is much quicker and more accurate than other spline algorithms of lesser degrees. Easy to create and produces a seemingly seamless curve. Disadvantages Applications sensitive to the smoothness of derivatives higher than second degree may give an undesired result

11 References http://www.physics.utah.edu/~detar/phys672 0/handouts/cubic_spline/cubic_spline/node1. html


Download ppt "Cubic Spline Interpolation. Cubic Splines attempt to solve the problem of the smoothness of a graph as well as reduce error. Polynomial interpolation."

Similar presentations


Ads by Google