Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I find the tangent at a point?

44 views
Skip to first unread message

James

unread,
Feb 10, 2012, 10:38:12 AM2/10/12
to
I have an array of X co-ordinates and another array of Y co-ordinates which when plotted gives a curve.
could somebody tell me how to find the tangent or slope at each of these coordinates?

Thank you!!

James

Torsten

unread,
Feb 10, 2012, 11:22:27 AM2/10/12
to
An approximation for the slope at point X_(i) is (Y_(i+1)-Y_(i-1))/
(X_(i+1)-X_(i-1)) (central difference).
At the end points X_(1) and X_(n), you could use one-sided
differences:
at X_(1): (Y_(2)-Y_(1))/(X_(2)-X_(1)) and at X_(n): (Y_(n)-Y_(n-1))/
(X_(n)-X_(n-1))

Best wishes
Torsten.


James

unread,
Feb 11, 2012, 4:51:30 AM2/11/12
to
Thanks a lot Torsten

Torsten <Torsten...@umsicht.fraunhofer.de> wrote in message <ed4d4b74-bc6e-4da3...@dq9g2000vbb.googlegroups.com>...

Torsten

unread,
Feb 11, 2012, 8:34:51 AM2/11/12
to
On 11 Feb., 10:51, "James " <jameskja...@gmail.com> wrote:
> Thanks a lot Torsten
>
>
>
> Torsten <Torsten.Hen...@umsicht.fraunhofer.de> wrote in message <ed4d4b74-bc6e-4da3-9dea-e47f3b205...@dq9g2000vbb.googlegroups.com>...
> > On 10 Feb., 16:38, "James " <jameskja...@gmail.com> wrote:
> > > I have an array of X co-ordinates and another array of Y co-ordinates which when plotted gives a curve.
> > > could somebody tell me how to find the tangent or slope at each of these coordinates?
>
> > > Thank you!!
>
> > > James
>
> > An approximation for the slope at point X_(i) is (Y_(i+1)-Y_(i-1))/
> > (X_(i+1)-X_(i-1)) (central difference).
> > At the end points X_(1) and X_(n), you could use one-sided
> > differences:
> > at X_(1): (Y_(2)-Y_(1))/(X_(2)-X_(1)) and at X_(n): (Y_(n)-Y_(n-1))/
> > (X_(n)-X_(n-1))
>
> > Best wishes
> > Torsten.- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

I just noticed that the approximation is only valid if the X-
coordinates
all have equal distance, i.e. X_(i+1)-X_(i) = deltax = constant.

If the X-coordinates have different distance, then you should use
at x=X(1) :
slope approximately
Y(1)*((X_(1)-X_(2))+(X_(1)-X_(3))/((X_(1)-X_(2))*(X_(1)-X_(3))) +
Y(2)*(X_(1)-X_(3))/((X_(2)-X_(1))*(X_(2)-X_(3))) +
Y(3)*(X_1)-X_(2))/((X_(3)-X_(2))*(X_(3)-X_(1)))
in inner points X=X_(i)
slope approximately
Y_(i-1)*(X_(i)-X_(i+1))/((X_(i-1)-X_(i))*(X_(i-1)-X_(i+1))) +
Y_(i)*((X_(i)-X_(i-1))+(X_(i)-X_(i+1)))/((X_(i)-X_(i-1))*(X_(i)-X_(i
+1))) +
Y_(i+1)*(X_(i)-X_(i-1))/((X_(i+1)-X_(i))*(X_(i+1)-X_(i-1)))
at X=X_(n):
Y_(n-2)*(X_(n)-X_(n-1))/((X_(n-2)-X_(n-1))*(X_(n-2)-X_(n))) +
Y_(n-1)*(X_(n)-X_(n-2))/((X_(n-1)-X_(n-2))*(X_(n-1)-X_(n))) +
Y_(n)*((X_(n)-X_(n-1))+(X_(n)-X_(n-2)))/((X_(n)-X_(n-1))*(X_(n)-
X_(n-2)))

Best wishes
Torsten.
0 new messages