Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. 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

The following curve shows an initial segment of smooth decline, followed by a set of nearly equal data points, followed by another smooth decline.

I am looking for a function that could best fit these data points.

Any suggestions?

an initial segment of smooth decline, followed by a set of nearly equal data points, followed by another smooth decline

share|cite|improve this question
I guess you should adopt some piecewise approximation of some kind. Is a piecewise linear approximation too crude? If that is the case you could try a piecewise cubic spline. (Disclaimer: I am not an expert of those things.) – Giuseppe Negro Jan 9 '13 at 0:22
A polynomial function – Cactus BAMF Jan 9 '13 at 0:23
@CactusBAMF Yes, a polynomial of order 3 seems to work. I'll search for a method to fit a polynomial to those data points. – Laurent Jan 9 '13 at 2:23
@GiuseppeNegro Thanks. I have used an Akima spline, which works very well, but I would prefer a function, rather than a piecewise approximation. – Laurent Jan 9 '13 at 2:24
May I ask why? Strictly speaking, a piecewise approximation is a function---just one that takes a bit more effort to write down. What might the practical limitation be on using one? – Michael Grant Apr 9 '13 at 2:50

A cubic polynomial $p(x)=ax^3+bx^3+cx+d$ would do a decent job here. The coefficients $a,b,c,d$ can be determined using linear least squares.

But you should also explore the possibility that your function contains a periodic component. These are not as easy to fit to the data when you don't know the period. But you can find the period either by eyeballing the residual of the polynomial approximation, or by taking the Fourier transform of the data. (I could not try this myself since no actual data is given in the question, only a plot).

share|cite|improve this answer

This all depends. if you are simply looking for a function that best fits the points, I count $6$ critical points (places where the derivative changes sign), so you could fit with a polynomial of degree $7$. This means $8$ unknown coefficients without any other knowledge of the curve, but since it looks like you have more than $8$ points, you should be able to get some decent fit.

Then again, you can get a more accurate fit by assuming that the function is the sum of a linear component and a polynomial. The linear component is determined by the leftmost and rightmost points - no fit necessary. This should minimize the linear component of the fit polynomial and make the fit more robust.

Nevertheless, if the points derive from some physical measurement, then you need to ask yourself what model is best for the experiment - and how well does your model fit with the points? Further, you may want as low a dimension as possible because the points do look noisy (see my earlier comments about many critical points).

share|cite|improve this answer

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.