K
Kevin Neilson
Guest
This isn't a question; I'm putting this here as a reference so I can find it in the future. This is how to build a cubic interpolator circuit that takes four samples and interpolates a sample between the middle two.
Given four samples, y0, y1, y2, y3, sampled with period T=1 at (arbitrary) times t={-1,0,1,2}, and given mu, where 0<mu<T, what is the cubic spline interpolation formula to find ymu, the interpolated value of y that corresponds to time t=mu (and lies somewhere between the two middle samples)?
Answer, written in Horner's Method format:
ymu = 1/6*((((-y0+3y1-3y2+y3)mu + (3y0-6y1+3y2))mu + (-2y0-3y1+6y2-y3))mu + 6y1)
Note: 1/6 = binary 0.001010101..., 6x = (x + x<<2)<<2
Abbreviated Derivation:
You are given four samples (t,y) = (-1,y0), (0,y1), (1,y2), (2,y2)
This is the cubic poly that contains those four points:
y = a*t^3 + b*t^2 + c*t + d
When you put the four points into this equations you have four equations in four unknowns. Solving yields
a = 1/6*(-y0+3y1-3y2+y3)
b = 1/6*(3y0-6y1+3y2)
c = 1/6*(-2y0-3y1+6y2-y3)
d = y1
Given four samples, y0, y1, y2, y3, sampled with period T=1 at (arbitrary) times t={-1,0,1,2}, and given mu, where 0<mu<T, what is the cubic spline interpolation formula to find ymu, the interpolated value of y that corresponds to time t=mu (and lies somewhere between the two middle samples)?
Answer, written in Horner's Method format:
ymu = 1/6*((((-y0+3y1-3y2+y3)mu + (3y0-6y1+3y2))mu + (-2y0-3y1+6y2-y3))mu + 6y1)
Note: 1/6 = binary 0.001010101..., 6x = (x + x<<2)<<2
Abbreviated Derivation:
You are given four samples (t,y) = (-1,y0), (0,y1), (1,y2), (2,y2)
This is the cubic poly that contains those four points:
y = a*t^3 + b*t^2 + c*t + d
When you put the four points into this equations you have four equations in four unknowns. Solving yields
a = 1/6*(-y0+3y1-3y2+y3)
b = 1/6*(3y0-6y1+3y2)
c = 1/6*(-2y0-3y1+6y2-y3)
d = y1