Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to use the function BSplineFunction[] to create a natural cubic spline. Normally what is done is that you specify "SplineDegree -> 3" and include a list of points and it will carry out the interpolation. I have a slightly different scenario now where my knots are not known, some of the points are variable and some interpolation points are not specified but rather velocities are specified.

More specifically, I would like a natural cubic spline satisfying these constraints where the numbers $0 < b < a$ and where $p_{-1}, p_0$ and $p_1$ are fixed:

$$ \begin{align}x(-a) & = a(p_{-1} - p_0) & x^{(1)}(-a) & = p_0 - p_{-1} & x^{(2)}(-a) &= 0 \\ x(a) &= a(p_1 - p_0) & x^{(1)}(a) & = p_1 - p_{0} & x^{(2)}(a) &= 0 \\ & &x(0) &= p_0\end{align} $$

With the condition $x(t)$ needs $C^2$ at $t = -b$, $t = 0$ and $t=b$.

This will give me $4$ separate cubic polynomials on $[-a, -b], [-b, 0], [0, b], [b, a]$. I have a total of $16$ degrees of freedom and $16$ constraints so a unique solution should exist.

I could very easily put this into a matrix myself but it seems Mathematica already has it inbuilt, it would be a shame not to use it just because I couldn't figure out how. Is this possible and if so, can you please either let me know how or point me to relevant documentation that I might not have seen yet.

Thanks

Edit: Additional details regarding the conversation between me and belisarius below. I have done a hand computation for such a problem and here is an example of a function I get:

$$ f_1 = -\frac{x^3 (-2 b \text{pC}+b \text{pL}+b \text{pR}-6 \text{pC})}{6 a^2 (a-b)}-\frac{x^2 (-2 b \text{pC}+b \text{pL}+b \text{pR}-6 \text{pC})}{2 a (a-b)}-\frac{x (-2 a \text{pC}+2 a \text{pL}-b \text{pL}+b \text{pR}-6 \text{pC})}{2 (a-b)}+\frac{a (2 b \text{pC}-b \text{pL}-b \text{pR}+6 \text{pC})}{6 (a-b)} $$

where pL = $p_{-1}$, pC = $p_0$ and pR = $p_1$. Here is a picture of $f_1, f_2, f_3, f_4$ for the parameters $b=3, a=6$ and $p_{-1} = 2, p_0 = 3$ and $p_1 = 5$:

Cubic spline

share|improve this question
2  
See the options for Interpolation: they allow you to specify derivatives. –  whuber Mar 19 '13 at 20:47
    
Thanks, I will have another look. I probably missed something obvious, I did read through those before. –  muzzlator Mar 19 '13 at 21:01
    
I seem to be missing something. Apart from the conditions $0<b<a$ and $C^2$ continuity at $\pm b$, there are no other conditions (e.g. values at $x=\pm b$)? –  J. M. Apr 20 '13 at 18:47
    
Hm. I seem to have misworded the original question, it should be $C^2$ at $x = 0$ too. Will edit. –  muzzlator Apr 20 '13 at 18:54
    
Still missing something. There's no prescription for, say, $x(b)$? –  J. M. Apr 20 '13 at 19:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.