Akima spline

In applied mathematics, an Akima spline is a type of non-smoothing spline that gives good fits to curves where the second derivative is rapidly varying. The Akima spline was published by Hiroshi Akima in 1970 from Akima's pursuit of a cubic spline curve that would appear more natural and smooth, akin to an intuitively hand-drawn curve. The Akima spline has become the algorithm of choice for several computer graphics applications. Its advantage over the cubic spline curve is its stability with respect to outliers.

Method
Given a set of "knot" points $$(x_i, y_i)_{i=1\dots n}$$, where the $$x_i$$ are strictly increasing, the Akima spline will go through each of the given points. At those points, its slope, $$s_i$$, is a function of the locations of the points $$(x_{i-2}, y_{i-2})$$ through $$(x_{i+2}, y_{i+2})$$. Specifically, if we define $$m_i$$ as the slope of the line segment from $$(x_i, y_i)$$ to $$(x_{i+1},y_{i+1})$$, namely
 * $$m_i=\frac{y_{i+1} - y_i}{x_{i+1}-x_i} \,,$$

then the spline slopes $$s_i$$ are defined as the following weighted average of $$m_{i-1}$$ and $$m_i$$,


 * $$s_i = \frac{|m_{i+1} - m_i|m_{i-1} + |m_{i-1} - m_{i-2}|m_i}{|m_{i+1} - m_i| + |m_{i-1} - m_{i-2}|} \,.$$

If the denominator equals zero, the slope is given as


 * $$s_i=\frac{m_{i-1}+m_{i}}{2}\,.$$

The first two and the last two points need a special prescription, for example,


 * $$s_1=m_1 \,, s_2=\frac{m_{1}+m_{2}}{2} \,, s_{n-1}=\frac{m_{n-2}+m_{n-1}}{2} \,, s_n=m_{n-1} \,.$$

The spline is then defined as the piecewise cubic function whose value between $$x_i$$ and $$x_{i+1}$$ is the unique cubic polynomial $$P_i(x)$$,


 * $$P_i(x)=a_i+b_i(x-x_i)+c_i(x-x_i)^2+d_i(x-x_i)^3 \,,$$

where the coefficients of the polynomial are chosen such that the four conditions of continuity of the spline together with its first derivative are satisfied,


 * $$P(x_i) = y_i \,, P(x_{i+1}) = y_{i+1} \,,  P'(x_i) = s_i \,,  P'(x_{i+1}) = s_{i+1} \,.$$

which gives


 * $$a_i=y_i \,,$$
 * $$b_i=s_i \,,$$
 * $$c_i=\frac{3m_i-2s_i-s_{i+1}}{x_{i+1}-x_i} \,,$$
 * $$d_i=\frac{s_i+s_{i+1}-2m_i}{(x_{i+1}-x_i)^2} \,.$$

Due to these conditions the Akima spline is a C1 differentiable function, that is, the function itself is continuous and the first derivative is also continuous. However, in general, the second derivative is not necessarily continuous.

An advantage of the Akima spline is due to the fact that it uses only values from neighboring knot points in the construction of the coefficients of the interpolation polynomial between any two knot points. This means that there is no large system of equations to solve and the Akima spline avoids unphysical wiggles in regions where the second derivative in the underlying curve is rapidly changing. A possible disadvantage of the Akima spline is that it has a discontinuous second derivative.