# Find fit for complex function for smooth derivatives

I need to fit my data dropbox of the form {x,y} because I need the fit function for further derivative calculation. My derivative curve should be smooth.

I tried

 BSplineFunction[data, SplineDegree -> 5]


and also

Interpolation[data, InterpolationOrder -> 2]


but both derivates are not smooth.

Therefore I ended up by using least square fit (LSF) by using a polynomial with varying the degree of the polynomial (DOP) to find the best fit:

DOP = 21;
LSF = Fit[data, Evaluate[Table[x^i, {x, 0, DOP}]] , x];


The problem is that even choosing a high DOP, the experimental data are not fitted very well in the important section of the curve (between local minimum and -maximum)

(blue: experimental data; red: LSF)

and/or the derivative seems to start to oscillate at the beginning or end of the curve (in this example at the beginning, pointed to by black arrow):

Zooming the experimental curve in the first section does not reveal something that could cause that error:

Has that something to do with Runge's phenomenon or how can I solve that easily?

• Using Chebyshev nodes probably solves the problem... Nov 16, 2013 at 17:52
• You might want to look at this discussion? mathematica.stackexchange.com/a/10997/1089 Nov 16, 2013 at 17:54

## 1 Answer

This "edge jitter" is to be expected. It is called Runge's Phenomenon. It happens around the edges of an interpolation, and it becomes worse with higher degree interpolations. Try using a lower degree on the spline (degree 3). On the interpolation you might be able add in some "fake" end points on the edges to force the "jitter" to occur farther away from your real data.

• Thank you. However, lower spline degree causes not smooth derivative. Otherwise it would be great. Nov 16, 2013 at 17:51