\chapter{Sage\TeX}
\label{Chapter2}
\section{This is a test}
Testing $\frac{1}{178} = \sage{n(1/178)}$.
\section{plotting}
is always fun ...
\sageplot[width=.5\textwidth]{plot(sin(x), (x,-10,10))}
\section{This is a test}
Testing $(1-x-x^2)^3 = \sage{((1-x-x^2)^2).expand()}$.
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) = sin(cos(2*x)^2 / (2+x))
\end{sageblock}
The first derivative of $f$ is $\sage{diff(f,x)}$.
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 $10$:
\sageplot[width=.5\textwidth]{plot(f, -1, 10)}
\section{AMS Math}
$$P\left(A=2\middle|\frac{A^2}{B}>4\right)$$
Matrix:
\begin{equation*}
A_{m,n} =
\begin{pmatrix}
a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\
a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m,1} & a_{m,2} & \cdots & a_{m,n}
\end{pmatrix}
\end{equation*}
More here: \url{https://en.wikibooks.org/wiki/LaTeX/Mathematics}.