In Matlab, I can use the spline interpolation function spapi
to generate a spline curve, so that prescribed values of the curves and its first two derivatives can be matched. For example:
spapi([0 0 0 0 1 2 2 2 2],[0 1 1 1 2],[2 0 1 2 -1])
this produces the unique cubic spline f on the interval [0..2] with exactly one interior knot, at 1, that satisfies the five conditions
f(0)=2, f(1)=0, f'(1)=1, f''(1)=2, f(2)=–1
These include 3-fold matching at 1, i.e., matching there to prescribed values of the function and its first two derivatives.
In Python, however, the spline interpolate function scipy.interpolate.splrep(x,y)
can not work as x
should be monotone increasing.
So, how can I get a curve with prescribed values and derivative values? Is there any Python moldue or function?
Many thanks!