Does the cubic Hermite spline interpolation of a monotone data with known slopes guarantee the monotonicity in interpolation segments?
8 views (last 30 days)
Show older comments
I am trying to interpolate monotone data with known data values and also known first derivative values at knots. If I use these first derivative values directly with cubic Hermite spline interpolation (like the attached photo), Can I gurantee the monotonicity of the interpolation segments?
4 Comments
darova
on 8 Jan 2020
I tried this:
x = -3:3;
y = [-1 -1 -1 0 1 1 1];
t = linspace(-3,3);
p = pchip(x,y,t);
s = spline(x,y,t);
plot(x,y,'o',t,p,'-',t,s,'-.')
legend('data','pchip','spline',4)
figure
dp = diff(p)./diff(t);
ds = diff(s)./diff(t);
plot(t(2:end),dp,'-g',t(2:end),ds,'-.r')
legend('derivative hermitte',...
'derivative spline')
DOesn't look like hermite interpolation has monotonical transition between knots
Answers (1)
John D'Errico
on 8 Jan 2020
Edited: John D'Errico
on 8 Jan 2020
pchip always gaurantees a monotonic interpolant if the data is itself monotone. However...
If you provide the derivatives yourself, this does NOT assure you of a monotonic interpolant. In fact, I can trivially generate a counter-example of a C1 cubic Hermite interpolant (technically not a true spline, but many people tend to think of it as one), where the data is monotone increasing, and the derivatives are always positvive, yet the function itself is not monotone increasing.
For example, consider this function plot, of a C1 cubic Hermite interpolant.
At every data point, a derivative was supplied, chosen carefully such that the derivatives at the points were STRICTLY positive. If you don't believe me, here they are:
slopes =
1.9825
2.035
1.8774
2.4553
0.30124
8.3397
8.3399
0.30064
2.4575
1.8693
2.0654
Yet you can see that the function itself is not monotonic between the data. If that does not convince you, then consider this more extreme version, with the same strictly monotone increasing data points and a more significantly modified but always positive set of derivatives at the data points.
(Yes, I know that this last curve almost seems to have a negative derivative at some of the data points. The slopes are not negative at the breaks, I can assure you.)
So the answer is a absolute one. Providing your own derivatives is not sufficient to insure monotonicity. In fact, it is even not that difficult for such a failure to occur, even if your derivatives are not cooked up as I have done.
Edit:
As an addendum, I would point out that it would be possible to construct a variation of pchip that would accept your own list of derivatives, then leave all alone unless they would consitute a deviation from monotonicity. You would just find a minimal perturbation of the derivative set such that the result is not fully monotonic. I can think of several ways to achieve that (though I do not write code on spec.) It would not be too difficult though.
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!