Is there any way to pass a function defined in sagtex to pgfplots for plotting? See the following example.
\documentclass{article}
\usepackage{pgfplots}
\usepackage{sagetex}
\begin{document}
\begin{sagesilent}
f(x) = 2*sin(x^2)
\end{sagesilent}
$f(x) = \sage{f(x)}$
\begin{center}
\begin{tikzpicture}
\begin{axis}[no markers, samples=100]
% \addplot gnuplot {\sageraw{f(x)}};
%should be the same as
\addplot gnuplot {2*sin(x^2)};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
Edit: I also tried \pgfmathdeclarefunction{function}{\sagestr{print(f(x))}} and then \addplot gnuplot {function(x)}; but it didn't work.
Edit 2: I have just opened a feature request for sagetex: https://github.com/dandrake/sagetex/issues/1 I hope there will be a solution for this issue soon
\pgfmathdeclarefunction{generic sage}with one argument. Assign the output to the raw sage output. I don't have Sage so I can't test it. – percusse Jan 03 '15 at 14:43\sagerawabove doesn't exist, it was only a fake command. – student Jan 03 '15 at 14:53sagesilentwithin the function declaration? – percusse Jan 03 '15 at 15:07