Monotone interpolation can be accomplished using cubic Hermite spline with the tangents m i {\displaystyle m_{i}} modified to ensure the monotonicity of the resulting Hermite spline.
An algorithm is also available for monotone quintic Hermite interpolation.
There are several ways of selecting interpolating tangents for each data point. This section will outline the use of the Fritsch–Carlson method. Note that only one pass of the algorithm is required.
Let the data points be ( x k , y k ) {\displaystyle (x_{k},y_{k})} indexed in sorted order for k = 1 , … n {\displaystyle k=1,\,\dots \,n} .
δ k = y k + 1 − y k x k + 1 − x k {\displaystyle \delta _{k}={\frac {y_{k+1}-y_{k}}{x_{k+1}-x_{k}}}}
m k = δ k − 1 + δ k 2 {\displaystyle m_{k}={\frac {\delta _{k-1}+\delta _{k}}{2}}}
m 1 = δ 1 and m n = δ n − 1 {\displaystyle m_{1}=\delta _{1}\quad {\text{ and }}\quad m_{n}=\delta _{n-1}\,} .
α k = m k / δ k and β k = m k + 1 / δ k {\displaystyle \alpha _{k}=m_{k}/\delta _{k}\quad {\text{ and }}\quad \beta _{k}=m_{k+1}/\delta _{k}} .
ϕ k = α k − ( 2 α k + β k − 3 ) 2 3 ( α k + β k − 2 ) > 0 {\displaystyle \phi _{k}=\alpha _{k}-{\frac {(2\alpha _{k}+\beta _{k}-3)^{2}}{3(\alpha _{k}+\beta _{k}-2)}}>0\,} , or
τ k = 3 α k 2 + β k 2 {\displaystyle \tau _{k}={\frac {3}{\sqrt {\alpha _{k}^{2}+\beta _{k}^{2}}}}\,} ,
m k = τ k α k δ k and m k + 1 = τ k β k δ k {\displaystyle m_{k}=\tau _{k}\,\alpha _{k}\,\delta _{k}\quad {\text{ and }}\quad m_{k+1}=\tau _{k}\,\beta _{k}\,\delta _{k}\,} .
After the preprocessing above, evaluation of the interpolated spline is equivalent to a cubic Hermite spline, using the data x k {\displaystyle x_{k}} , y k {\displaystyle y_{k}} , and m k {\displaystyle m_{k}} for k = 1 , … n {\displaystyle k=1,\,\dots \,n} .
To evaluate at x {\displaystyle x} , find the index k {\displaystyle k} in the sequence where x {\displaystyle x} , lies between x k {\displaystyle x_{k}} , and x k + 1 {\displaystyle x_{k+1}} , that is: x k ≤ x ≤ x k + 1 {\displaystyle x_{k}\leq x\leq x_{k+1}} . Calculate
then the interpolated value is
where h i i {\displaystyle h_{ii}} are the basis functions for the cubic Hermite spline.
The following JavaScript implementation takes a data set and produces a monotone cubic spline interpolant function: