Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/latex/sagetex/minimal.tex
Views: 1038
\documentclass{article}12\usepackage[utf8]{inputenc}3\usepackage{fullpage}4\usepackage{mathtools}5\usepackage{sagetex}6\usepackage{url}78\title{This is a demo of SageTeX}910\begin{document}1112\maketitle1314To learn more about \LaTeX: \url{https://en.wikibooks.org/wiki/LaTeX}1516For SageTeX, please check out the project:17\url{https://github.com/dandrake/sagetex}1819\section{Test}2021Testing $\frac{1}{178} = \sage{n(1/178)}$.2223\section{Plotting}2425is always fun ...2627\sageplot[width=.5\textwidth]{plot(x * (1+ sin(x)), (x,-10,10))}2829\section{This is a test}3031Testing $(1-x^2)^3 = \sage{((1-x^2)^2).expand()}$.3233Using Sage\TeX, one can use Sage to compute things and put them into34your \LaTeX{} document. For example, there are35$\sage{number_of_partitions(1269)}$ integer partitions of $1269$.36You don't need to compute the number yourself, or even cut and paste37it from somewhere.3839Here's some Sage code:4041\begin{sageblock}42f(x) = cos(2*x)^2 / (2+x)43\end{sageblock}4445The first derivative of $f$ is $\sage{diff(f,x)}$.4647The second derivative of $f$ is4849\[50\frac{\mathrm{d}^{2}}{\mathrm{d}x^{2}} \sage{f(x)} =51\sage{diff(f, x, 2)(x)}.52\]5354Here's a plot of $f$ from $-1$ to $10$:5556\sageplot[width=.5\textwidth]{plot(f, -1, 10)}5758\section{AMS Math}5960$$P\left(A=2\middle|\frac{A^2}{B}>4\right)$$6162Matrix:6364\begin{equation*}65A_{m,n} =66\begin{pmatrix}67a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\68a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\69\vdots & \vdots & \ddots & \vdots \\70a_{m,1} & a_{m,2} & \cdots & a_{m,n}71\end{pmatrix}72\end{equation*}7374More here: \url{https://en.wikibooks.org/wiki/LaTeX/Mathematics}.7576\section{Pure Text}7778Usually, \verb|\sage{}| assumes that the value presented is79a mathematical formula and wraps it into \$.80Alternatively, one can display a Python-string via \verb|\sagestr{}|.8182\begin{sagesilent}83u = 1 + 184\end{sagesilent}85861+1 = \sagestr{str(u)}.8788\end{document}899091