Consulting: Spline Roots

A need exists for determining a solution to the following cubic spline \(\) $$f(x)=a_{i}\left(x-x_{i}\right)^{3}+b_{i}\left(x-x_{i}\right)^{3}+c_{i}\left(x-x_{i}\right)^{3}+d_{i}=V$$

The full consulting report is available at SplineRoots

Part I: Analytical Methods

One-step analytical solutions exist for a cubic polynomial (See http://mathworld.wolfram.com/CubicFormula.html). The history behind this solution is quite interesting and only a few hundred years old. Given an arbitrary cubic polynomial, $$f(x)=a_{i}\left(x-x_{i}\right)^{3}+b_{i}\left(x-x_{i}\right)^{3}+c_{i}\left(x-x_{i}\right)^{3}+d_{i}$$
the polynomial is non-dimensionalized by \[a_{i}\]
to give $$F(x)=\left(x-x_{i}\right)^{3}+a_{2}\left(x-x_{i}\right)^{3}+a_{1}\left(x-x_{i}\right)^{3}+a_{0}$$
Three intermediate terms are calculated $$Q=\frac{3a_{1}-a_{2}^{2}}{9}$$
$$R=\frac{9a_{2}a_{1}-27a_{0}-2a_{2}^{3}}{54}$$
$$\theta=\arccos\left(\frac{R}{\sqrt{-Q^{3}}}\right)$$
The real solutions are $$z_{1}=2\sqrt{-Q}\,\cos\left(\frac{\theta}{3}\right)-\frac{a_{2}}{3}$$
$$z_{2}=2\sqrt{-Q}\,\cos\left(\frac{\theta+2\pi}{3}\right)-\frac{a_{2}}{3}$$
$$z_{3}=2\sqrt{-Q}\,\cos\left(\frac{\theta+4\pi}{3}\right)-\frac{a_{2}}{3}$$
The roots are selected from the z
value calculated above $$x=\left\{ z_{1},z_{2},z_{3}\right\} $$

There are several issues associated with this method.
• Out of Range: Intermediate terms may not be real if the search value is outside the range of possible function values f(x)
• Picking the correct solution: multiple solutions may exist, you must ensure the calculated x  lies in the correct domain.

Part II: Numerical Methods

• Suggested to avoid Newton-Raphson iterative root finding since division by a near zero derivative causes problems. N-R is however excellent for polishing a root after a prior routine gets “close”.

• Simple bisection would likely be the most robust especially if a human can identify a known upper and lower bound.

Bisection Method

See the attached pdf (SplineRoots) for an explanation and examples of bisection root finding.

Newton-Raphson Root Finding

The definition of N-R for a given function f  and desired value V
is $$x_{new}=x_{old}-\frac{f(x_{old})-V}{f^{\prime}(x_{old})}$$
where$$\hat{x}=x-x_{i}$$
$$ f(x)=a_{i}\hat{x}^{3}+b_{i}\hat{x}^{2}+c_{i}\hat{x}+d_{i}
f^{\prime}(x)=3a_{i}\hat{x}^{2}+2b_{i}\hat{x}+c_{i}$$
See the attached pdf (SplineRoots) for an explanation and examples of NR root finding.