0
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ 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? $\endgroup$
    – Matti P.
    Jan 8, 2019 at 13:54
  • $\begingroup$ 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. $\endgroup$
    – BeeTiau
    Jan 8, 2019 at 13:56
  • 1
    $\begingroup$ @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. $\endgroup$ Jan 8, 2019 at 14:06

1 Answer 1

1
$\begingroup$

In my experience, when trying to estimate the slope at a point, it is better to use the slope of the line between the preceding and following point.

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$).

$\endgroup$
2
  • $\begingroup$ Thanks. Meaning that there is no way we can estimate the slope without knowing the functions (or trend?) of the data? $\endgroup$
    – BeeTiau
    Jan 8, 2019 at 15:45
  • $\begingroup$ All you need are a series of (x, y) values. $\endgroup$ Jan 8, 2019 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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