# [Tex/LaTex] How to use sagetex package

sagetex

I'm trying to use sagetex package,
but then I found this kind of problem when running the code,
may anyone help?

Here is the code:

\documentclass{article}
\usepackage{sagetex}

\begin{document}
Using Sage\TeX, one can use Sage to compute things and put them into
your \LaTeX{} document. For example, there are
$\sage{number_of_partitions(1269)}$ integer partitions of $1269$.
You don't need to compute the number yourself, or even cut and paste
it from somewhere.
Here's some Sage code:
\begin{sageblock}
f(x) = exp(x) * sin(2*x)
\end{sageblock}
The second derivative of $f$ is
$\frac{\mathrm{d}^{2}}{\mathrm{d}x^{2}} \sage{f(x)} = \sage{diff(f, x, 2)(x)}.$
Here's a plot of $f$ from $-1$ to $1$:
\sageplot{plot(f, -1, 1)}
\sageplot[scale=.5]{plot3d(sin(pi*(x^2+y^2))/2,(x,-1,1),(y,-1,1))}
we know that 2010 factors to $\sage{factor(2010)}$
\begin{sagesilent}
m=identity_matrix(QQ,3)
m[0]=m[0]+m[1]
m[1]=m[1]-m[2]
m[2]=m[2]-2*m[1]
m[1]=m[1]+3*m[0]
m[0]=2*m[0]
\end{sagesilent}
Compute the rref of $\sage{m}$
\begin{sageblock}
g(x)=taylor(tan(x),x,0,10)
\end{sageblock}
$$\tan(x)=\sage{g(x)}$$
\end{document}


Running

pdflatex myfile.tex


produces an auxiliary file that contains all the computations Sage needs to do:

myfile.sagetex.sage


Running Sage on this file:

sage myfile.sagetex.sage


computes the results of all these computations, so that the next time you run

pdflatex myfile.tex


the results of the computations are included and appear in the resulting pdf.