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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)}
share|improve this question
up vote 3 down vote accepted

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}
share|improve this answer
    
Thanks! This is EXACTLY what I was looking for. – Physicsworks Sep 26 '12 at 17:52

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}
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.