# how to find slope of discrete point?

I am wondering if it is possible to find the slope at each point in the following dataset,

 % X Y %=================== 0.7761 0.5715 0.794 0.5729 0.8117 0.5744 0.8292 0.5762 0.8465 0.5782 0.8637 0.5804 0.8807 0.5828 0.8977 0.5853 0.9144 0.5879 0.9311 0.5907 0.9477 0.5937 0.9641 0.5968 0.9805 0.6 0.9967 0.6033 1.0129 0.6067

I understand that the slope can be obtained using the difference of the two neighboring points by

$$m = \frac{y_2-y_1}{x_2-x_1}$$

and, the angle that each point made with the $$x$$-axis is essentially the $$atan$$ of $$m$$

$$\theta = \tan^{-1}(m)$$

But, is it possible to calculate the slope without using the above formula? without trying to curve-fit the points.

• The formula that you're using for the slope $m$ assumes that the function $y=f(x)$ is linear between the points. There are other methods, too. It's possible to assume a quadratic relation, etc ... But why do you ask if it's possible to calculate without using the formula? What's wrong with using the formula? Jan 8, 2019 at 13:54
• There's nothing wrong with the formula. The reason is that the method is heavily dependent on the sampling rate of the points. I am curious if there is any other method or approach that can be used. Jan 8, 2019 at 13:56
• @BeeTiau: I'd take Matti P's suggestion, and assume a reasonable polynomial shape (why polynomial? Because they're super-easy to differentiate), differentiate that, and get the derivative value at the desired points. This method has the advantage of smoothing out your data a bit (fitting a curve is a summation process, and hence smoothing, whereas raw differentiation like you did makes graphs more jagged and noisy). As for sampling rate, fitting a reasonable polynomial (you might look up cubic splines) will mitigate that. Jan 8, 2019 at 14:06

This is analogous to the fact that $$f'(x)$$ is more accurately estimated by $$(f(x+h)-f(x-h))/(2h)$$ (error of order $$h^2$$) than by $$(f(x+h)-f(x))/(h)$$ (error of order $$h$$).