Recently I have discovered the interesting package named luacas (compilable with LuaLaTeX). To pag. 14 of the manual
https://ctan.mirror.garr.it/mirrors/ctan/macros/luatex/latex/luacas/doc/luacas.pdf
I have not understood the necessary packages to put in the preamble to compile the MWE to plot f and f'.
Someone please, can help me?
Here the fragment of the code:
\directlua{
tex.print(h:tolatex())
}
For Bob’s purposes, \fetch{h} is exactly what he needs:
\begin{tikzpicture}[scale=0.9]
\begin{axis}[legend pos = north west]
\addplot [domain=-3.5:1.5,samples=100]
{\fetch{h}};
\addlegendentry{$f$};
\addplot[densely dashed]
[domain=-3.25:1.25,samples=100]
{\fetch{dh}};
\addlegendentry{$df/dx$};
\addplot[gray,dashed,thick]
[domain=-3.5:1.5] {0};
\end{axis}
\end{tikzpicture}
Alternatively, Bob could use \store. The \store command will fetch the contents of its mandatory argument and store it in a macro of the same name.
\store{h}
\store{dh}

