# [SciPy-User] help interpreting univariate spline

josef.pktd@gmai... josef.pktd@gmai...
Fri Apr 30 15:40:33 CDT 2010

```On Fri, Apr 30, 2010 at 4:14 PM, Elliot Hallmark <permafacture@gmail.com> wrote:
>>  (I'll point out that you lose accuracy - possibly a lot of it -
>> by converting polynomials from one representation to another.)
>
> error between evaluation of the interpolation and eval of polynomial
> is consistently 10^-16.  I don't know if this is huge in computer
> world, but it is
> quite reasonable to me.  10^-16 is about zero in my view.
>
>
>  >If all
>> you want to do is solve the polynomials, though, scipy already
>> provides root-finding functionality in its splines
>
> But I will be using c code through cython to solve for roots, which is
> why I want a transparent way to solve the interpolation.
>
>>
>> If you really want the polynomials, though, the tck representation
>> scipy uses is semi-standard for representing splines; you may find the
>> non-object-oriented interface (splrep, splev, etc.) somewhat less
>> opaque in this respect. If you do decide to decipher the results, keep
>> in mind that with the knots held fixed, it's a linear representation
>> of the space of piecewise-cubic functions, so if you can find
>> representations for your basis functions (e.g. 1, x, x**2, x**3) you
>> can easily work out the conversion. And since the interpolating spline
>> for each of those functions is itself, all you need to do is four
>> interpolations on a fixed set of knots.
>
>
> um, I think this is what I already have done?  But the "semi standard"
> spline representation in tck is completely undocumented as far as I
> can tell.  The only way to get the polynomial coefficents I can tell
> is through evaluating the derivatives.
>
> Do you know what is the meaning of the coefficents splrep generates?
> How could such a small set of coefficents represent all the
> information of a cubic function?

just a guess:
http://en.wikipedia.org/wiki/B-spline#Cubic_B-Spline

has a representation of the curve as linear combination of spline
basis functions which requires only m-2 coefficients.

original documentation by Dierckx shows the exact specification.

But I still wouldn't see from the wikipedia representation, how to get
the coefficients of the piecewise polynomial back.

Josef

> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
```