3

Suppose I defined some variables via

\def\n1{some_value_1}
\def\n2{some_value_2}
\def\n3{some_value_3}

and I'd like to have another one, say, \f which is a function of \n1, \n2 and \n3.

This simple code doesn't work:

\def\f{\n1*log(\n2)-\n3}

P.S. This is going to be used in plotting functions via PsTricks (if it helps).

UPDATE: For example (\f is used in \psplot for x_max):

\def\f{\n1*log(\n2)-\n3}
\psplot{0}{\f}{sin(x)}
3

enter image description here

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\psset{algebraic,plotpoints=100}

\usepackage[nomessages]{fp}
\FPset\a{3}
\FPset\b{2}
\FPset\c{1}
\FPeval\XMax{round(a*ln(b)-c:3)}
\begin{document}

\begin{pspicture}[showgrid=bottom](-\psPi,-2)(\psPi,2)
  \psplot[linecolor=blue]{0}{\XMax}{sin(x)}
  \rput[tr](\psPi,2){\textcolor{red}{XMax=$\XMax$}}
\end{pspicture}

\end{document}
2

The macro names must not contain numbers.

enter image description here

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\psset{algebraic,plotpoints=100}

\def\f(#1){#1}
\def\g(#1){sqrt(#1)}
\def\h(#1){\f(\g(#1))}

\begin{document}

\begin{pspicture}[showgrid=bottom](-1,-3)(5,3)
  \psplot[linecolor=blue]{0}{5}{\h(x)}
\end{pspicture}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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