SPLINES - TEST PREPARATION NOTES
1. KEY CONCEPTS
Introduction
• Problem: Large oscillations in interpolating polynomials between nodes
• Solution: Use piecewise polynomials (splines) between consecutive nodes
• Splines generate function/data values only at the nodes
Splines Definition
• Given nodes (xₖ, yₖ) for k = 1,2,...,n
• Spline S(x) consists of polynomials S₁(x), S₂(x),...,Sₙ₋₁(x)
• Key property: S(xₖ) = yₖ for k = 1,2,...,n
2. LINEAR SPLINES
Mathematical Form
Properties
1. Generates data at nodes: Sₖ(xₖ) = yₖ, k = 1,2,...,n-1, Sₙ₋₁(xₙ) = yₙ
2. Continuous at interior nodes: Sₖ(xₖ₊₁) = Sₖ₊₁(xₖ₊₁), k = 1,2,...,n-2
Basic Structure for Linear Spline Implementation
Example from Exercise 1:
Plotting Splines:
Step-by-Step Method:
1. Set up data matrix: D = [x_values; y_values]
2. Calculate slopes for each segment:
• For segment k: slope = (yₖ₊₁ - yₖ)/(xₖ₊₁ - xₖ)
3. Define spline functions:
1. Ensure continuity: Check that Sₖ(xₖ₊₁) = Sₖ₊₁(xₖ₊₁)
2. Evaluate at required points using appropriate spline segment
Key MATLAB Commands:
• clear - Clear workspace
• format long - Set number display format
• @(x) - Anonymous function syntax
• fplot(function, [x_range]) - Plot function over range
• plot(x,y,'o') - Plot points with circles
• hold on/off - Control plot overlay
Linear Spline Segments:
Coefficient Calculation:
• aₖ = yₖ (y-value at node k)
• bₖ = (yₖ₊₁ - yₖ)/(xₖ₊₁ - xₖ) (slope of segment k)