Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

| Download
Views: 480
1
% Chapter Template
2
3
\chapter{Sage\TeX} % Main chapter title
4
5
\label{Chapter2} % Change X to a consecutive number; for referencing this chapter elsewhere, use \ref{ChapterX}
6
7
\section{This is a test}
8
9
Testing $\frac{1}{178} = \sage{n(1/178)}$.
10
11
\section{plotting}
12
13
is always fun ...
14
15
\sageplot[width=.5\textwidth]{plot(sin(x), (x,-10,10))}
16
17
\section{This is a test}
18
19
Testing $(1-x-x^2)^3 = \sage{((1-x-x^2)^2).expand()}$.
20
21
Using Sage\TeX, one can use Sage to compute things and put them into
22
your \LaTeX{} document. For example, there are
23
$\sage{number_of_partitions(1269)}$ integer partitions of $1269$.
24
You don't need to compute the number yourself, or even cut and paste
25
it from somewhere.
26
27
Here's some Sage code:
28
29
\begin{sageblock}
30
f(x) = sin(cos(2*x)^2 / (2+x))
31
\end{sageblock}
32
33
The first derivative of $f$ is $\sage{diff(f,x)}$.
34
35
The second derivative of $f$ is
36
37
\[
38
\frac{\mathrm{d}^{2}}{\mathrm{d}x^{2}} \sage{f(x)} =
39
\sage{diff(f, x, 2)(x)}.
40
\]
41
42
Here's a plot of $f$ from $-1$ to $10$:
43
44
\sageplot[width=.5\textwidth]{plot(f, -1, 10)}
45
46
\section{AMS Math}
47
48
$$P\left(A=2\middle|\frac{A^2}{B}>4\right)$$
49
50
Matrix:
51
52
\begin{equation*}
53
A_{m,n} =
54
\begin{pmatrix}
55
a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\
56
a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\
57
\vdots & \vdots & \ddots & \vdots \\
58
a_{m,1} & a_{m,2} & \cdots & a_{m,n}
59
\end{pmatrix}
60
\end{equation*}
61
62
More here: \url{https://en.wikibooks.org/wiki/LaTeX/Mathematics}.
63