\documentclass{article} \title{Embedding SAGE In Latex: Examples} \usepackage{amsmath} \usepackage{sagetex} \begin{document} \abstract{Gonzalo Tornaria and Joe Wetherell and others designed and implemented this at the SAGE Days coding spring. It's amazing! It allows you to embed arbitrary SAGE code and its output in latex documents, and works like any other latex package.} \maketitle This is an example $1+2+3=\sage{1+2+3}$ and also 2+3=\sage{2+3}. Now we evaluate the following block: \begin{sageblock} # do some stuff E = EllipticCurve("37a") # more stuff \end{sageblock} Now the elliptic curve $E$ given by $\sage{E}$ has discriminant $\sage{E.discriminant()}$. There are problems with the spacing, but this is easily fixed. \begin{sageblock} M = MatrixSpace(QQ,10) A = M(range(10^2)) \end{sageblock} Consider the matrix $$A^2 = \sage{A^2}$$ defined in SAGE code above. It's also possible to do caching! \begin{sageblock} try: E = load('E2') except IOError: E = EllipticCurve([1,2,3,4,5]) E.anlist(100000) E.save('E2') \end{sageblock} The 9999's Fourier coefficient of $\sage{E}$ is $\sage{E.anlist(100000)[9999]}$. \begin{sageblock} fMaxima = maxima('sin(x)^2*cos(x)*exp(x)') gMaxima = fMaxima.integrate("x") \end{sageblock} We have $$\int \sage{fMaxima} dx = \sage{gMaxima}.$$ In Axiom it looks like this: \begin{sageblock} fAxiom = axiom('sin(x)^2*cos(x)*exp(x)') gAxiom = fAxiom.integrate("x") \end{sageblock} We have $$\int \sage{fAxiom} dx = \sage{gAxiom}.$$ This year is $2006=\sage{factor(2006)}$. Next lets compute in a polynomial ring. \begin{sageblock} x = QQ['x'].0 f = x^10 + 17 \end{sageblock} Consider $f=\sage{f}$. Notice that the $10$th power of $f$ is $f^{10} = \sage{f^10}$. The factorization of $\sage{x^500-1}$ is $\sage{factor(x^500-1)}.$ \end{document}