A B-spline of degree $j$ is defined at knots $\vec k$ by the Cox-de Boor recursion formula \begin{align} B_{i,1}(x) &= \left\{ \begin{matrix} 1 & \mathrm{if} \quad k_i \leq x < k_{i+1} \\ 0 & \mathrm{otherwise} \end{matrix} \right. \\ B_{i,j}(x) &= \frac{x - k_i}{k_{i+j-1} - k_i} B_{i,j-1}(x) + \frac{k_{i+j} - x}{k_{i+j} - k_{i+1}} B_{i+1,j-1}(x) \end{align}

and has derivative \begin{equation} \frac{\text{d}B_{i,j}(x)}{\text{d}x} = (j-1) \left( \frac{-B_{i+1,j-1}(x)}{k_{i+j}-k_{i+1}} + \frac{B_{i,j-1}(x)}{k_{i+j-1}-k_i} \right). \end{equation}

I am trying to implement the O'Sullivan penalty \begin{equation} S(x) = \sum_{i=1}^N \left\{ y_i - \sum_{j=1}^n \alpha_j B_j(x) \right\}^2 + \lambda \int_x \left\{ \sum_{j=1}^n \alpha_j \frac{\text{d}^2 B_j(x)}{\text{d}x^2} \right\} \text{d}x \end{equation} which requires second derivatives. What is the second derivative of a B-spline?


This document gives (with a corrected typo)

\begin{equation} \frac{\text{d}^{(n)}B_{i,j}(x)}{\text{d}x^{(n)}} = (j-1) \left( \frac{- \text{d}^{(n-1)} B_{i+1,j-1}(x) / \text{d}x^{(n-1)}}{k_{i+j}-k_{i+1}} + \frac{\text{d}^{(n-1)} B_{i,j-1}(x) / \text{d}x^{(n-1)}}{k_{i+j-1}-k_i} \right). \end{equation}

  • 1
    $\begingroup$ +1. Thank you for sharing your answer with us. Please consider accepting it too if you think it clarifies the issue you raised (no rep-points for self-accepting an answer I am afraid!). $\endgroup$ – usεr11852 says Reinstate Monic Jan 29 '17 at 21:32

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.