

last edited 15 years ago by Bill Page 
1 2 3  
Editor: Bill Page
Time: 2007/09/19 00:20:17 GMT7 

Note: 
changed:  \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^5001}$ is $\sage{factor(x^5001)}.$ \end{document}
Download: pdf dvi ps src tex log 
sage: cd '/var/zope/var/LatexWiki/mathaction'; unset PYTHONPATH; PATH=/usr/local/bin:$PATH HOME=/var/lib/plone2/main sage SandBoxSagePamphlet.sage mkdir: cannot create directory `/var/lib/plone2': Permission denied cp: target `/var/lib/plone2/main/.sage//' is not a directory: No such file or directory Traceback (most recent call last): File "SandBoxSagePamphlet.py", line 2, in <module> from sage.all_cmdline import * File "/usr/local/sage2.6/local/lib/python2.5/sitepackages/sage/all_cmdline.py", line 14, in <module> from sage.all import * File "/usr/local/sage2.6/local/lib/python2.5/sitepackages/sage/all.py", line 53, in <module> from sage.misc.all import * # takes a while File "/usr/local/sage2.6/local/lib/python2.5/sitepackages/sage/misc/all.py", line 1, in <module> from misc import (alarm, srange, xsrange, sxrange, getitem, File "/usr/local/sage2.6/local/lib/python2.5/sitepackages/sage/misc/misc.py", line 75, in <module> raise OSError, " ** Error trying to create the SAGE tmp directory in your home directory. A possible cause of this might be that you built or upgraded SAGE after typing 'su'. You probably need to delete the directory $HOME/.sage." OSError: ** Error trying to create the SAGE tmp directory in your home directory. A possible cause of this might be that you built or upgraded SAGE after typing 'su'. You probably need to delete the directory $HOME/.sage. [Errno 13] Permission denied: '/var/lib/plone2'