%sage

print 'This is SAGE_TMP path that will have to be copied in the \includegraphics LaTeX command'
SAGE_TMP

This is SAGE_TMP path that will have to be copied in the \includegraphics LaTeX command l'/projects/9021f9d5-8761-43dc-a671-18da3a5ab38f/.sage/temp/compute2-us/28385'
%latex

\section{\LaTeX \ Equation Editor Examples}

Here are some examples using \LaTeX{} and \textsf{Sage\TeX}:

\begin{enumerate}
\item The Exponential Function $\displaystyle \sum_{n=0}^\infty \frac{x^n}{n!} = e^x$
\item Computing a fraction $\frac{1}{178} = \sage{n(1/178)}$
\item Computing a derivative
$\frac{\mathrm{d}}{\mathrm{d}x} \sage{sin(cos(2*x)^2 / (2+x))} = \sage{diff(sin(cos(2*x)^2 / (2+x)), x)(x)}$
\end{enumerate}

\section{Plotting}

Here is a plot:
\begin{center}
%\sage{plot(sin(cos(2*x)^2 / (2+x)), -1, 10, title='Plot sin(cos(x)^2 / (2+x)) from -1 to 10').save(os.path.join(SAGE_TMP, 'test.png'))}
\includegraphics[width=0.8\textwidth]{/projects/9021f9d5-8761-43dc-a671-18da3a5ab38f/.sage/temp/compute2-us/28385/test.png}
\end{center}

Getting the plot to show in-line required a bit of a hack. When using the \textbf{show()} function, the plot rendered at the top of the image. So we used the \textbf{save()} function. Since we are saving the plot to the temporary location \textsf{SAGE\_TMP} it will be removed when leaving Sage. \\

Also, the plot command appears to be commented, but it still renders. This was required to stop Sage from printing the word \textbf{None}.

\section{AMS Math}

$$P\left(A=2\middle|\frac{A^2}{B}>4\right)$$

Matrix:

\begin{equation*}
A_{m,n} =
\begin{pmatrix}
a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\
a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\
\vdots  & \vdots  & \ddots & \vdots  \\
a_{m,1} & a_{m,2} & \cdots & a_{m,n}
\end{pmatrix}
\end{equation*}