# Difference in cubic spline formula

• zzmanzz

## Homework Statement

Hi, this is more of a review question and I'm just looking at solutions of natural cubic spline equations and some will give the cubic spline as:

1. s(x) = a + bx + cx^2 + dx^3

on Wolfram

while other pages will give:

2. s(x) = a + b(x - t) + c(x-t)^2 + d(x-t)^3

where t is the first coordinate in the each point given. I'm not sure which is the standard version and it can make a difference when I evaluate the derivatives so any clarification is appreciated.

As I didn't know the term cubic spline, I looked it up on Wikipedia and found
$$c(t)=(2p_0-2p_1+m_0+m_1)t^3 + (-3p_0+3p_1-2m_0-m_1)t^2+m_0t+p_0=(2t^3-3t^2+1)p_0+(-2t^3+3t^2)p_1+(t^3-2t^2+t)m_0+(t^3-t^2)m_1$$
so the answer seems to be: both, depending on how you would like to interpret and group the coefficients.

It's all how you want to parametrize the spline. The first form may be more convenient for proofs, defining each in terms of the same ##x##. But when you evaluate that, as ##x## gets larger and larger, so do ##x^2## and ##x^3## and you're going to be dealing with small differences between large numbers. It's mathematically correct and gives the right answer theoretically, but might lead to some round-off errors in actually evaluating.

The second form is in terms of the distance ##(x - t)## from the last point. It won't have the problem of numerical stability because ##(x - t)## will never get very large.

In fact I've often used a normalized parameter ##(x - x_i)/(x_{i+1}-x_i)## which ranges from 0 at the beginning of each interval to 1 at the end of the interval. I've found that makes the derivations and resulting equations extremely easy.

Since all of these things are linear in ##x##, if expanded and simplified they should all lead to the same polynomials given the same constraints.