Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: 335_16
Views: 88
1
\documentclass{article}
2
\title{Title of Document}
3
\author{Name of Author}
4
\usepackage{sagetex}
5
6
\begin{document}
7
\maketitle
8
9
10
Using Sage\TeX, one can use Sage to compute things and put them into
11
your \LaTeX{} document. For example, there are
12
$\sage{number_of_partitions(1269)}$ integer partitions of $1269$.
13
You don't need to compute the number yourself, or even cut and paste
14
it from somewhere.
15
16
Here's some Sage code:
17
18
\begin{sageblock}
19
f(x) = exp(x) * sin(2*x)
20
\end{sageblock}
21
22
The second derivative of $f$ is
23
24
\[
25
\frac{\mathrm{d}^{2}}{\mathrm{d}x^{2}} \sage{f(x)} =
26
\sage{diff(f, x, 2)(x)}.
27
\]
28
29
Here's a plot of $f$ from $-1$ to $1$:
30
31
\sageplot{plot(f, -1, 1)}
32
33
34
\begin{sageblock}
35
a = var('a')
36
b = var('b')
37
d = {a: [2], 2: [a,3,b], 3: [2,4,b], 4: [3,5,b], 5:[6,b], b: [2,3,4,5,6]}
38
G = Graph(d)
39
G.add_edge((a,b,'foo'))
40
\end{sageblock}
41
\begin{center}
42
\sageplot[width=.7\textwidth]{G.plot(color_by_label={None:'black','foo':'red'})}
43
\end{center}
44
\end{document}
45
46