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)

fit vs experimental (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):

enter image description here

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

enter image description here

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


1 Answer 1


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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.