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

Let's say I have an "S" shaped curve made up of 50 points. I am only given the data points, and there is no simple or obvious equation for each point on the curve.

So given only the data points, how would I be able to calculate the slope of the curve at a particular data point?

share|cite|improve this question

Estimate the tangent by taking the secants you can compute; you the tangent will lie somewhere between the two.

That is: you cannot compute the slope exactly, but you can estimate it from the information you have.

You have immediately preceding and immediately succeeding points, $t_{i-1}$ and $t_{i+1}$, as well as value $f(t_{i-1})$, $f(t_i)$, and $f(t_{i+1})$. The secant between $(t_{i-1},f(t_{i-1}))$, and $(t_i,f(t_i))$ has a certain slope $L_1$; the secant between $(t_i,f(t_i))$ and $(t_{i+1},f(t_{i+1}))$ has a certain slope $L_2$. Unless the graph is very nasty, the tangent at $(t_i,f(t_i))$ should have a slope that is somewhere between $L_1$ and $L_2$.

share|cite|improve this answer

The simplest is just to take one of the neighboring points and find the slope of the line through those two. This approach is sensitive to measurement error in the points, particularly if they are measured at x values that are close together. Another approach is to fit some functional form (like an arctangent or logistic function is your data is S shaped) through the data points. This is smoothing, so will be less sensitive to measurement error (particularly if it has fewer parameters than you have measurements), but is sensitive to modeling error. There is a discussion in chapters 3 and 15 of Numerical Recipes

share|cite|improve this answer

Cubic Splines! You fit cubic spline through the points, and then take slope from the cubic spline definition. Note that if the data have any noise, you need to smooth it first.


  1. Cubic Splines - Wolfram
  2. Splines - Wikipedia
  3. Interpolation - Numerical Recipies Online - Open charter B3

Once the spline is defined, for each segment with curve coordinates ($x(\alpha)$,$y(\alpha)$) the slope is $$s=\frac{\mathrm{d}y/\mathrm{d}\alpha}{\mathrm{d}x/\mathrm{d}\alpha}$$ evaluated at the desired location parameter $\alpha=0\ldots1$.

share|cite|improve this answer

Your Answer


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