[pstricks] Can't use a mathematical function defined with FPeval in \psplot

Juergen Rose rose at rz.uni-potsdam.de
Sat Apr 12 16:16:28 CEST 2014


Am Freitag, den 11.04.2014, 16:30 +0200 schrieb Herbert Voss:
> Am 10.04.2014 18:13, schrieb Juergen Rose:
> 
> > I used the following code:
> >
> > \documentclass{article}
> > \usepackage[nomessages]{fp}%
> > \usepackage{pst-plot}
> >
> > \newcommand{\myMathFunction}[1]
> >      {\FPeval\result{trunc(((#1) * 5) - (#1)^2:0)}\result}
> 
> that cannot work. trunc(... :0) is a fp specific syntax and won't
> be understand by PSTricks (PostScript). You have to define two
> functions
> 
> Herbert

I found a solution. It is using two functions, but the algebraic
formular is only in one function:

\documentclass{article}

\usepackage[nomessages]{fp}
\usepackage{pst-plot}

\def\myMathFunction#1{(#1) * 5 - (#1)^2}

\newcommand\myMathFuncTwo[1] {
  \FPeval\result{\myMathFunction{#1}} \FPtrunc\res{\result}{2}\res
}

\begin{document}
\begin{tabular}{ r r }
  $x$ & $f(x)$ \\\hline
  0 & \myMathFuncTwo{0}\\
  1 & \myMathFuncTwo{1}\\
  2 & \myMathFuncTwo{2}\\
  3.3 & \myMathFuncTwo{3.3}\\
  4 & \myMathFuncTwo{4}\\
  5 & \myMathFuncTwo{5}\\\hline
\end{tabular}
%
\pspicture[shift=*](-1,0)(6,7)
\psaxes{->}(5.5,6)
\psplot[algebraic,linecolor=red,linewidth=1.5pt]{0}{5}{%
 \myMathFunction{x}%
}
\endpspicture
\end{document}

With this solution I can live. Thank you once more Herbert.




More information about the PSTricks mailing list