Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Using Chebyshev nodes probably solves the problem... – Shukoff Nov 16 '13 at 17:52
You might want to look at this discussion? – chris Nov 16 '13 at 17:54
up vote 2 down vote accepted

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.

share|improve this answer
Thank you. However, lower spline degree causes not smooth derivative. Otherwise it would be great. – Shukoff Nov 16 '13 at 17:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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