0% found this document useful (0 votes)
52 views14 pages

Piecewise Linear Interpolation: - Simple Idea

The document discusses piecewise linear interpolation, which connects data points with straight lines. It defines the local variable s as x - xk, and the first divided difference as (yk+1 – yk)/(xk+1 –xk). The interpolant is given by L(x) = yk + (x – xk) (yk+1 – yk)/(xk+1 –xk), which is a linear function passing through the points (xk, yk) and (xk+1, yk+1). It also discusses piecewise cubic interpolation, which fits cubic polynomials between points, requiring two derivatives to be specified or enforced. Cubic splines impose continuity conditions to solve for the derivatives without explicitly
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views14 pages

Piecewise Linear Interpolation: - Simple Idea

The document discusses piecewise linear interpolation, which connects data points with straight lines. It defines the local variable s as x - xk, and the first divided difference as (yk+1 – yk)/(xk+1 –xk). The interpolant is given by L(x) = yk + (x – xk) (yk+1 – yk)/(xk+1 –xk), which is a linear function passing through the points (xk, yk) and (xk+1, yk+1). It also discusses piecewise cubic interpolation, which fits cubic polynomials between points, requiring two derivatives to be specified or enforced. Cubic splines impose continuity conditions to solve for the derivatives without explicitly
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Piecewise linear interpolation

• Simple idea
– Connect straight lines between data points
– Any intermediate value read off from straight line
• The local variable, s, is
• s = x - xk
• The first divided difference is
• δk = (yk+1 – yk)/(xk+1 –xk)
• With these quantities in hand, the interpolant is
• L(x) = yk + (x – xk) (yk+1 – yk)/(xk+1 –xk)
• = yk + sδk
• Linear function that passes through (xk, yk) and (xk+1, yk+1)
Piecewise linear interpolation
• Same format as all function v = piecelin(x,y,u)
other interpolants %PIECELIN Piecewise linear interpolation.
% v = piecelin(x,y,u) finds piecewise linear L(x)
• Function diff finds % with L(x(j)) = y(j) and returns v(k) = L(u(k)).
% First divided difference
difference of delta = diff(y)./diff(x);
elements in a vector % Find subinterval indices k so that x(k) <= u <
x(k+1)
• Find appropriate n = length(x);
k = ones(size(u));
sub-interval for j = 2:n-1
k(x(j) <= u) = j;
• Evaluate end
• Jargon: x is called a % Evaluate interpolant
s = u - x(k);
“knot” for the linear v = y(k) + s.*delta(k);
spline interpolant
• So we can reduce error by choosing small intervals where
2nd derivative is higher
– If we can choose where to sample data
– Do more where the “action” is more
Piecewise Cubic interpolation
• While we expect function not to vary, we expect it to also
be smooth
• So we could consider piecewise interpolants of higher
degree
• How many pieces of information do we need to fit a
cubic between two points?
– y=a+bx+cx2+dx3
– 4 coefficients
– Need 4 pieces of information
– 2 values at end points
– Need 2 more pieces of information
– Derivatives?
• However for Hermite, the derivative needs to be specified
• Cubic splines, the derivative is not specified but enforced
Cubic splines
Imposing the continuity conditions
Using function continuity
First Derivative continuity
Second derivative continuity
Solving for m

• n-2 equations in n unknowns


• Need to add two conditions
• Usually at end points
Solving a cubic spline system
• Assume natural splines

• This is a tridiagonal system


• Can be solved in O(n) operations
• How?
– Do LU and solve
– With tridiagonal structure requires O(7n) operations
Interpolation: wrap up
• Interpolation: Given a function at N points, find its value at
other point(s)
• Polynomial interpolation
– Monomial, Newton and Lagrange forms
• Piecewise polynomial interpolation
– Linear, Hermite cubic and Cubic Splines
• Polynomial interpolation is good at low orders
• However, higher order polynomials “overfit” the data and
do not predict the curve well in between interpolation
points
• Cubic Splines are quite good in smoothly interpolating data

You might also like