# How to find the best interpolating function if we know $y(x_i)$ and $dy(x_i)/dx$

Imagine you are given a set of data points $\{x_i,y_i\}$, supplemented by a list of known first derivatives $\{y'_i\}$.

How would you construct an interpolating function $y(x)$ (which satisfies $y(x_i)=y_i$ and $y'(x_i)=y'_i$), such that the derivative, calculated from this function has the smallest error.

The function is expected to be well behaved, consisting of piece-wise power functions, smoothely linked.

What would you do if you knew second derivatives as well and wanted to work with them instead of the first ones?

-
I would first try a cubic spline. –  Chris Taylor Feb 27 '12 at 15:22
I like cubic splines, but 1) This isn't extendable to the case when you know second derivatives as well as the first ones, 2) Even in the simpler case of having only first derivatives, if you want to work with y', y'' shall be non-smooth, which isn't a good feature. –  Alexey Bobrick Feb 27 '12 at 15:33
Like a Hermite Interpolation problem? –  mixedmath Feb 27 '12 at 16:01
The minimum degree polynomial interpolation can be found in "Newton form" easily using "divided differences". This lets you replace cubic splines with quartic splines, etc. The method easily allows you to have 5 derivatives at one point given and only 2 at another, and none (only the function) at another (per spline). To do even better than this: I think the more clever interpolation ideas require the algorithm to choose the xi, and the user to supply the yi and yi' etc. –  Jack Schmidt Feb 27 '12 at 16:03
@Jack Schmidt, when going to higher order splines, one would expect them to be unstable and not really recovering the original function. Or would you suggest power functions being well recovered by, say a 5-th order spline for the case of 2-nd derivatives given? –  Alexey Bobrick Feb 27 '12 at 22:04