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

14 ビュー (過去 30 日間)
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 件のコメント

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);
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
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 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 =
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.

#### 1 件のコメント

Abdelrahman Alaa 2020 年 1 月 8 日