Embed code, results of computations, and plots from the Sage mathematics software suite (https://www.sagemath.org) into LaTeX documents. Source repository for https://pypi.org/project/sagetex/ and https://ctan.org/pkg/sagetex
It would be useful to provide a way to "export" a function defined in sage such that you can use it with pgfplots directly. There is already a suggestion on stackexchange (http://tex.stackexchange.com/questions/220491/how-to-pass-a-function-defined-in-sagetex-to-pgfplots), where I proposed to have something like a sageraw command which you could use to pass the function as in the example below. Another idea would be to provide a command \expfct(funktion,texcommand) which "saves" the function under the name texcommand such that it is available from the main document for pgfplots.
\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}
It would be useful to provide a way to "export" a function defined in sage such that you can use it with pgfplots directly. There is already a suggestion on stackexchange (http://tex.stackexchange.com/questions/220491/how-to-pass-a-function-defined-in-sagetex-to-pgfplots), where I proposed to have something like a sageraw command which you could use to pass the function as in the example below. Another idea would be to provide a command \expfct(funktion,texcommand) which "saves" the function under the name texcommand such that it is available from the main document for pgfplots.