1
\documentclass[aspectratio=1610]{beamer} 
\usepackage{amsmath} 

\begin{document} 
\def\function(#1){ 96* (#1)-16 *(#1)^2 } 

%1. I am trying to condense the following two lines

\pgfmathparse{3+\function(1)}
\let\z\pgfmathresult
z result is \z  %


 %2.  I would like  store the result of the previous line in a 'variable'

 %The following doesn't work 

\def\myfp(#1,#2){\pgfmathparse{#1} \let\#2\pgfmathresult}
\myfp(3+ \function(1),\z)  

% /This yields the right answer BUT  z Result is \z   ..... Yields error 



%3. Why does the following mess up%

\let\z7\pgfmathresult

z7 result is {\z7} 

%4. PLEASE point me to relevant documentation!
\end{document}
user34241
  • 421
  • 2
  • 4

1 Answers1

1

I am not sure I understand the question. However, if you want to call a macro \z7 this does not work because macro names cannot contain numbers. And I had to remove a backslash to arrive at

\documentclass[aspectratio=1610]{beamer} 
\usepackage{amsmath} 

\begin{document} 
\def\function(#1){ 96* (#1)-16 *(#1)^2 } 

%1. I am trying to condense the following two lines

\pgfmathparse{3+\function(1)}
\let\z\pgfmathresult
z result is \z  %


 %2.  I would like  store the result of the previous line in a 'variable'

 %The following doesn't work 

\def\myfp(#1,#2){\pgfmathparse{#1} \let#2\pgfmathresult} % <removed \ before #2
\myfp(3+ \function(1),\z)  

% /This yields the right answer BUT  z Result is \z   ..... Yields error 



%3. Why does the following mess up%

%\pgfmathparse{\z*7}
\let\zseven\pgfmathresult

z7 result is {\zseven} 

%4. PLEASE point me to relevant documentation!
\end{document}

enter image description here

  • What about documentation (i.e., for macros requested in %4? I'd rather try to look this stuff up myself rather than ask inappropriately elementary questions on stackexchange. For example, how did you know to remove the backslash in %2? – user34241 Feb 18 '19 at 13:39
  • @user34241 Could you please try to make your question clearer? And which parts do you want to get explanations for? –  Feb 18 '19 at 15:18