Talk:Monotone cubic interpolation

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Clarification request[edit]

In the formula : finterpolated(x) = ylowerh00(t) + hmlowerh10(t) + yupperh01(t) + hmupperh11(t) is ylower < yupper or is the ylower the y value correspond to the xlower and vis-versa?

Also is it possible to impose the condition and (2nd derivative at the first point and the last point equal to zero)as in natural cubic spline. In the current state beond the end points the curve goes hay way. Tapas ks (talk) 10:10, 10 January 2009 (UTC)[reply]



i want a f(x,y) that can cover a square of 1*1 sizs? 77.237.172.1 (talk) 20:35, 10 February 2008 (UTC)[reply]

Look at Multivariate interpolation. --Berland (talk) 07:20, 22 February 2008 (UTC)[reply]

Correctness of step 5[edit]

I reverted this edit, because it contradicts the referenced paper by Fritsch and Carlson, and because the claims put forward by the edit were unreferenced. The introduced comment may be correct, but if so it has to be referenced. --Berland (talk) 13:58, 20 February 2008 (UTC)[reply]

Re: Correctness of step 5[edit]

The Step 5, as it was originally put down, was misinterpreted. The original article by Fritsch & Carlson (1980) states the following Step 2A: find such subset of set of all feasible parameters , which is defined by the conditions in Step 5, such that for any and , , we have . To preserve monotonicity of the previous interval, while updating values in the current interval, we need to check that set , in our case defined by , satisfies this condition. Note that we need to check conditions of this subset in Step 5, as well as normalizing the when they fall outside of it. The original Wiki article showed inconsistent application of this argument.76.194.82.134 (talk) 01:57, 22 February 2008 (UTC)[reply]

Glad you cared to elaborate here. By rereading the paper, I see your point, and as far as I can see, in order for the wiki article to be correct in terms of the article, we should replace step 5 by:
5. Now, if , then set and where .
--Berland (talk) 07:17, 22 February 2008 (UTC)[reply]
Thanks, Berland. Just corrected the article.159.53.110.143 (talk) 15:43, 22 February 2008 (UTC)[reply]

Higham 1992 suggests a possibly better alternative[edit]

Higham, D. J. (1992) Monotonic piecewise cubic interpolation, with applications to ODE plotting. Journal of Computational and Applied Mathematics, 39 (3). pp. 287-294. ISSN 0377-0427

They point out that if you *know* your derivatives and data at every point, there is a better way to ensure monotonicity than forcing the interpolant to have the wrong derivative at a data point: they introduce extra knots.

Might be worth mentioning. — Preceding unsigned comment added by 132.206.92.211 (talk) 02:58, 19 April 2008 (UTC)[reply]

Step 4[edit]

In step 4 it says

In such cases, piecewise monotone curves can still be generated by choosing , although global strict monotonicity is not possible.

I implemented this algorithm, and it gives much better results, if I only set . I don't have access to the paper, so I can't check, but it doesn't seem reasonable to set the m of any other than the actual local minimum/maximum to zero.

Tdieb (talk) 15:22, 20 June 2012 (UTC)[reply]

Be careful with step 3[edit]

Step 3 says

For k=1,\dots,n-1, if \Delta_k = 0 (if two successive y_k=y_{k+1} are equal), then set m_k = m_{k+1} = 0, as the spline connecting these points must be flat to preserve monotonicity. Ignore step 4 and 5 for those k.

However, comparison of real (floating point) numbers for equality makes no sense with applied algorithm, and makes little sense with mathematics if the equality is not proved. I would suggest some wording suggesting the idea instead of this wording saying it is computed exactly like this. --Hibou57 (talk) 20:45, 27 June 2013 (UTC)[reply]

JavaScript Implementation[edit]

The sample JavaScript implementation would be much more readable and portable if it used array indices for assignment instead of 'push'. For example, instead of writing "dxs.push(dx)" use "dxs[i] = dx". — Preceding unsigned comment added by 109.145.139.99 (talk) 10:20, 31 October 2013 (UTC)[reply]

I went ahead and did this for all but one of them. There's 1 case where an array element is assigned to outside of an initializer loop where I felt it would be more immediately readable to leave the .push as is than to use "c1s[c1s.length] = ms[ms.length - 1]);", at least to me. Jmortiger (talk) 17:37, 25 January 2023 (UTC)[reply]

JavaScript Implementation is not Fritsch-Carlson method[edit]

The sample JavaScript implementation is a useful resource for monotone cubic interpolation, and it is appropriate to include it in this article, but it does not implement the Fritsch-Carlson method as claimed: "The following JavaScript implementation takes a data set and produces a Fritsch-Carlson cubic spline interpolant function". The usage example (extended by one point) produces this output:

0 squared is about 0
0.5 squared is about 0.4375
1 squared is about 1
1.5 squared is about 2.21875
2 squared is about 4
2.5 squared is about 6.239583333333333
3 squared is about 9
3.5 squared is about 12.354166666666666
4 squared is about 16

The Fritsch-Carlson method (which in this case is a no-op as the constraints are always satisfied) produces this output:

0 squared is about 0
0.5 squared is about 0.375
1 squared is about 1
1.5 squared is about 2.25
2 squared is about 4
2.5 squared is about 6.25
3 squared is about 9
3.5 squared is about 12.375
4 squared is about 16

Note in particular that for x=1.5 and x=2.5 the interpolant is exact, which is not true of the Javascript implementation.

I suggest that the article be edited to change the quoted line to: "The following JavaScript implementation takes a data set and produces a monotone cubic spline interpolant function"

Tuello (talk) 14:08, 15 August 2014 (UTC)[reply]

Redundant Step in Checking for Local Extrema[edit]

In my eyes, step 4 is currently redundant: From step 2: " and have different sign, set ."

In step 4, we check wether or are less then zero. Therefore:

For , the result is

Therefore, this step also just checks wether and have different sign; since if they do, either or will be less than (and the other one will be bigger).

One of these steps is therefore redundant; I would suggest removing the check in step 4; since if so, or won't be used twice, but only for enforcing monotonicity.

--MariusLambacher (talk) 15:29, 17 June 2017 (UTC)[reply]