[pstricks] A little bit more complicated function definition fails again. Was: Can't use a mathematical function defined with FPeval in \psplot

Juergen Rose rose at rz.uni-potsdam.de
Sat Apr 12 18:39:53 CEST 2014


Am Samstag, den 12.04.2014, 16:16 +0200 schrieb Juergen Rose:

> ...
> 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}
...
I tried to use a little bit more complicated definition of a function:

\documentclass{article}

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

\def\Vre{700}

\begin{document}

\def\myMathFunction#1{
  \def\nonr##1{1000*(\Vre/2)^(1/3)/((2)^0.5*(##1))+(6)^0.5/2-1}
  (\nont{(#1)}) * 5 - (\nonr{(#1)})^2
}

\pspicture[shift=*](-1,0)(6,7)
\psaxes{->}(5.5,6)
\psplot[algebraic,linecolor=red,linewidth=1.5pt]{1}{5}{%
 \myMathFunction{x}%
}
\endpspicture
\end{document}

xelatex fails with:

No file define_math_function_test_3__fp_table_plot.aux.
! Undefined control sequence.
\myMathFunction #1-> \def \nonr 

##1{1000*(\Vre /2)^(1/3)/((2)^0.5*(##1))+(6)...
l.23 }


I have an other example with a very similar definition of function,
which works. I do not see, what I am doing wrong. Please help.

Juergen





More information about the PSTricks mailing list