Cubic Hermitian interpolation

The cubic Hermitian interpolation algorithm uses a cubic polynomial to interpolate between 2 points with given slope at both points. In case the slope at each point is given, this algorithm can interpolate a smooth shape between random numbers of supporting points without big tendency to oscillate. That can be quite useful in some cases.

In some descriptions they are talking about a Lagrange function in relation to this interpolation algorithm. I wonder where they found that. At least for the cubic version I cannot see any reference to a Lagrange function here :-)


If the cubic function for the interpolation is


Hermite

The derivation of this is:


Hermite


With two simple points: One at x = 0 and the other one at x = 1, we get:


Hermite


and


Hermite


And with the given function values y1 and y2 and the slopes p1 and p2



Hermite


and



Hermite


And with these inserted in the upper formulations


Hermite


or a bit reformed


Hermite


This matrix equation for c2 and c3 can be resolved for c2:


Hermite


And with this inserted in the upper equation again:



Hermite


And with



Hermite


We get for the entire function



HermiteHermite



Or sorted for y1 and y2 and the slopes p1 and p2


HermiteHermite



or


HermiteHermite



That’s how it is usually written :-)

With two supporting points (0;1) and (1;1.05) and p1= -0.1 and p2=0.12 that would look like:


Hermite




An interesting view is the comparison of the weight of each value in this graph:


Hermite


Now, if there is an interval not from 0 to 1 but from a to b, x just has to be substituted by


Hermite



That’s all. And there is nothing of a Lagrange function in it :-)



The demo project consists of one window:


Hermite



I entered 6 supporting points (x_k, y_k) with their slope p_k. These values can be edited and the recalculation of the interpolated shape shows immediately the effect.

The algorithm is quite simple but in my opinion it has one big disadvantage: You have to know the slopes in each supporting point and this is not always given :-)


C# Demo Project Hermitian interpolation
  • Hermite.zip