Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
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
add comment

1 Answer

up vote 11 down vote accepted

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}
\usepackage{pstricks,pst-plot,pstricks-add}

\begin{document}
\def\F{x RadtoDeg dup dup cos exch 2 mul cos add exch 3 mul cos add}
\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}

enter image description here

share|improve this answer
    
Thanks a lot! That is perfect! –  Miguel Toledo González Aug 18 '12 at 15:05
2  
@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
add comment

Your Answer

 
discard

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

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