The derivation of the cubic spline interpolation (from this MIT OCW lecture, page 13) starts off with second derivatives, which are piecewise linear functions. It's written in the form

$$ s''(x) = \frac{x_j - x}{h_j}\sigma_{j-1} + \frac{x - x_{j-1}}{h_j}\sigma_{j}, h = x_j - x_{j-1}, \sigma_{j} = s''(x_j) $$

which is confusing to me, because I think of it as

\begin{align*} s''(x) = f(x) &= \frac{f_{j} - f_{j-1}}{x_j - x_{j-1}}(x - x_j) \\ &= \frac{f_{j}}{h_j}(x - x_j) - \frac{f_{j-1}}{h_j}(x - x_j) \\ &= \frac{f_{j}}{h_j}(x - x_j) + \frac{f_{j-1}}{h_j}(x_j - x) = \frac{\sigma_{j}}{h_j}(x - x_j) + \frac{\sigma_{j-1}}{h_j}(x_j - x) \\ &= \frac{x - x_j}{h_j}\sigma_{j} + \frac{x_j - x}{h_j}\sigma_{j-1} \end{align*}

which is not quite the same, and I'm confused by how they obtained that form, mainly where $x_{j-1}$ came from.

After that, they take the integral of the function twice, obtaining a function with integration constants (?)

$$\alpha_j (x - x_{j-1}) + \beta_j(x_j - x)$$

and I was under the impression one integral would give integration constant $\alpha_j$, then a second would give

$$\alpha_j (x) + \beta_j$$

The pdf's explanation doesn't really do it much justice, and so I'm confused how such an integration is possible (why is $\beta_j$ a coefficient when it should be a constant).

Could someone clarify these steps for me? Thanks!


$$ \frac{(x_{j-1}-x)f_{j-1}+(x-x_{j-1})f_{j}}{x_j-x_{j-1}} = \frac{f_j-f_{j-1}}{x_j-x_{j-1}}(x-x_{j-1}) $$


(I change the names on purpose, with the hope it's simpler to understand the problem, as it's really related to linear interpolation, not splines)

You want a linear function on $[a,b]$ that equals $p$ at $x=a$ and $q$ at $x=b$.

Consider the function $g(x)=\dfrac{x-a}{b-a}q$. It's linear and $g(a)=0$, $g(b)=q$. With a carefully chosen linear combination of two similar functions, you get the linear function you want.

Consider now


The function $f$ is linear, and $f(a)=p$, $f(b)=q$.

Now, the $f$ you considered is


This can't work, as $f(b)=0$, not $q$, and $f(a)=p-q$, not $p$. You forgot one term in the linear interpolation, the function should be:


Of course, it's equivalent to the linear interpolation above:



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.