MATLAB Answers

Does the cubic Hermite spline interpolation of a monotone data with known slopes guarantee the monotonicity in interpolation segments?

14 ビュー (過去 30 日間)
Abdelrahman  Alaa
Abdelrahman Alaa 2020 年 1 月 8 日
コメント済み: Abdelrahman Alaa 2020 年 1 月 8 日
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 件のコメント

表示 1 件の古いコメント
Abdelrahman  Alaa
Abdelrahman Alaa 2020 年 1 月 8 日
I tried it on my data and it works fine(gives a monotone interpolation segments), but I want to know if this data changed, Can I use the same approach and gurantee the monotonicity or it depends on the input data (given that the data will always be monotonic) ? I know about pchip but I prefer to use these real slopes (first derivative values).
darova 2020 年 1 月 8 日
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);
dp = diff(p)./diff(t);
ds = diff(s)./diff(t);
legend('derivative hermitte',...
'derivative spline')
DOesn't look like hermite interpolation has monotonical transition between knots
Abdelrahman  Alaa
Abdelrahman Alaa 2020 年 1 月 8 日
I think that you get confused because of the term "spline" in the question, I mean that I use the known values and first derivative values and interpolate them using the attached formula. It is different from function "spline" in MATALB which determines the slopes at knots to make the second derivative continuous.

サインイン to comment.

回答 (1 件)

John D'Errico
John D'Errico 2020 年 1 月 8 日
編集済み: John D'Errico 2020 年 1 月 8 日
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 =
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.
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.

  1 件のコメント

Abdelrahman  Alaa
Abdelrahman Alaa 2020 年 1 月 8 日
Thanks John for your answer.
I am very convinced that if I provide the derivatives, the function can be non-monotonic even if the data is monotonic. And also I was thinking of that case where the function can introduce both minimum and maximum so both derivatives still have the same sign as you referred in your answer. Also I read Fritsch, F. N. and R. E. Carlson paper "Monotone Piecewise Cubic Interpolation." and know the conditions needed for the monotonicity.
But I tried to interpolate some data on real application (Mosfet ID vs VGS if you are familiar) and get surprised that the direct cubic Hermite approach gives a monotone functions even with big data (around milion points and all generated functions are monotone). So I was thinking that if the data has some characteristics I don't need to worry about monotonicity(Don't need to check monotonicity for each interval). But I can't figure out what these characteristics can be?!
Also I was wondering if the case is that we know the data values and also the derivative values, and let's assume that the data always increases and the derivatives are positive values, and we use the cubic hermite approach and found that the generated function between any two points is not monotone. Isn't that mean that cubic interpolation is not the best method to interpolate on this interval? So we can try another method instead of change our first derivative values to satisfy the monotoniciy?
Could you help me figure out answers for these questions?
Thanks again.

サインイン to comment.

サインイン してこの質問に回答します。

Translated by