\documentclass{article}
\title{Title of Document}
\author{Name of Author}
\usepackage{sagetex}
\begin{document}
\maketitle
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)}
\begin{sageblock}
a = var('a')
b = var('b')
d = {a: [2], 2: [a,3,b], 3: [2,4,b], 4: [3,5,b], 5:[6,b], b: [2,3,4,5,6]}
G = Graph(d)
G.add_edge((a,b,'foo'))
\end{sageblock}
\begin{center}
\sageplot[width=.7\textwidth]{G.plot(color_by_label={None:'black','foo':'red'})}
\end{center}
\end{document}