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.

In my investigation Derive can only evaluate the derivative of function f(x) with respect to x. My attempt below does not produce the expected result because I try to find the derivative of x(t) and y(t) with respect to t.

\documentclass{article}
\usepackage{pst-plot,pst-node}

\def\x{sin(t)}
\def\y{cos(t)}

\def\xx{Derive(1,\x)}
\def\yy{Derive(1,\y)}

\begin{document}

\begin{pspicture}[algebraic](-.2,-2.2)(\dimexpr\psPiFour cm+.2cm,2.2)
    \psparametricplot{0}{TwoPi 2 mul}{\xx|\yy}
\end{pspicture}

\end{document}
  • Can anybody here help me to let Derive also work with any variable such that my project here (click) can be easily done without having to manually calculate the derivative of the given functions?

  • How can we invoke Derive in postfix form? If it is possible then the first question can be solved just by using ED as follows,

    <postfix expression in x>  1 Derive t /x ED
    
share|improve this question

1 Answer 1

up vote 5 down vote accepted
+100

The variable x used for the derivative is hardcoded, see definition of /EvalDerive in the file pst-algparser.pro. So you must redefine some internal Postscript functions.

The less invasive redefinition I found was to change /EvalVariable, which is the only procedure actually accessing the (x):

\documentclass[pstricks,margin=5pt]{standalone}
\usepackage{pst-plot,pst-node}
\def\ChangeEvalVariable#1{%
  \pstVerb{tx@Derive begin
    /origEvalVariable /EvalVariable load def
    /EvalVariable { 2 index (#1) eq { (1) } { (0) } ifelse 4 -1 roll exch 6 2 roll } def
  end }%
}%
\def\ResetEvalVariable{%
  \pstVerb{tx@Derive begin
    /EvalVariable /origEvalVariable load def
    end }%
}%
\def\x{sin(t)}
\def\y{cos(t)}

\def\xx{Derive(1,\x)}
\def\yy{Derive(1,\y)}

\begin{document}

\begin{pspicture}[algebraic](-1.2,-1.2)(3.2,1.2)
    \ChangeEvalVariable{t}
    \psparametricplot{0}{Pi}{\xx|\yy}
    \ResetEvalVariable
    \psplot{0}{Pi}{Derive(1,sin(x))}
\end{pspicture}

\end{document}

enter image description here

You cannot use Derive for a Postscript expression, because Derive actually calculates the derivative analytically by parsing the string representation of the function.

share|improve this answer

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.