# How to draw tangens of arbitrary functions y=f(x) at given point (x,y) of f(x) using PStricks?

I'm relative new using PStricks and I don't know exactly how to draw a tangens of y=f(x) at a given point of the curve. I know, by simple mathematics that can be done by constructing the associate differential triangle at the point, [(x,y), dx, dy]. But, I think that PStricks should have a "easy-way" to do it automatically. Please, can you help me?

-
Welcome! Do you mean tangent? –  Marco Daniel Aug 18 '12 at 14:58
yes, that comes from Deutsch –  Miguel Toledo González Aug 18 '12 at 15:03

Pstricks consist of several packages. The basic on is pstricks.

A complete list of all available packages with a small description is given at tug.org/PStricks

To plot a function the package pst-plot is recommended. It provides the command \psplot.

Plotting a tangent of given function can easily be done be the command \psplotTangent which is provided by the package pstricks-add.

Here an example of the documentation:

\documentclass[pstricks]{standalone}

\begin{document}
\def\Fp{x RadtoDeg dup dup sin exch 2 mul sin 2 mul add exch 3 mul sin 3 mul add neg}
\psset{plotpoints=1001}
\begin{pspicture}(-7.5,-2.5)(7.5,4)%X\psgrid
\psaxes{->}(0,0)(-7.5,-2)(7.5,3.5)
\psplot[linewidth=3\pslinewidth]{-7}{7}{\F}
\psset{linecolor=red, arrows=<->, arrowscale=2}
\multido{\n=-7+1}{8}{\psplotTangent{\n}{1}{\F}}
\psset{linecolor=magenta, arrows=<->, arrowscale=2}%
\multido{\n=0+1}{8}{\psplotTangent[linecolor=blue, Derive=\Fp]{\n}{1}{\F}}
\end{pspicture}

\end{document}


-
Thanks a lot! That is perfect! –  Miguel Toledo González Aug 18 '12 at 15:05
@MiguelToledoGonzález don't forget to accept Marco Daniel's answer (click on the green checkmark to the left). –  Gonzalo Medina Aug 18 '12 at 15:11