% !TEX TS-program = sage 

% The following lines are standard LaTeX preamble statements.
\documentclass[11pt, oneside]{amsart}
\usepackage{geometry}     
\geometry{letterpaper}         
\usepackage[parfill]{parskip} 
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{epstopdf}
\title{Brief Article}
\author{The Author}

% Only one command is required to use Sage within the LaTeX source:
\usepackage{sagetex}

\begin{document}
\maketitle
\section{Introduction}

This is an example of using Sage within a \TeX\ document. We can compute extended values like 

	$$32^{31} = \sage{32^31}$$
	
We can plot functions like $x \sin x$:

 \sageplot[width=5in]{plot(x * sin( 30 * x), -1, 1)}
 
 We can integrate:
 
 $$\int {{x^2 + x + 1} \over {(x - 1)^3 (x^2 + x + 2)}}\,dx$$
 $$=  \sage{integrate( (x^2 + x + 1) / ((x - 1)^3 * (x^2 + x + 2)) )}$$
 
 \newpage
 We can perform matrix calculations:
 
$$\sage{matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])^3}$$

$$AB=  \sage{Matrix([[1, 2], [3, 4]])} \sage{Matrix([[5, 6], [6, 8]])} = \sage{Matrix([[1, 2], [3, 4]]) * Matrix([[5, 6], [6, 8]])}$$

Plots are fun; here is a second one showing $x \ln x$. The ``width'' command in the source is sent to the include graphics command in LaTeX rather than to Sage.

\sageplot[width=5in]{plot(x * ln(x), 0, 2)}

Sage understands mathematical constants and writes them symbolically unless it is told to produce a numerical approximation. The term $e \pi$ below is not in the LaTeX source; instead it is the result of a Sage calculation, as is the numerical value on the other side of the equal sign.

The product of $e$ and $\pi$ is $\sage{pi * e} = \sage{N(pi * e)}.$

\end{document}

