summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/lualatex/luacas/reference
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/lualatex/luacas/reference')
-rw-r--r--Master/texmf-dist/doc/lualatex/luacas/reference/ref.tex236
-rw-r--r--Master/texmf-dist/doc/lualatex/luacas/reference/ref_algebra/ref_algebra.tex336
-rw-r--r--Master/texmf-dist/doc/lualatex/luacas/reference/ref_algebra/ref_algebra_classes/ref_algebra_classes.tex977
-rw-r--r--Master/texmf-dist/doc/lualatex/luacas/reference/ref_algebra/ref_algebra_methods/ref_algebra_methods.tex1305
-rw-r--r--Master/texmf-dist/doc/lualatex/luacas/reference/ref_calculus/ref_calculus.tex225
-rw-r--r--Master/texmf-dist/doc/lualatex/luacas/reference/ref_calculus/ref_calculus_classes/ref_calculus_classes.tex277
-rw-r--r--Master/texmf-dist/doc/lualatex/luacas/reference/ref_calculus/ref_calculus_methods/ref_calculus_methods.tex473
-rw-r--r--Master/texmf-dist/doc/lualatex/luacas/reference/ref_core/ref_core.tex249
-rw-r--r--Master/texmf-dist/doc/lualatex/luacas/reference/ref_core/ref_core_classes/ref_core_classes.tex455
-rw-r--r--Master/texmf-dist/doc/lualatex/luacas/reference/ref_core/ref_core_methods/ref_core_methods.tex1155
10 files changed, 5688 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/lualatex/luacas/reference/ref.tex b/Master/texmf-dist/doc/lualatex/luacas/reference/ref.tex
new file mode 100644
index 00000000000..426a1e17e5b
--- /dev/null
+++ b/Master/texmf-dist/doc/lualatex/luacas/reference/ref.tex
@@ -0,0 +1,236 @@
+\documentclass{article}
+
+\usepackage{luacas}
+\usepackage{amsmath}
+\usepackage{amssymb}
+
+\usepackage[margin=1in]{geometry}
+\usepackage[shortlabels]{enumitem}
+
+\usepackage{pgfplots}
+\pgfplotsset{compat=1.18}
+\usetikzlibrary{positioning,calc}
+\usepackage[edges]{forest}
+\usepackage{minted}
+\usemintedstyle{pastie}
+\usepackage[hidelinks]{hyperref}
+\usepackage{parskip}
+\usepackage{multicol}
+\usepackage[most]{tcolorbox}
+ \tcbuselibrary{xparse,documentation}
+\usepackage{microtype}
+\usepackage{makeidx}
+
+\usepackage[
+backend=biber,
+style=numeric,
+]{biblatex}
+\addbibresource{sources.bib}
+
+\definecolor{rose}{RGB}{128,0,0}
+\definecolor{roseyellow}{RGB}{222,205,99}
+\definecolor{roseblue}{RGB}{167,188,214}
+\definecolor{rosenavy}{RGB}{79,117,139}
+\definecolor{roseorange}{RGB}{232,119,34}
+\definecolor{rosegreen}{RGB}{61,68,30}
+\definecolor{rosewhite}{RGB}{223,209,167}
+\definecolor{rosebrown}{RGB}{108,87,27}
+\definecolor{rosegray}{RGB}{84,88,90}
+
+\definecolor{codegreen}{HTML}{49BE25}
+
+\newtcolorbox{codebox}[1][sidebyside]{
+ enhanced,skin=bicolor,
+ #1,
+ arc=1pt,
+ colframe=brown,
+ colback=brown!15,colbacklower=white,
+ boxrule=1pt,
+ notitle
+}
+
+\newtcolorbox{codehead}[1][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1
+}
+
+\usepackage{varwidth}
+
+\newtcolorbox{newcodehead}[2][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1,
+ fonttitle=\bfseries\ttfamily\footnotesize,
+ coltitle=rosegray,
+ attach boxed title to top text right,
+ boxed title style={frame hidden,size=small,bottom=-1mm,
+ interior style={fill=none,
+ top color=white,
+ bottom color=white}},
+ title={#2}
+}
+
+\makeindex
+
+\newcommand{\coderef}[2]{%
+\begin{codehead}[sidebyside,segmentation hidden]%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{codehead}%
+}
+
+\newcommand{\newcoderef}[3]{%
+\begin{newcodehead}[sidebyside,segmentation hidden]{#3}%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{newcodehead}%
+}
+
+\begin{document}
+\thispagestyle{empty}
+\part{Reference}
+This part contains reference material for the classes and methods that incorporate the \texttt{luacas} package. Some classes are \emph{concrete} while others are \emph{abstract}. The concrete classes are essentially the objects that a user might reasonably interact with while using \texttt{luacas}. Thankfully, most of this interaction will be filtered through a rudimentary (but functional!) parser. Abstract classes exist for the purposes of inheritance.
+
+The classes in the diagram below are color-coded according to:
+\begin{itemize}
+ \item (\tikz[baseline=-0.5ex]\node[text=rosenavy,fill=roseblue!40]{\ttfamily\bfseries Class};) {\color{rosenavy}\ttfamily\bfseries Class}: a (concrete) class belonging to the core module;
+ \item (\tikz[baseline=-0.5ex]\node[text=rose,fill=rose!30]{\ttfamily\bfseries Class};) {\color{rose}\ttfamily\bfseries Class}: a (concrete) class belonging to the algebra module;
+ \item (\tikz[baseline=-0.5ex]\node[text=roseorange,fill=roseorange!30]{\ttfamily\bfseries Class};) {\color{roseorange}\ttfamily\bfseries Class}: a (concrete) class belonging to the calculus module.
+\end{itemize}
+Inheritance is indicated with an arrow:
+
+\forestset{multiple directions/.style={for tree={#1}, phantom, for relative level=1{no edge, delay={!c.content/.pgfmath=content("!u")}, before computing xy={l=0,s=0}}},
+ multiple directions/.default={},
+ grow subtree/.style={for tree={grow=#1}},
+ grow' subtree/.style={for tree={grow'=#1}}}
+
+\begin{center}
+ \begin{forest}
+ core/.style = {draw={rosenavy,thick},
+ font={\ttfamily\bfseries\color{rosenavy}},
+ fill = roseblue!#1},
+ algebra/.style = {draw={rose,thick},
+ font={\ttfamily\bfseries\color{rose}},
+ fill = rose!#1},
+ calculus/.style = {draw={roseorange,thick},
+ font={\ttfamily\bfseries\color{roseorange}},
+ fill = roseorange!#1},
+ multiple directions,
+ for tree = {font = \ttfamily\bfseries,
+ draw,
+ rounded corners=1pt,
+ edge = {-stealth},
+ s sep = 0.2cm}
+ [Expression
+ [, grow subtree = 90
+ [AtomicExpression,
+ core = {0},
+ for tree = {grow=east,
+ child anchor=west,
+ node options={anchor=west}},
+ forked edges,
+ calign=last,
+ l sep = 0.5cm,
+ s sep = 0.2cm
+ [SymbolExpression,
+ core={50}]
+ [ConstantExpression,
+ core ={0},
+ for tree = {grow = north,
+ node options = {anchor=north}
+ }
+ [Ring,
+ algebra ={0},
+ for tree = {grow = east}
+ [EuclideanDomain,
+ algebra={0}
+ [Field,
+ algebra = {0}
+ [IntegerModN,
+ algebra={30}]
+ [Rational,
+ algebra={30}]
+ ]
+ [Integer,
+ algebra={30}]
+ ]
+ [PolynomialRing,
+ algebra={30}]
+ ]
+ ]
+ ]]
+ [, grow subtree = -90
+ [CompoundExpression,
+ core = {0},
+ for tree = {grow=east,
+ child anchor=west,
+ node options={anchor=west}},forked edges,
+ calign=last,
+ l sep = 0.5cm,
+ s sep = 0.2cm
+ [FunctionExpression,
+ core = {40}
+ [TrigExpression,algebra={30}]
+ ]
+ [BinaryOperation,
+ core = {40}]
+ [Equation,
+ algebra = {30}]
+ [Logarithm,
+ algebra={30}]
+ [FactorialExpression,
+ algebra={30}]
+ [RootExpression,
+ algebra={30}]
+ [SqrtExpression,
+ algebra={30}]
+ [AbsExpression,
+ algebra={30}]
+ [DerivativeExpression,
+ calculus={20}]
+ [DiffExpression,
+ calculus={20}]
+ [IntegralExpression,
+ calculus={20}]
+ ]]
+ ]
+ \end{forest}
+\end{center}
+Every object in \texttt{luacas} is an expression, meaning it inherits from the {\ttfamily Expression} type (class). Since the {\ttfamily Expression} type itself has no constructor and cannot be instantiated, it it closer to an interface in Java OOP terms.\footnote{In reality, interfaces are unnecessary in Lua due to its weak typing - Lua doesn't check whether an object has a method at compile time. The {\ttfamily Expression} type is really an abstract class in Java terms.} {\ttfamily Expression}s can store any number of other expressions as sub-expressions, depending on type. This means that {\ttfamily Expression} objects are really trees. Types that inherit from {\ttfamily Expression} that can not store other expressions are called \emph{atomic expressions}, and correspond to the leaf nodes of the tree. Other expression types are \emph{compound expressions}. Thus, every {\ttfamily Expression} type inherits from one of {\ttfamily AtomicExpression} or {\ttfamily CompoundExpression}. The {\ttfamily ConstantExpresssion} interface is a subinterface to {\ttfamily AtomicExpression}. Types that inherit from {\ttfamily ConstantExpression} roughly correspond to numbers (interpreted broadly).
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/lualatex/luacas/reference/ref_algebra/ref_algebra.tex b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_algebra/ref_algebra.tex
new file mode 100644
index 00000000000..0e9bd011e84
--- /dev/null
+++ b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_algebra/ref_algebra.tex
@@ -0,0 +1,336 @@
+\documentclass{article}
+
+\usepackage{luacas}
+\usepackage{amsmath}
+\usepackage{amssymb}
+
+\usepackage[margin=1in]{geometry}
+\usepackage[shortlabels]{enumitem}
+
+\usepackage{pgfplots}
+\pgfplotsset{compat=1.18}
+\usetikzlibrary{positioning,calc}
+\usepackage{forest}
+\usepackage{minted}
+\usemintedstyle{pastie}
+\usepackage[hidelinks]{hyperref}
+\usepackage{parskip}
+\usepackage{multicol}
+\usepackage[most]{tcolorbox}
+ \tcbuselibrary{xparse,documentation}
+\usepackage{microtype}
+\usepackage{makeidx}
+
+\usepackage[
+backend=biber,
+style=numeric,
+]{biblatex}
+\addbibresource{sources.bib}
+
+\definecolor{rose}{RGB}{128,0,0}
+\definecolor{roseyellow}{RGB}{222,205,99}
+\definecolor{roseblue}{RGB}{167,188,214}
+\definecolor{rosenavy}{RGB}{79,117,139}
+\definecolor{roseorange}{RGB}{232,119,34}
+\definecolor{rosegreen}{RGB}{61,68,30}
+\definecolor{rosewhite}{RGB}{223,209,167}
+\definecolor{rosebrown}{RGB}{108,87,27}
+\definecolor{rosegray}{RGB}{84,88,90}
+
+\definecolor{codegreen}{HTML}{49BE25}
+
+\newtcolorbox{codebox}[1][sidebyside]{
+ enhanced,skin=bicolor,
+ #1,
+ arc=1pt,
+ colframe=brown,
+ colback=brown!15,colbacklower=white,
+ boxrule=1pt,
+ notitle
+}
+
+\newtcolorbox{codehead}[1][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1
+}
+
+\usepackage{varwidth}
+
+\newtcolorbox{newcodehead}[2][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1,
+ fonttitle=\bfseries\ttfamily\footnotesize,
+ coltitle=rosegray,
+ attach boxed title to top text right,
+ boxed title style={frame hidden,
+ size=small,
+ bottom=-1mm,
+ interior style={fill=none,
+ top color=white,
+ bottom color=white}
+ },
+ title={#2}
+}
+
+\makeindex
+
+\newcommand{\coderef}[2]{%
+\begin{codehead}[sidebyside,segmentation hidden]%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{codehead}%
+}
+
+\newcommand{\newcoderef}[3]{%
+\begin{newcodehead}[sidebyside,segmentation hidden]{#3}%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{newcodehead}%
+}
+
+\usetikzlibrary{shapes.multipart}
+\useforestlibrary{edges}
+
+\def\error{\color{red}}
+\def\self{\color{gray}}
+\def\call{$\star$ }
+
+\begin{document}
+\thispagestyle{empty}
+
+\section{Algebra}
+ This section contains reference materials for the algebra functionality of \texttt{luacas}. The classes in this module are diagramed below according to inheritance along with the methods/functions one can call upon them.
+ \begin{itemize}
+ \item {\error\ttfamily\itshape method}: an abstract method;
+ \item {\self\ttfamily\itshape method}: a method that returns the expression unchanged;
+ \item {\ttfamily\itshape method}: method that is either unique, implements an abstract method, or overrides an abstract
+method;
+ \item {\tikz[baseline=-0.5ex]\node[fill=rose!30] {\ttfamily\bfseries Class};}: a concrete class.
+ \end{itemize}
+Here is an inhertiance diagram of the classes in the algebra module that are derived from the \texttt{AtomicExpression} branch of classes. However, not all of them are proper {\ttfamily ConstantExpression}s, so some of them override the {\ttfamily isconstant()} method. Most methods are stated, but some were omitted (because they inherit in the obvious way, they are auxiliary and not likely to be interesting to the end-user, etc).
+ \vfill
+\forestset{
+rectcore/.style = {rectangle split,
+ rectangle split parts=2,
+ draw = {rosenavy,thick},
+ rounded corners = 1pt,
+ font = \ttfamily\bfseries,
+ fill = roseblue!#1
+ },
+rectalg/.style = {rectangle split,
+ rectangle split parts=2,
+ draw = {rose,thick},
+ rounded corners = 1pt,
+ font = \ttfamily\bfseries,
+ fill = rose!#1
+ }
+}
+\forestset{
+ multiple directions/.style={
+ for tree={#1},
+ phantom,
+ for relative level=1{
+ no edge,
+ delay={
+ !c.content/.pgfmath=content("!u")},
+ before computing xy={l=0,s=0}
+ }
+ },
+ multiple directions/.default={},
+ grow subtree/.style={for tree={grow=#1}},
+ grow' subtree/.style={for tree={grow'=#1}}}
+\tikzset{
+ every two node part/.style={font=\ttfamily\itshape\footnotesize}
+}
+\begin{center}
+ \begin{forest}
+ for tree = {node options={align=left},
+ edge = {-stealth}
+ },
+ forked edges
+ [Expression\nodepart{two}$\cdots$,rectcore={0}
+ [AtomicExpression\nodepart{two}$\cdots$,rectcore={0}
+ [SymbolExpression\nodepart{two}$\cdots$,rectcore={50}]
+ [ConstantExpression\nodepart{two}$\cdots$,rectcore={0}
+ [Ring\nodepart{two}\begin{minipage}{0.45\textwidth}\begin{multicols}{3}
+ {\error :getring}\\
+ {\error :inring(ring)}\\
+ {\error :iscommutative}\\
+ {\error :add(b)}\\
+ :sub(b)\\
+ {\error :neg(b)}\\
+ {\error :mul(b)}\\
+ :pow(n)\\
+ {\error :eq(b)}\\
+ {\error :lt(b)}\\
+ {\error :le(b)}\\
+ {\error :zero()}\\
+ {\error :one()}\\
+ {\error .makering}\\
+ .resultantring
+ \end{multicols}\end{minipage}
+ ,rectalg={0}
+ [PolynomialRing\nodepart{two}
+ .makering\\
+ .R\\
+ .gcd\\
+ .extendedgcd\\
+ .resultant\\
+ .resultantmulti\\
+ .monicgcdremainders\\
+ .partialfractions\\
+ %:isatomic\\
+ :new\\
+ .mul{\textunderscore}rec\\
+ :divremainder\\
+ :psuedodivide\\
+ :isconstant\\
+ :isatomic\\
+ :freeof\\
+ :tocompoundexpression\\
+ :evaluateat\\
+ :derivative\\
+ :squarefreefactorization\\
+ :factor\\
+ :rationalroots\\
+ :roots\\
+ $\cdots$
+ ,rectalg={30}]
+ [EuclideanDomain\nodepart{two}
+ {\error :divremainder}\\
+ :iscommutative
+ ,rectalg={0}
+ [Integer\nodepart{two}
+ .gcd\\
+ .extendedgcd\\
+ .max\\
+ .min\\
+ .ceillog\\
+ .powmod\\
+ :new\\
+ :divremainder\\
+ :asnumber\\
+ :divisors\\
+ :primefactorization\\
+ :findafactor\\
+ :isprime\\
+ :abs\\
+ $\cdots$
+ ,rectalg={30}]
+ [Field\nodepart{two}
+ :div
+ ,rectalg={0}
+ [Rational\nodepart{two}
+ :new\\
+ :reduce\\
+ :isconstant\\
+ :tocompoundexpression\\
+ :asnumber\\
+ :div
+ ,rectalg={30}]
+ [IntegerModN\nodepart{two}
+ :new
+ ,rectalg={30}]
+ ]
+ ]
+ ]
+ ]
+ ]
+ ]
+ \end{forest}
+\end{center}
+\vfill
+
+\newpage
+
+Here is an inhertiance diagram of the classes in the algebra module that are derived from the \texttt{CompoundExpression} branch of classes. Again, most methods are stated, but some were omitted (because they inherit in the obvious way, they are auxiliary and not likely to be interesting to the end-user, etc).
+\vfill
+\begin{center}
+ \begin{forest}
+ for tree = {node options={align=left},
+ grow = south,
+ edge = {-stealth},
+ child anchor = west
+ },
+ forked edges
+ [Expression\nodepart{two}$\cdots$,
+ rectcore={0}
+ [CompoundExpression\nodepart{two}
+ $\cdots$,
+ rectcore={0},
+ calign = first,
+ for tree = {node options = {anchor = west},
+ grow' = east}
+ [BinaryOperation\nodepart{two}
+ $\cdots$,
+ rectcore={50}]
+ [FunctionExpression\nodepart{two}
+ $\cdots$,
+ rectcore={50}
+ [TrigExpression\nodepart{two}
+ :new
+ ,rectalg={30}]
+ ]
+ [AbsExpression\nodepart{two}
+ :new
+ ,rectalg={30}]
+ [SqrtExpression\nodepart{two}
+ :new\\
+ :topower
+ ,rectalg={30}]
+ [RootExpression\nodepart{two}
+ :new
+ ,rectalg={30}]
+ [FactorialExpression\nodepart{two}
+ :new
+ ,rectalg={30}]
+ [Logarithm\nodepart{two}
+ :new
+ ,rectalg={30}]
+ [Equation\nodepart{two}
+ :new\\
+ :solvefor()
+ ,rectalg={30}]
+ ]
+ ]
+ \end{forest}
+\end{center}
+\vfill
+\end{document}
+
diff --git a/Master/texmf-dist/doc/lualatex/luacas/reference/ref_algebra/ref_algebra_classes/ref_algebra_classes.tex b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_algebra/ref_algebra_classes/ref_algebra_classes.tex
new file mode 100644
index 00000000000..58d9b69f843
--- /dev/null
+++ b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_algebra/ref_algebra_classes/ref_algebra_classes.tex
@@ -0,0 +1,977 @@
+\documentclass{article}
+
+\usepackage{luacas}
+\usepackage{amsmath}
+\usepackage{amssymb}
+
+\usepackage[margin=1in]{geometry}
+\usepackage[shortlabels]{enumitem}
+
+\usepackage{pgfplots}
+\pgfplotsset{compat=1.18}
+\usetikzlibrary{positioning,calc}
+\usepackage{forest}
+\usepackage{minted}
+\usemintedstyle{pastie}
+\usepackage[hidelinks]{hyperref}
+\usepackage{parskip}
+\usepackage{multicol}
+\usepackage[most]{tcolorbox}
+ \tcbuselibrary{xparse,documentation}
+\usepackage{microtype}
+\usepackage{makeidx}
+\usepackage{fontawesome}
+
+\usepackage[
+backend=biber,
+style=numeric,
+]{biblatex}
+\addbibresource{sources.bib}
+
+\definecolor{rose}{RGB}{128,0,0}
+\definecolor{roseyellow}{RGB}{222,205,99}
+\definecolor{roseblue}{RGB}{167,188,214}
+\definecolor{rosenavy}{RGB}{79,117,139}
+\definecolor{roseorange}{RGB}{232,119,34}
+\definecolor{rosegreen}{RGB}{61,68,30}
+\definecolor{rosewhite}{RGB}{223,209,167}
+\definecolor{rosebrown}{RGB}{108,87,27}
+\definecolor{rosegray}{RGB}{84,88,90}
+
+\definecolor{codegreen}{HTML}{49BE25}
+
+\newtcolorbox{codebox}[1][sidebyside]{
+ enhanced,skin=bicolor,
+ #1,
+ arc=1pt,
+ colframe=brown,
+ colback=brown!15,colbacklower=white,
+ boxrule=1pt,
+ notitle
+}
+
+\newtcolorbox{codehead}[1][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1
+}
+
+\usepackage{varwidth}
+
+\newtcolorbox{newcodehead}[2][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1,
+ fonttitle=\bfseries\ttfamily\footnotesize,
+ coltitle=rosegray,
+ attach boxed title to top text right,
+ boxed title style={frame hidden,size=small,bottom=-1mm,
+ interior style={fill=none,
+ top color=white,
+ bottom color=white}},
+ title={#2}
+}
+
+\makeindex
+
+\newcommand{\coderef}[2]{%
+\begin{codehead}[sidebyside,segmentation hidden]%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{codehead}%
+}
+
+\newcommand{\newcoderef}[3]{%
+\begin{newcodehead}[sidebyside,segmentation hidden]{#3}%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{newcodehead}%
+}
+
+\begin{document}
+\setdescription{style=multiline,
+ topsep=10pt,
+ leftmargin=5cm,
+ }
+
+\subsection{Algebra Classes}
+
+The algebra package contains functionality for arbitrary-precision arithmetic, polynomial arithmetic and factoring, symbolic root finding, and logarithm and trigonometric expression classes. It requires the core package to be loaded.
+
+The abstract classes in the algebra module all inherit from the \texttt{ConstantExpression} branch in the inheritance tree:
+
+\begin{itemize}
+ \item \texttt{Ring}
+ \item \texttt{EuclideanDomain}
+ \item \texttt{Field}
+\end{itemize}
+
+The {\ttfamily EuclideanDomain} class is a sub-class to the {\ttfamily Ring} class, and the {\ttfamily Field} class is a sub-class to the {\ttfamily EuclideanDomain} class.
+
+The following concrete classes inherit from the {\ttfamily Ring} class (or one of the sub-classes mentioned above). However, not all of them are proper {\ttfamily ConstantExpression}s, so some of them override the {\ttfamily isconstant()} method.
+
+\begin{itemize}
+ \item {\ttfamily Integer}
+ \item {\ttfamily IntegerModN}
+ \item {\ttfamily Rational}
+ \item {\ttfamily PolynomialRing}
+\end{itemize}
+
+The other concrete classes in the Algebra package do not inherit from the {\ttfamily Ring} interface, instead they inherit from the {\ttfamily CompoundExpression} interface:
+
+\begin{multicols}{2}
+\begin{itemize}
+ \item {\ttfamily AbsExpression}
+ \item {\ttfamily Logarithm}
+ \item {\ttfamily FactorialExpression}
+ \item {\ttfamily SqrtExpression}
+ \item {\ttfamily TrigExpression}
+ \item {\ttfamily RootExpression}
+ \item {\ttfamily Equation}
+\end{itemize}
+\end{multicols}
+
+\newcoderef{function Integer:new(n)}{return Integer}{n number|string|Integer}
+\index{Algebra!Classes!\texttt{SymbolExpression}}
+\addcontentsline{toc}{subsubsection}{\ttfamily Integer}
+
+Takes a \texttt{string}, \texttt{number}, or {\ttfamily Integer} input and constructs an \texttt{Integer} expression. The \texttt{Integer} class allows us to perform exact arithmetic on integers. Indeed, since Lua can only store integers exactly up to a certain point, it is recommended to use strings to build large integers.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+a = Integer(-12435)
+b = Integer('-12435')
+tex.print('\\[',a:tolatex(),
+ '=',
+ b:tolatex(),
+ '\\]')
+\end{minted}
+\tcblower
+\directlua{
+ a = Integer(-12435)
+ b = Integer('-12435')
+ tex.print('\\[',a:tolatex(),
+ '=',
+ b:tolatex(),
+ '\\]')
+}
+\end{codebox}
+An {\ttfamily Integer} is a table 1-indexed by Lua numbers consisting of Lua numbers. For example:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+tex.print(tostring(b[1]))
+\end{minted}
+\tcblower
+\directlua{
+ tex.print(tostring(b[1]))
+}
+\end{codebox}
+Whereas:
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{lua}
+c = Integer('7240531360949381947528131508')
+tex.print('The first 14 digits of c:', tostring(c[1]),'. ')
+tex.print('The last 14 digits of c:', tostring([2]),'.')
+\end{minted}
+\tcblower
+\directlua{
+ c = Integer('7240531360949381947528131508')
+ tex.print('The first 14 digits of c:', tostring(c[1]),'. ')
+ tex.print('The last 14 digits of c:', tostring(c[2]),'.')
+}
+\end{codebox}
+
+The global field {\ttfamily DIGITSIZE} is set to \texttt{14} so that exact arithmetic on {\ttfamily Integer}s can be done as efficiently as possible while respecting Lua's limitations.
+
+\subsubsection*{Fields}
+{\ttfamily Integer}s have a {\ttfamily .sign} field which contains the Lua number {\ttfamily 1} or {\ttfamily -1} depending on whether \texttt{Integer} is positive or negative.
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{lua}
+tex.print('The sign of',tostring(b),'is:',tostring(b.sign))
+\end{minted}
+\tcblower
+\directlua{
+ tex.print('The sign of',
+ tostring(b),
+ 'is:',
+ tostring(b.sign))
+}
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+The contents of the environment \mintinline{latex}{\begin{CAS}..\end{CAS}} are wrapped in the argument of a function \mintinline{lua}{CASparse()} which, among other things, seeks out digit strings intended to represent integers, and wraps those in \texttt{Integer('...')}.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ c = 7240531360949381947528131508
+\end{CAS}
+\directlua{
+ tex.print(tostring(c[1]))
+}
+\end{minted}
+\tcblower
+\begin{CAS}
+ c = 7240531360949381947528131508
+\end{CAS}
+\directlua{
+ tex.print(tostring(c[1]))
+}
+\end{codebox}
+
+\newcoderef{function IntegerModN:new(i,n)}{return IntegerModN}{i Integer, n Integer}
+\index{Algebra!Classes!\texttt{IntegerModN}}
+\addcontentsline{toc}{subsubsection}{\ttfamily IntegerModN}
+
+Takes an {\ttfamily Integer i} and {\ttfamily Integer n} and constructs an element in the ring $\mathbf{Z}/n\mathbf{Z}$, the integers modulo $n$.
+
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{lua}
+i = Integer(143)
+n = Integer(57)
+a = IntegerModN(i,n)
+tex.print('\\[',i:tolatex(),'\\equiv',a:tolatex(true),'\\]')
+\end{minted}
+\tcblower
+\luaexec{
+ i = Integer(143)
+ n = Integer(57)
+ a = IntegerModN(i,n)
+ tex.print('\\[',i:tolatex(),'\\equiv',a:tolatex(true),'\\]')
+}
+\end{codebox}
+
+\subsubsection*{Fields}
+
+{\ttfamily IntegerModN}s have two fields: {\ttfamily .element} and {\ttfamily .modulus}. The reduced input \texttt{i} is stored in {\ttfamily .element} while the input \texttt{n} is stored in {\ttfamily .modulus}:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+tex.print(a.element:tolatex(),'\\newline')
+tex.print(a.modulus:tolatex())
+\end{minted}
+\tcblower
+\luaexec{
+ tex.print(a.element:tolatex(),'\\newline')
+ tex.print(a.modulus:tolatex())
+}
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+The function \texttt{Mod(,)} is a shortcut for \texttt{IntegerModN(,)}:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ i = 143
+ n = 57
+ a = Mod(i,n)
+\end{CAS}
+\[\print{i}\equiv\print{a}\bmod{\print{n}}\]
+\end{minted}
+\tcblower
+\begin{CAS}
+ i = 143
+ n = 57
+ a = Mod(i,n)
+\end{CAS}
+\[ \print{i} \equiv \print{a} \bmod{\print{n}}\]
+\end{codebox}
+
+\newcoderef{function PolynomialRing:new(coefficients, symbol, degree)}{return PolynomialRing}{coefficients table<number,Ring>, symbol string|SymbolExpression, degree Integer}
+\index{Algebra!Classes!\texttt{PolynomialRing}}
+\addcontentsline{toc}{subsubsection}{\ttfamily PolynomialRing}
+
+Takes a table of {\ttfamily coefficients}, not all necessarily in the same ring, and a {\ttfamily symbol} to create a polynomial in $\mathtt{R[x]}$ where $\mathtt{x}$ is {\ttfamily symbol} and $\mathtt{R}$ is the smallest {\ttfamily Ring} possible given the coefficients. If {\ttfamily degree} is omitted, it will calculate the degree of the polynomial automatically. The list can either be one-indexed or zero-indexed, but if it is one-indexed, the internal list of coefficients will still be zero-indexed.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = PolynomialRing({0,1/3,-1/2,1/6},'t')
+\end{CAS}
+\[ \print{f} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = PolynomialRing({0,1/3,-1/2,1/6},'t')
+\end{CAS}
+\[ \print{f} \]
+\end{codebox}
+The \texttt{PolynomialRing} class overwrites the \mintinline{lua}{isatomic()} and \mintinline{lua}{isconstant()} inheritances from the abstract class \texttt{ConstantExpression}.
+\subsubsection*{Fields}
+
+\begin{multicols}{2}
+{\ttfamily PolynomialRing}s have several fields:
+\begin{itemize}
+ \item {\ttfamily f.coefficients} stores the 0-indexed table of coefficients of {\ttfamily f};
+ \item {\ttfamily f.degree} stores the {\ttfamily Integer} that represents the degree of {\ttfamily f};
+ \item {\ttfamily f.symbol} stores the {\ttfamily string} representing the variable or {\ttfamily symbol} of {\ttfamily f}.
+ \item {\ttfamily f.ring} stores the \texttt{RingIdentifier} for the ring of coefficients.
+\end{itemize}
+
+\columnbreak
+
+\parseshrub{f}
+\bracketset{action character = @}
+\begin{center}
+\begin{forest}
+ for tree = {font = \ttfamily,
+ draw,
+ rounded corners = 1pt,
+ fill=gray!20,
+ s sep = 1.5cm,
+ l sep = 2cm}
+ @\shrubresult
+\end{forest}
+\end{center}
+\end{multicols}
+For example:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+for i=0,f.degree:asnumber() do
+ tex.print('\\[',
+ f.coefficients[i]:tolatex(),
+ f.symbol,
+ '^{',
+ tostring(i),
+ '}\\]')
+end
+if f.ring == Rational.getring() then
+ tex.print('Rational coefficients')
+end
+\end{minted}
+\tcblower
+\luaexec{
+for i=0,f.degree:asnumber() do
+ tex.print(
+ '\\[',
+ f.coefficients[i]:tolatex(),
+ f.symbol,
+ '^{',
+ tostring(i),
+ '}\\]'
+ )
+ end
+ if f.ring == Rational.getring() then
+ tex.print('Rational coefficients')
+ end
+}
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+The function \mintinline{lua}{Poly()} is a shortcut for \mintinline{lua}{PolynomialRing:new()}. If the second argument \texttt{symbol} is omitted, then the default is \texttt{'x'}:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = Poly({0,1/3,-1/2,1/6})
+\end{CAS}
+\[ \print{f} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = Poly({0,1/3,-1/2,1/6})
+\end{CAS}
+\[ \print{f} \]
+\end{codebox}
+
+Alternatively, one could typeset the polynomial naturally and use the \texttt{topoly()} function. This is the same as the \texttt{topolynomial()} method except that the \texttt{autosimplify()} method is automatically called first:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = 1/3*x - 1/2*x^2 + 1/6*x^3
+ f = topoly(f)
+\end{CAS}
+\[ \print{f} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = 1/3*x - 1/2*x^2 + 1/6*x^3
+ f = topoly(f)
+\end{CAS}
+\[ \print{f} \]
+\end{codebox}
+
+\newcoderef{function Rational:new(n,d,keep)}{return Rational}{n Ring, d Ring, keep bool}
+\index{Algebra!Classes!\texttt{Rational}}
+\addcontentsline{toc}{subsubsection}{\ttfamily Rational}
+
+Takes a numerator {\ttfamily n} and denominator {\ttfamily d} in the same {\ttfamily Ring} and constructs a rational expression in the field of fractions over that ring. For the integers, this is the ring of rational numbers. If the {\ttfamily keep} flag is omitted, the constructed object will be simplified to have smallest possible denominator, possibly returning an object in the original {\ttfamily Ring}. Typically, the {\ttfamily Ring} will be either {\ttfamily Integer} or {\ttfamily PolynomialRing}, so {\ttfamily Rational} can be viewed as a constructor for either a rational number or a rational function.
+
+For example:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+a = Integer(6)
+b = Integer(10)
+c = Rational(a,b)
+tex.print('\\[',c:tolatex(),'\\]')
+\end{minted}
+\tcblower
+\luaexec{
+ a = Integer(6)
+ b = Integer(10)
+ c = Rational(a,b)
+ tex.print('\\[',c:tolatex(),'\\]')
+}
+\end{codebox}
+But also:
+\begin{codebox}
+ \begin{minted}{lua}
+a = Poly({Integer(2),Integer(3)})
+b = Poly({Integer(4),Integer(1)})
+c = Rational(a,b)
+tex.print('\\[',c:tolatex(),'\\]')
+\end{minted}
+\tcblower
+\luaexec{
+a = Poly({Integer(2),Integer(3)})
+b = Poly({Integer(4),Integer(1)})
+c = Rational(a,b)
+tex.print('\\[',c:tolatex(),'\\]')
+}
+\end{codebox}
+
+\subsubsection*{Fields}
+
+\texttt{Rational}s naturally have the two fields: \texttt{numerator}, \texttt{denominator}. These fields store precisely what you think. \texttt{Rational}s also have a \texttt{ring} field which stores the \texttt{RingIdentifier} to which the numerator and denominator belong. (This is $\mathbb{Z}$ for the rational numbers.)
+
+If \texttt{numerator} or \texttt{denominator} are \texttt{PolynomialRing}s, then the constructed \texttt{Rational} will have an additional field: \texttt{symbol}. This stores the symbol the polynomial rings are constructed over.
+
+\begin{codebox}[]
+ \begin{minted}{lua}
+if c.ring == PolynomialRing.getring() then
+ tex.print('$',c:tolatex(),'$ is a Rational Function in the variable',c.symbol)
+end
+\end{minted}
+\tcblower
+\luaexec{
+if c.ring == PolynomialRing.getring() then
+ tex.print('$',c:tolatex(),'$ is a Rational Function in the variable',c.symbol)
+end
+}
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+\texttt{Raional}s are constructed naturally using the \texttt{/} operator:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = Poly({2,3})
+ b = Poly({4,1})
+ c = a/b
+\end{CAS}
+\[ \print{c} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = Poly({2,3})
+ b = Poly({4,1})
+ c = a/b
+\end{CAS}
+\[ \print{c} \]
+\end{codebox}
+
+\coderef{function AbsExpression:new(expression)}{return AbsExpression}
+\addcontentsline{toc}{subsubsection}{\ttfamily AbsExpression}
+
+Creates a new absolute value expression with the given expression.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = Poly({1,1})
+ g = Poly({-1,1})
+ h = AbsExpression(f/g)
+\end{CAS}
+\[ h = \print{h} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = Poly({1,1})
+ g = Poly({-1,1})
+ h = AbsExpression(f/g)
+\end{CAS}
+\[ h = \print{h} \]
+\end{codebox}
+
+\subsubsection*{Fields}
+
+\texttt{AbsExpression}s have only one field: \texttt{.expression}. This field simply holds the \texttt{Expression} inside the absolute value:
+\begin{multicols}{2}
+\begin{codebox}[]
+\begin{minted}[fontsize=\small]{lua}
+tex.print('\\[',
+ h.expression:tolatex(),
+ '\\]')
+\end{minted}
+\tcblower
+\directlua{
+ tex.print('\\[',h.expression:tolatex(),'\\]')
+}
+\end{codebox}
+\parseshrub{h}
+\bracketset{action character = @}
+\begin{center}
+\begin{forest}
+ for tree = {font=\ttfamily,
+ draw,
+ rounded corners=1pt,
+ fill=gray!20,
+ l sep =1.5cm}
+ @\shrubresult
+\end{forest}
+\end{center}
+\end{multicols}
+
+\subsubsection*{Parsing}
+
+The function \mintinline{lua}{abs()} is a shortcut to \mintinline{lua}{AbsExpression:new()}. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = Poly({1,1})
+ g = Poly({-1,1})
+ h = abs(f/g)
+\end{CAS}
+\[ h = \print{h} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = Poly({1,1})
+ g = Poly({-1,1})
+ h = abs(f/g)
+\end{CAS}
+\[ h = \print{h} \]
+\end{codebox}
+
+\newcoderef{function Logarithm:new(base,arg)}{return Logarithm}{base Expression, arg Expression}
+\addcontentsline{toc}{subsubsection}{\ttfamily Logarithm}
+
+Creates a new \texttt{Logarithm} expression with the given \texttt{base} and \texttt{arg}ument. Some basic simplification rules are known to \texttt{autosimplify()}:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('b','x','y')
+ f = Logarithm(b,x^y)
+\end{CAS}
+\[ \print{f} = \print*{f} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('b','x','y')
+ f = Logarithm(b,x^y)
+\end{CAS}
+\[ \print{f} = \print*{f} \]
+\end{codebox}
+
+\subsubsection*{Fields}
+
+\begin{multicols}{2}
+\texttt{Logarithm}s have two fields: \texttt{base} and \texttt{expression}; \texttt{base} naturally stores the base of the logarithm (i.e., the first argument of \texttt{Logarithm}) while \texttt{expression} stores the argument of the logarithm (i.e., the second argument of \texttt{Logarithm}).
+
+\begin{center}
+ \parseshrub{f}
+ \bracketset{action character = @}
+ \begin{forest}
+ for tree = {font = \ttfamily,
+ draw,
+ rounded corners=1pt,
+ fill = gray!20,
+ s sep = 1.5cm}
+ @\shrubresult
+ \end{forest}
+\end{center}
+\end{multicols}
+
+\subsubsection*{Parsing}
+
+The function \mintinline{lua}{log()} is a shortcut to \texttt{Logarithm}:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('b')
+ f = log(b,b)
+\end{CAS}
+\[ \print{f} = \print*{f} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('b')
+ f = log(b,b)
+\end{CAS}
+\[ \print{f} = \print*{f} \]
+\end{codebox}
+
+There is also a \mintinline{lua}{ln()} function to shortcut \texttt{Logarithm} where the base is \texttt{e}, the natural exponent.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = ln(e)
+\end{CAS}
+\[ \print{f} = \print*{f} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = ln(e)
+\end{CAS}
+\[ \print{f} = \print*{f} \]
+\end{codebox}
+
+\newcoderef{function FactorialExpression:new(expression)}{return FactorialExpression}{expression Expression}
+\addcontentsline{toc}{subsubsection}{\ttfamily FactorialExpression}
+
+Creates a new \texttt{FactorialExpression} with the given \texttt{expression}. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = FactorialExpression(5)
+\end{CAS}
+\[ \print{a} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = FactorialExpression(5)
+\end{CAS}
+\[ \print{a} \]
+\end{codebox}
+The \texttt{evaluate()} method will compute factorials of nonnegative \texttt{Integer}s:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = FactorialExpression(5)
+\end{CAS}
+\[ \print{a} = \print{a:evaluate()} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = FactorialExpression(5)
+\end{CAS}
+\[ \print{a} = \print{a:evaluate()} \]
+\end{codebox}
+
+\subsubsection*{Fields}
+
+\texttt{FactorialExpression}s have only one field: \texttt{expression}. This field stores the argument of \texttt{FactorialExpression()}.
+
+\subsubsection*{Parsing}
+
+The function \mintinline{lua}{factorial()} is a shortcut to \texttt{FactorialExpression()}:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = factorial(5)
+\end{CAS}
+\[ \print{a} = \print{a:evaluate()} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = factorial(5)
+\end{CAS}
+\[ \print{a} = \print{a:evaluate()} \]
+\end{codebox}
+
+\newcoderef{function SqrtExpression:new(expression, root)}{return SqrtExpression}{expression Expression, root Integer}
+\addcontentsline{toc}{subsubsection}{\ttfamily SqrtExpression}
+
+Creates a new \texttt{SqrtExpression} with the given \texttt{expression} and \texttt{root}. Typically, \texttt{expression} is an \texttt{Integer} or \texttt{Rational}, and \texttt{SqrtExpression} is intended to represent a positive real number. If \texttt{root} is omitted, then \texttt{root} defaults to \mintinline{lua}{Integer(2)}. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+a = SqrtExpression(Integer(8))
+b = SqrtExpression(Integer(8),Integer(3))
+c = a+b
+tex.print('\\[',c:tolatex(),'\\]')
+\end{minted}
+\tcblower
+\directlua{
+ a = SqrtExpression(Integer(8))
+b = SqrtExpression(Integer(8),Integer(3))
+c = a+b
+tex.print('\\[',c:tolatex(),'\\]')
+}
+\end{codebox}
+When \texttt{expression} and \texttt{root} are of the \texttt{Integer} or \texttt{Rational} types, then \texttt{autosimplify()} does a couple things. For example, with \texttt{a,b} as above, we get:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+c = c:autosimplify()
+tex.print('\\[',c:tolatex(),'\\]')
+\end{minted}
+\tcblower
+\directlua{
+c = c:autosimplify()
+tex.print('\\[',c:tolatex(),'\\]')
+}
+\end{codebox}
+On the other hand, if \texttt{root} or \texttt{expression} are not constants, then typically \mintinline{lua}{autosimplify()} will convert \texttt{SqrtExpression} to the appropriate \texttt{BinaryOperation}. For example:
+
+\directlua{
+ vars('x')
+ a = SqrtExpression(x,Integer(3))
+ b = a:autosimplify()
+}
+
+\begin{multicols}{2}
+ \begin{center}
+ \underline{Tree for \texttt{a}}
+
+\parseshrub{a}
+\bracketset{action character = @}
+\begin{forest}
+ for tree = {s sep=2cm,
+ font=\ttfamily,
+ draw,
+ rounded corners = 1pt,
+ fill=gray!20}
+ @\shrubresult
+\end{forest}
+
+ \underline{Tree for \texttt{a:autosimplify()}}
+
+\parseshrub{a:autosimplify()}
+\bracketset{action character = @}
+\begin{forest}
+ for tree = {s sep=2cm,
+ font=\ttfamily}
+ @\shrubresult
+\end{forest}
+\end{center}
+\end{multicols}
+
+\subsubsection*{Parsing}
+
+The function \mintinline{lua}{sqrt()} shortcuts \texttt{SqrtExpression()}:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = sqrt(1/9)
+ b = sqrt(27/16,3)
+ c = a+b
+\end{CAS}
+\[ \print{c} = \print*{c} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = sqrt(1/9)
+ b = sqrt(27/16,3)
+ c = a+b
+\end{CAS}
+\[ \print{c} = \print*{c} \]
+\end{codebox}
+
+\newcoderef{function TrigExpression:new(name,expression)}{return TrigExpression}{name string|SymbolExpression, expression Expression}
+\addcontentsline{toc}{subsubsection}{\ttfamily TrigExpression}
+
+Creates a new trig expression with the given \texttt{name} and \texttt{expression}. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+vars('x')
+f = TrigExpression('sin',x)
+tex.print('\\[',f:tolatex(),'\\]')
+\end{minted}
+\tcblower
+\directlua{
+ vars('x')
+ f = TrigExpression('sin',x)
+ tex.print('\\[',f:tolatex(),'\\]')
+}
+\end{codebox}
+
+\subsubsection*{Fields}
+
+\begin{multicols}{2}
+
+\texttt{TrigExpression}s have many fields:
+\begin{itemize}
+ \item \mintinline{lua}{TrigExpression.name} stores the string \texttt{name}, i.e. the first argument of \mintinline{lua}{TrigExpression()};
+ \item \mintinline{lua}{TrigExpression.expression} stores the \texttt{Expression} \texttt{expression}, i.e. the second argument of \mintinline{lua}{TrigExpression()};
+ \item and all fields inherited from \texttt{FunctionExpression} (e.g. \mintinline{lua}{TrigExpression.derivatives} which defaults to \mintinline{lua}{Integer.zero()}).
+\end{itemize}
+
+\columnbreak
+
+\begin{center}
+\parseshrub{f}
+\bracketset{action character = @}
+\begin{forest}
+ for tree = {font = \ttfamily,
+ draw,
+ rounded corners = 1pt,
+ fill = gray!20,
+ l sep = 2cm}
+ @\shrubresult
+\end{forest}
+\end{center}
+\end{multicols}
+
+\subsubsection*{Parsing}
+
+The usual trigonometric functions have the anticipated shortcut names. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = arctan(x^2)
+\end{CAS}
+\[ \print{f} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = arctan(x^2)
+\end{CAS}
+\[ \print{f} \]
+\end{codebox}
+
+\newcoderef{function RootExpression:new(expression)}{return RootExpression}{expression Expression}
+\addcontentsline{toc}{subsubsection}{\ttfamily RootExpression}
+
+Creates a new \texttt{RootExpression} with the given \texttt{expression}. The method \mintinline{lua}{RootExpression:autosimplify()} attempts to return a list of zeros of \texttt{expression}. If no such set can be found, then
+
+\mintinline{lua}{RootExpression(expression:autosimplify())}
+
+is returned instead. At the moment, \texttt{expression} must be a univariate polynomial of degree $0,1,2$ or $3$ in order for the \texttt{autosimplify()} method to return anything interesting. Of course, \texttt{luacas} can find roots of higher degree polynomials, but this involves more machinery/methods within the \texttt{PolynomialRing} class.
+
+\subsubsection*{Fields}
+\texttt{RootExpression}s have only one field: \texttt{.expression}. For example:
+\begin{multicols}{2}
+ \begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = Poly({3,2,1})
+ r = RootExpression(f)
+\end{CAS}
+\[ \print{r} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = Poly({3,2,1})
+ r = RootExpression(f)
+\end{CAS}
+\[ \print{r} \]
+\end{codebox}
+
+\begin{center}
+\parseshrub{r}
+\bracketset{action character = @}
+\begin{forest}
+ for tree = {font = \ttfamily,
+ draw,
+ rounded corners=1pt,
+ fill=gray!20,
+ l sep = 2cm}
+ @\shrubresult
+\end{forest}
+\end{center}
+\end{multicols}
+
+\subsubsection*{Parsing}
+
+The function \mintinline{lua}{roots()} essentially shortcuts \texttt{RootExpression()}, but when \texttt{expression} is of the \texttt{PolynomialRing}-type, then \texttt{PolynomialRing:roots()} is returned.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ r = roots(f)
+\end{CAS}
+\[ \print{r[1]} \qquad \print{r[2]} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ r = roots(f)
+\end{CAS}
+\[ \print{r[1]} \qquad \print{r[2]} \]
+\end{codebox}
+
+
+\newcoderef{function Equation:new(lhs, rhs)}{return Equation}{lhs Expression, rhs Expression}
+\addcontentsline{toc}{subsubsection}{\ttfamily Equation}
+
+Creates a new \texttt{Equation} expression with the given \texttt{lhs} (left hand side) and \texttt{rhs} (right hand side). If both sides of the equation are constants, or structurally identical, \texttt{autosimplify()} will return a boolean:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x','y')
+ f = Equation(sin(x-y),sin(x-y))
+ g = f:autosimplify()
+\end{CAS}
+\[ \print{f} \to \print{g} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x','y')
+ f = Equation(sin(x-y),sin(x-y))
+ g = f:autosimplify()
+\end{CAS}
+\[ \print{f} \to true \]
+\end{codebox}
+
+\subsubsection*{Fields}
+
+\begin{multicols}{2}
+\texttt{Equation}s have two fields: \texttt{lhs} and \texttt{rhs}; which store the expressions on the left and right sides of the equation.
+
+\begin{center}
+ \parseshrub{f}
+ \bracketset{action character = @}
+ \begin{forest}
+ for tree = {font = \ttfamily,
+ draw,
+ rounded corners=1pt,
+ fill = gray!20,
+ s sep = 1.5cm}
+ @\shrubresult
+ \end{forest}
+\end{center}
+\end{multicols}
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/lualatex/luacas/reference/ref_algebra/ref_algebra_methods/ref_algebra_methods.tex b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_algebra/ref_algebra_methods/ref_algebra_methods.tex
new file mode 100644
index 00000000000..b576cdc1a39
--- /dev/null
+++ b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_algebra/ref_algebra_methods/ref_algebra_methods.tex
@@ -0,0 +1,1305 @@
+\documentclass{article}
+
+\usepackage{luacas}
+\usepackage{amsmath}
+\usepackage{amssymb}
+
+\usepackage[margin=1in]{geometry}
+\usepackage[shortlabels]{enumitem}
+
+\usepackage{pgfplots}
+\pgfplotsset{compat=1.18}
+\usetikzlibrary{positioning,calc}
+\usepackage{forest}
+\usepackage{minted}
+\usemintedstyle{pastie}
+\usepackage[hidelinks]{hyperref}
+\usepackage{parskip}
+\usepackage{multicol}
+\usepackage[most]{tcolorbox}
+ \tcbuselibrary{xparse,documentation}
+\usepackage{microtype}
+\usepackage{makeidx}
+\usepackage{fontawesome5}
+
+\usepackage[
+backend=biber,
+style=numeric,
+]{biblatex}
+\addbibresource{sources.bib}
+
+\definecolor{rose}{RGB}{128,0,0}
+\definecolor{roseyellow}{RGB}{222,205,99}
+\definecolor{roseblue}{RGB}{167,188,214}
+\definecolor{rosenavy}{RGB}{79,117,139}
+\definecolor{roseorange}{RGB}{232,119,34}
+\definecolor{rosegreen}{RGB}{61,68,30}
+\definecolor{rosewhite}{RGB}{223,209,167}
+\definecolor{rosebrown}{RGB}{108,87,27}
+\definecolor{rosegray}{RGB}{84,88,90}
+
+\definecolor{codegreen}{HTML}{49BE25}
+
+\newtcolorbox{codebox}[1][sidebyside]{
+ enhanced,skin=bicolor,
+ #1,
+ arc=1pt,
+ colframe=brown,
+ colback=brown!15,colbacklower=white,
+ boxrule=1pt,
+ notitle
+}
+
+\newtcolorbox{codehead}[1][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1
+}
+
+\DeclareTotalTCBox{\lilcoderef}{O{} m m}{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ enhanced,
+ nobeforeafter,
+ tcbox raise base,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=1mm,
+ right=1mm,
+ top=1mm,
+ bottom=1mm,
+ oversize,
+ #1
+}{\mintinline{lua}{#2} \mintinline{lua}{#3}}
+
+\usepackage{varwidth}
+
+\newtcolorbox{newcodehead}[2][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1,
+ fonttitle=\bfseries\ttfamily\footnotesize,
+ coltitle=rosegray,
+ attach boxed title to top text right,
+ boxed title style={frame hidden,size=small,bottom=-1mm,
+ interior style={fill=none,
+ top color=white,
+ bottom color=white}},
+ title={#2}
+}
+
+\makeindex
+
+\newcommand{\coderef}[2]{%
+\begin{codehead}[sidebyside,segmentation hidden]%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{codehead}%
+}
+
+\newcommand{\newcoderef}[3]{%
+\begin{newcodehead}[sidebyside,segmentation hidden]{#3}%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{newcodehead}%
+}
+\usepackage{marginnote}
+
+\begin{document}
+\setdescription{style=multiline,
+ topsep=10pt,
+ leftmargin=6.5cm,
+ }
+
+\subsection{Algebra Methods}
+
+Many classes in the algebra package inherit from the {\ttfamily Ring} interface. The {\ttfamily Ring} interface requires the following arithmetic operations, which have corresponding abstract metamethods listed below. Of course, these abstract methods get passed to the appropriate concrete methods in the concrete classes that inherit from {\ttfamily Ring}.
+
+For {\ttfamily Ring} objects {\ttfamily a} and {\ttfamily b}:
+
+\SetLabelAlign{parright}{\parbox[t]{\labelwidth}{\raggedleft#1}}
+\begin{description}%[labelwidth = 6.5cm,align=parright]
+ \item[\lilcoderef{function a:add(b)}{return a + b}] Adds two ring elements.
+ \item[\lilcoderef{function a:sub(b)}{return a - b}] Subtracts one ring element from another. Subtraction has a default implementation in {\ttfamily Ring.lua} as adding the additive inverse, but this can be overwritten if a faster performance method is available.
+ \item[\lilcoderef{function a:neg()}{return -a}] Returns the additive inverse of a ring element.
+ \item[\lilcoderef{function a:mul(b)}{return a * b}] Multiplies two ring elements.
+ \item[\lilcoderef{function a:pow(n)}{return a ^ n}] Raises one ring element to the power of an integer. Exponentiation has a default implementation as repeated multiplication, but this can (and probably should) be overwritten for faster performance.
+ \item[\lilcoderef{function a:eq(b)}{return a == b}] Tests if two ring elements are the same.
+ \item[\lilcoderef{function a:lt(b)}{return a < b}] Tests if one ring element is less than another under some total order. If the ring does not have a natural total order, this method does not need to be implemented.
+ \item[\lilcoderef{function a:le(b)}{return a <= b}] Tests if one ring element is less than or equal to another under some total order. If the ring does not have a natural total order, this method does not need to be implemented.
+ \item[\lilcoderef{function a:zero()}{return Ring}] Returns the additive identity of the ring to which \texttt{a} belongs.
+ \item[\lilcoderef{function a:one()}{return Ring}] Returns the multiplicative identity of the ring to which \texttt{a} belongs.
+\end{description}
+
+\reversemarginpar
+Arithmetic\marginnote{\color{rose}\large\faHandPointRight} of {\ttfamily Ring} elements will (generally) not form a {\ttfamily BinaryOperation}. Instead, the appropriate \mintinline{lua}{__RingOperation} is called which then passes the arithmetic to a specific ring, if possible. For example:
+\begin{codebox}
+ \begin{minted}[breaklines,fontsize=\small]{latex}
+\begin{CAS}
+ f = Poly({2,1})
+ g = Poly({2,5})
+ h = f+g
+\end{CAS}
+\[ (\print{f}) + (\print{g}) = \print{h} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = Poly({2,1})
+ g = Poly({2,5})
+ h = f+g
+\end{CAS}
+\[ (\print{f}) + (\print{g}) = \print{h} \]
+\end{codebox}
+So why have the {\ttfamily Ring} class to begin with? Many of the rings in the algebra package are subsets of one another. For instance, integers are subsets of rationals, which are subsets of polynomial rings over the rationals, etc. To smoothly convert objects from one ring to another, it's good to have a class like {\ttfamily Ring} to handle all the ``traffic.''
+
+For example, the {\ttfamily RingIdentifier} object acts as a pseudo-class that stores information about the exact ring of an object, including the symbol the ring has if it's a polynomial ring. To perform operations on two elements of different rings, the CAS does the following:
+
+To get the generic {\ttfamily RingIdentifier} from a class, it uses the static method:
+\coderef{function Ring.makering()}{return RingIdentifier}
+
+To get the {\ttfamily RingIdentifier} from a specific instance (element) of a ring, it uses the method:
+
+\coderef{function Ring:getring()}{return RingIdentifier}
+
+So, for example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+a = Integer(2)/Integer(3)
+ring = a:getring()
+if ring == Integer.makering() then
+ tex.print('same rings')
+else
+ tex.print('different rings')
+end
+\end{minted}
+\tcblower
+\luaexec{
+a = Integer(2)/Integer(3)
+ring = a:getring()
+if ring == Integer.makering() then
+ tex.print('same rings')
+else
+ tex.print('different rings')
+end
+}
+\end{codebox}
+
+From there, the CAS computes the smallest {\ttfamily RingIdentifier} that contains the two {\ttfamily RingIdentifier}s as subsets using the static method:
+
+\newcoderef{function Ring.resultantring(ring1,ring2)}{return RingIdentifier}{ring1 RingIdentifier, ring2 RingIdentifier}
+
+So, for example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+a = Poly({Integer(2),Integer(1)})
+b = Integer(3)
+ring1 = a:getring()
+ring2 = b:getring()
+ring = Ring.resultantring(ring1,ring2)
+if ring == a:getring() then
+ tex.print('polynomial ring')
+end
+\end{minted}
+\tcblower
+\luaexec{
+ a = Poly({Integer(2),Integer(1)})
+ b = Integer(3)
+ ring1 = a:getring()
+ ring2 = b:getring()
+ ring = Ring.resultantring(ring1,ring2)
+ if ring == a:getring() then
+ tex.print('polynomial ring')
+ end
+}
+\end{codebox}
+
+Finally, the CAS converts both objects into the resultant {\ttfamily RingIdentifier}, if possible, using the method:
+
+\coderef{function Ring:inring(ring)}{return Ring}
+
+So, for example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+b = b:inring(ring)
+if b:type() == PolynomialRing then
+ tex.print('b is a polynomial now')
+end
+\end{minted}
+\tcblower
+\luaexec{
+ b = b:inring(ring)
+ if b:type() == PolynomialRing then
+ tex.print('b is a polynomial now')
+ end
+}
+\end{codebox}
+
+Finally, the CAS is able to perform the operation with the correct \mintinline{lua}{__RingOperation}. This all happens within the hierarchy of \texttt{Ring} classes automatically:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = Poly({1/2,3,1})
+ b = 1/2
+ c = a+b
+\end{CAS}
+\[ \print{a} + \print{b} = \print{c} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = Poly({1/2,3,1})
+ b = 2/3
+ c = a+b
+\end{CAS}
+\[ \print{a} + \print{b} = \print{c} \]
+\end{codebox}
+
+
+To add another class that implements {\ttfamily Ring} and has proper conversion abilities, the {\ttfamily resultantring} method needs to be updated to include all possible resultant rings constructed from the new ring and existing rings. The other three methods need to be implemented as well.
+
+\hrulefill
+
+We now discuss the more arithmetic methods included in the algebra package beginning with the \texttt{PolynomialRing} class.
+
+\coderef{function PolynomialRing:decompose()}{return table<number, PolynomialRing}
+\addcontentsline{toc}{subsubsection}{\ttfamily PolynomialRing:decompose}
+
+Returns a list of polynomials that form a complete decomposition of the given polynomial. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = Poly({5,-4,5,-2,1})
+ d = f:decompose()
+\end{CAS}
+\[ \left\{ \lprint{d} \right\} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = Poly({5,-4,5,-2,1})
+ d = f:decompose()
+\end{CAS}
+\[ \left\{ \lprint{d} \right\} \]
+\end{codebox}
+In particular, the code:
+\begin{minted}{lua}
+g = d[2]:evaluateat(d[1])
+tex.print('\\[', g:tolatex(), '\\]')
+\end{minted}
+recovers $f$:
+\luaexec{
+ g = d[2]:evaluateat(d[1])
+ tex.print('\\[', g:tolatex(), '\\]')
+}
+
+
+
+\coderef{function PolynomialRing:derivative()}{return PolynomialRing}
+\addcontentsline{toc}{subsubsection}{\ttfamily PolynomialRing:derivative}
+
+Returns the formal derivative of the given polynomial. For example:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = Poly({1,1,1/2,1/6})
+ g = f:derivative()
+\end{CAS}
+\[ \print{f} \xrightarrow{d/dx}
+ \print{g} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = Poly({1,1,1/2,1/6})
+ g = f:derivative()
+\end{CAS}
+\[ \print{f} \xrightarrow{d/dx}
+ \print{g} \]
+\end{codebox}
+
+\coderef{function PolynomialRing:divisors()}{return table<number, PolynomialRing>}
+\addcontentsline{toc}{subsubsection}{\ttfamily PolynomialRing:divisors}
+
+Returns a list of all monic divisors of positive degree of the polynomial, assuming the polynomial ring is a Euclidean Domain. For example:
+
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = topoly(x^4 - 2*x^3 - x + 2)
+ d = f:divisors()
+\end{CAS}
+\[ \left\{ \lprint{d} \right\} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = topoly(x^4 - 2*x^3 - x + 2)
+ d = f:divisors()
+\end{CAS}
+\[ \left\{ \lprint{d} \right\} \]
+\end{codebox}
+
+\newcoderef{function PolynomialRing:divremainder(poly1)}{return poly2,poly3}{poly1 PolynomialRing,..., poly3 PolynomialRing}
+\addcontentsline{toc}{subsubsection}{\ttfamily PolynomialRing:divremainder}
+
+Uses synthetic division to return the quotient (\texttt{poly2}) and remainder (\texttt{poly3}) of \texttt{self/poly1}. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = Poly({2,2,1})
+ g = Poly({1,1})
+ q,r = f:divremainder(g)
+\end{CAS}
+\[ \print{f} = (\print{g})(\print{q})
+ + \print{r} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = Poly({2,2,1})
+ g = Poly({1,1})
+ q,r = f:divremainder(g)
+\end{CAS}
+\[ \print{f} = (\print{g})(\print{q})
+ + \print{r} \]
+\end{codebox}
+
+\newcoderef{function PolynomialRing.extendedgcd(poly1,poly2)}{return poly3, poly4, poly5}{poly1 PolynomialRing, poly2 PolynomialRing, ..., poly5 PolynomialRing}
+\addcontentsline{toc}{subsubsection}{\ttfamily PolynomialRing:extendedgcd}
+
+Given two \texttt{PolynomialRing} elements \texttt{poly1,poly2} returns:
+\begin{itemize}
+ \item \texttt{poly3}: the gcd of \texttt{poly1,poly2};
+ \item \texttt{poly4,poly5}: the coefficients from Bezout's lemma via the extended gcd.
+\end{itemize}
+For example:
+
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = topoly((x-1)*(x-2)*(x-3))
+ g = topoly((x-1)*(x+2)*(x+3))
+ h,a,b = PolynomialRing.extendedgcd(f,g)
+\end{CAS}
+\[ \print{f*a+g*b} = (\print{f})\left( \print{a} \right) +
+ (\print{g})\left(\print{b} \right)\]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = topoly((x-1)*(x-2)*(x-3))
+ g = topoly((x-1)*(x+2)*(x+3))
+ h,a,b = PolynomialRing.extendedgcd(f,g)
+\end{CAS}
+\[ \print{f*a+g*b} = (\print{f})\left( \print{a} \right) +
+ (\print{g})\left(\print{b} \right)\]
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+The function \texttt{gcdext()} is a shortcut to \texttt{Polynomial.extendedgcd()}:
+
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = topoly((x+2)*(x-3))
+ g = topoly((x+4)*(x-3))
+ h,a,b = gcdext(f,g)
+\end{CAS}
+\[ \print{h} = (\print{f}) \left( \print{a} \right) +
+ (\print{g})\left( \print{b} \right). \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = topoly((x+2)*(x-3))
+ g = topoly((x+4)*(x-3))
+ h,a,b = gcdext(f,g)
+\end{CAS}
+\[ \print{h} = (\print{f}) \left( \print{a} \right) + (\print{g})\left( \print{b} \right). \]
+\end{codebox}
+
+\coderef{function PolynomialRing:evaluateat(Expression)}{return Expression}
+\addcontentsline{toc}{subsubsection}{\ttfamily PolynomialRing:evaluateat}
+
+Uses Horner's rule to evaluate a polynomial at \texttt{Expression}. Typically, the input \texttt{Expression} is an \texttt{Integer} or \texttt{Rational}. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = Poly({2,2,1})
+ p = f:evaluateat(1/2)
+\end{CAS}
+\[ \left. \print{f} \right|_{x=1/2}
+ = \print{p} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = Poly({2,2,1})
+ p = f:evaluateat(1/2)
+\end{CAS}
+\[ \left. \print{f} \right|_{x=1/2}
+ = \print{p} \]
+\end{codebox}
+
+\coderef{function PolynomialRing:factor()}{return BinaryOperation}
+\addcontentsline{toc}{subsubsection}{\ttfamily PolynomialRing:factor}
+
+Factors the given polynomial into irreducible terms over the polynomial ring to which the coefficients belong. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = Poly({8,24,32,24,10,2})
+ a = f:factor()
+\end{CAS}
+\[ \print{a} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = Poly({8,24,32,24,10,2})
+ a = f:factor()
+\end{CAS}
+\[ \print{a} \]
+\end{codebox}
+
+On the other hand:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = Poly({Mod(1,5),Mod(0,5),Mod(1,5)})
+ a = f:factor()
+\end{CAS}
+\[ \print{a} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = Poly({Mod(1,5),Mod(0,5),Mod(1,5)})
+ a = f:factor()
+\end{CAS}
+\[ \print{a} \]
+\end{codebox}
+
+The syntax \mintinline{lua}{f = Poly({Mod(1,5),Mod(0,5),Mod(1,5)})} is awkward. Alternatively, one can use the following instead:
+\begin{codebox}
+ \begin{minted}{latex}
+\begin{CAS}
+ f = Mod(Poly({1,0,1}),5)
+ a = f:factor()
+\end{CAS}
+\[ \print{f} = \print{a} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = Mod(Poly({1,0,1}),5)
+ a = f:factor()
+\end{CAS}
+\[ \print{f} = \print{a} \]
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+The function \mintinline{lua}{factor()} shortcuts \mintinline{lua}{PolynomialRing:factor()}. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = Poly({8,24,32,24,10,2})
+ a = factor(f)
+\end{CAS}
+\[ \print{a} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = Poly({8,24,32,24,10,2})
+ a = factor(f)
+\end{CAS}
+\[ \print{a} \]
+\end{codebox}
+
+\newcoderef{function PolynomialRing:freeof(symbol)}{return bool}{symbol SymbolExpression}
+\addcontentsline{toc}{subsubsection}{\ttfamily PolynomialRing:freeof}
+
+Checks the value of the field \mintinline{lua}{PolynomialRing.symbol} against \texttt{symbol}; returns \mintinline{lua}{true} if these symbols are not equal, and returns \mintinline{lua}{false} otherwise.
+
+Recall: the default symbol for \texttt{Poly} is \texttt{'x'}. So, for example:
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = Poly({2,2,1})
+ vars('t')
+ if f:freeof(t) then
+ tex.print('$',f:tolatex(),'$ is free of $',t:tolatex(),'$')
+ else
+ tex.print('$',f:tolatex(),'$ is bound by $',t:tolatex(),'$')
+ end
+\end{CAS}
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = Poly({2,2,1})
+ vars('t')
+ if f:freeof(t) then
+ tex.print('$',f:tolatex(),'$ is free of $',t:tolatex(),'$')
+ else
+ tex.print('$',f:tolatex(),'$ is bound by $',t:tolatex(),'$')
+ end
+\end{CAS}
+\end{codebox}
+
+\newcoderef{function PolynomialRing.gcd(poly1,poly2)}{return poly3}{poly1 PolynomialRing,..., poly3 PolynomialRing}
+\addcontentsline{toc}{subsubsection}{\ttfamily PolynomialRing.gcd}
+
+Returns the greatest common divisor of two polynomials in a ring (assuming \texttt{poly1,poly2} belong to a Euclidean domain). For example:
+
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = topoly((x^2+1)*(x-1))
+ g = topoly((x^2+1)*(x+2))
+ h = PolynomialRing.gcd(f,g)
+\end{CAS}
+\[ \gcd(\print{f},\print{g}) = \print{h} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = topoly((x^2+1)*(x-1))
+ g = topoly((x^2+1)*(x+2))
+ h = PolynomialRing.gcd(f,g)
+\end{CAS}
+\[ \gcd(\print{f},\print{g}) = \print{h} \]
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+The function \mintinline{lua}{gcd()} shortcuts \mintinline{lua}{PolynomialRing.gcd()}. For example:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = topoly(x^3 - x^2 + x - 1)
+ g = topoly(x^3 + 2*x^2 + x + 2)
+ h = gcd(f,g)
+\end{CAS}
+\[ \gcd(\print{f},\print{g}) = \print{h}.\]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = topoly(x^3 - x^2 + x - 1)
+ g = topoly(x^3 + 2*x^2 + x + 2)
+ h = gcd(f,g)
+\end{CAS}
+\[ \gcd(\print{f},\print{g}) = \print{h}.\]
+\end{codebox}
+
+\coderef{function PolynomialRing:isatomic()}{return false}
+\coderef{function PolynomialRing:isconstant()}{return false}
+
+The inheritances from \texttt{ConstantExpression} are overridden for the \texttt{PolynomialRing} class.
+
+\newcoderef{function PolynomialRing.monicgcdremainders(poly1,poly2)}{return table<number, Ring>}{poly1 PolynomialRing, poly2 PolynomialRing}
+\addcontentsline{toc}{subsubsection}{\ttfamily PolynomialRing.monicgcdremainders}
+
+Given two polynomials \texttt{poly1} and \texttt{poly2}, returns a list of the remainders generated by the monic Euclidean algorithm.
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = topoly(x^13-1)
+ g = topoly(x^8-1)
+ r = PolynomialRing.monicgcdremainders(f,g)
+\end{CAS}
+\luaexec{
+ for i=1,\#r do
+ tex.print('\\[', r[i]:tolatex(), '\\]')
+ end
+}
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = topoly(x^13-1)
+ g = topoly(x^8-1)
+ r = PolynomialRing.monicgcdremainders(f,g)
+\end{CAS}
+\luaexec{
+ for i=1,\#r do
+ tex.print('\\[', r[i]:tolatex(), '\\]')
+ end
+}
+\end{codebox}
+
+\coderef{function PolynomialRing.mul_rec(poly1,poly2)}{return PolynomialRing}
+\addcontentsline{toc}{subsubsection}{\ttfamily PolynomialRing.mul{\textunderscore}rec}
+
+Performs Karatsuba multiplication without constructing new polynomials recursively. But grade-school multiplication of polynomials is actually faster here up to a very large polynomial size due to Lua's overhead.
+
+\newcoderef{function PolynomialRing.partialfractions(g,f,ffactors)}{return BinaryOperation}{g PolynomialRing, f PolynomialRing, ffactors BinaryOperation}
+\addcontentsline{toc}{subsubsection}{\ttfamily PolynomialRing.partialfractions}
+
+Returns the partial fraction decomposition of the rational function \texttt{g/f} given \texttt{PolynomialRing}s \texttt{g, f}, and some (not necessarily irreducible) factorization \texttt{ffactors} of \texttt{f}. If the factorization is omitted, the irreducible factorization is used. The degree of \texttt{g} must be less than the degree of \texttt{f}.
+
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ g = topoly(4*x^2+2*x+2)
+ f = topoly((x^2+1)^2*(x+1))
+ a = PolynomialRing.partialfractions(g,f)
+\end{CAS}
+\[ \print{g/f} = \print*{a} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ g = topoly(4*x^2+2*x+2)
+ f = topoly((x^2+1)^2*(x+1))
+ a = PolynomialRing.partialfractions(g,f)
+\end{CAS}
+\[ \print{g/f} = \print*{a} \]
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+The function \mintinline{lua}{parfrac()} shortcuts the more long winded \mintinline{lua}{PolynomialRing.partialfractions()}. Additionally, the \texttt{parfrac} function will automatically try to convert the first two arguments to the \texttt{PolynomialRing} type via \mintinline{lua}{topoly()}.
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ g = 4*x^2+2*x+2
+ f = (x^2+1)^2*(x+1)
+ a = parfrac(g,f)
+\end{CAS}
+\[ \print{g/f} = \print*{a} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ g = 4*x^2+2*x+2
+ f = (x^2+1)^2*(x+1)
+ a = parfrac(g,f)
+\end{CAS}
+\[ \print{g/f} = \print*{a} \]
+\end{codebox}
+
+\newcoderef{function PolynomialRing:rationalroots()}{return remaining, roots}{remaining PolynomialRing, roots table<number,PolynomialRing>}
+\addcontentsline{toc}{subsubsection}{\ttfamily PolynomialRing:rationalroots}
+
+This method finds the factors of \texttt{PolynomialRing} (up to multiplicity) that correspond to rational roots; these factors are stored in a table \texttt{roots} and returned in the second output of the method. Those factors are then divided out of \texttt{Polynomialring}; the \texttt{PolynomialRing} that remains is returned in the first output of the method. For example:
+
+\begin{codebox}
+ \begin{minted}[breaklines,fontsize=\small]{latex}
+\begin{CAS}
+ f = topoly((x-1)^2*(x+1)*(x^2+1))
+ g,r = f:rationalroots()
+\end{CAS}
+The factors of $f$ corresponding to rational roots are:
+\luaexec{
+ for i =1, \#r do
+ tex.print('\\[', r[i]:tolatex(), '\\]')
+ end
+}
+The part of $f$ that remains after dividing out these linear terms is:
+\[ \print{g} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = topoly((x-1)^2*(x+1)*(x^2+1))
+ g,r = f:rationalroots()
+ \end{CAS}
+ The factors of $f$ corresponding to rational roots are:
+ \luaexec{
+ for i =1, \#r do
+ tex.print('\\[', r[i]:tolatex(), '\\]')
+ end
+ }
+ The part of $f$ that remains after dividing out these linear terms is:
+ \[ \print{g} \]
+\end{codebox}
+
+\coderef{function PolynomialRing:roots()}{return table<number, Expression}
+\addcontentsline{toc}{subsubsection}{\ttfamily PolynomialRing:roots}
+
+Returns a list of roots of \texttt{PolynomialRing}, simplified up to cubics. For example:
+
+\begin{codebox}[]
+ \begin{minted}[breaklines,fontsize=\small]{latex}
+\begin{CAS}
+ f = topoly(x^6 + 3*x^5 + 6*x^4 + 7*x^3 + 6*x^2 + 3*x + 2)
+ r = f:roots()
+\end{CAS}
+$ \left\{ \lprint{r} \right\}$
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = topoly(x^6 + 3*x^5 + 6*x^4 + 7*x^3 + 6*x^2 + 3*x + 2)
+ r = f:roots()
+\end{CAS}
+$ \left\{ \lprint{r} \right\}$
+\end{codebox}
+If the decomposition of \texttt{PolynomialRing} (or a factor thereof) is not a chain of cubics or lesser degree polynomials, then \texttt{RootExpression} is returned instead. For example:
+
+\begin{codebox}[]
+ \begin{minted}[breaklines,fontsize=\small]{latex}
+\begin{CAS}
+ f = topoly(x^6 + x^5 - x^4 + 2*x^3 + 4*x^2 - 2)
+ r = f:roots()
+\end{CAS}
+\[ \left\{ \lprint{r} \right\} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = topoly(x^6 + x^5 - x^4 + 2*x^3 + 4*x^2 - 2)
+ r = f:roots()
+\end{CAS}
+\[ \left\{ \lprint{r} \right\} \]
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+The function \mintinline{lua}{roots()} shortcuts \mintinline{lua}{PolynomialRing:roots()}. Also, the function \texttt{roots} attempts to cast the argument as a polynomial automatically using \mintinline{lua}{topoly()}. For example:
+
+\begin{codebox}
+ \begin{minted}[breaklines,fontsize=\small]{latex}
+\begin{CAS}
+ f = x^6+x^5-x^4+2*x^3+4*x^2-2
+ r = roots(f)
+\end{CAS}
+$ \left\{ \lprint{r} \right\}$
+\end{minted}
+\tcblower
+ \begin{CAS}
+ f = x^6 + x^5 - x^4 + 2*x^3 + 4*x^2 - 2
+ r = roots(f)
+ \end{CAS}
+ $ \left\{ \lprint{r} \right\}$
+\end{codebox}
+
+\newcoderef{function PolynomialRing.resultant(a,b)}{return Field}{a PolynomialRing, b PolynomialRing}
+\addcontentsline{toc}{subsubsection}{\ttfamily PolynomialRing.resultant}
+
+Returns the resultant of two polynomials \texttt{a,b} in the same ring, whose coefficients are all part of a field. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = topoly(x^2-2*x+1)
+ g = topoly(x^2+2*x-3)
+ r = PolynomialRing.resultant(f,g)
+\end{CAS}
+\[ \operatorname{res}(f,g) = \print{r} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = topoly(x^2-2*x+1)
+ g = topoly(x^2+2*x-3)
+ r = PolynomialRing.resultant(f,g)
+\end{CAS}
+\[ \operatorname{res}(f,g) = \print{r} \]
+\end{codebox}
+
+\coderef{function PolynomialRing:squarefreefactorization()}{return BinaryOperation}
+\addcontentsline{toc}{subsubsection}{\ttfamily PolynomialRing:squarefreefactorization}
+
+Returns the square-free factorization of a polynomial defined over the rationals.
+
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = topoly(x^7 - 13*x^6 + 66*x^5 - 158*x^4 + 149*x^3 + 63*x^2 - 216*x + 108)
+ s = f:squarefreefactorization()
+\end{CAS}
+\[ \print{s} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = topoly(x^7 - 13*x^6 + 66*x^5 - 158*x^4 + 149*x^3 + 63*x^2 - 216*x + 108)
+ s = f:squarefreefactorization()
+\end{CAS}
+\[ \print{s} \]
+\end{codebox}
+
+If the polynomial is defined over $\mathbf{Z}/p\mathbf{Z}$ (where $p$ is prime), then the method \texttt{modularsquarefreefactorization()} should be used.
+
+\subsubsection*{Parsing}
+
+The function \mintinline{lua}{factor()} has an optional boolean argument that if set to \mintinline{lua}{true} returns \texttt{squarefreefactorization()} or \texttt{modularsquarefreefactorization()} (as appropriate). For example:
+
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = topoly(x^6 + 2*x^5 + 4*x^4 + 4*x^3 + 5*x^2 + 2*x + 2)
+ s = factor(f,true)
+\end{CAS}
+\[ \print{s} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = topoly(x^6 + 2*x^5 + 4*x^4 + 4*x^3 + 5*x^2 + 2*x + 2)
+ s = factor(f,true)
+\end{CAS}
+\[ \print{s} \]
+\end{codebox}
+And also:
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = topoly(x^6 + 2*x^5 + 4*x^4 + 4*x^3 + 5*x^2 + 2*x + 2)
+ f = Mod(f,5)
+ s = factor(f,true)
+\end{CAS}
+\[ \print{s} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = topoly(x^6 + 2*x^5 + 4*x^4 + 4*x^3 + 5*x^2 + 2*x + 2)
+ f = Mod(f,5)
+ s = factor(f,true)
+\end{CAS}
+\[ \print{s} \]
+\end{codebox}
+
+\newcoderef{function Integer.gcd(a,b)}{return Integer}{a Integer, b Integer}
+\addcontentsline{toc}{subsubsection}{\ttfamily Ingeger.gcd}
+
+Returns the greatest common divisor of \texttt{a,b}. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = 408
+ b = 252
+ c = Integer.gcd(a,b)
+\end{CAS}
+\[ \gcd(a,b) = \print{c} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = 408
+ b = 252
+ c = Integer.gcd(a,b)
+\end{CAS}
+\[ \gcd(a,b) = \print{c} \]
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+The function \mintinline{lua}{gcd()} shortcuts \texttt{Integer.gcd()}. For example:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = 408
+ b = 252
+ c = gcd(a,b)
+\[ \gcd(a,b) = \print{c} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = 408
+ b = 252
+ c = gcd(a,b)
+\end{CAS}
+\[ \gcd(a,b) = \print{c} \]
+\end{codebox}
+
+
+\newcoderef{function Integer.extendedgcd(a,b)}{return Integer, Integer, Integer}{a Integer, b Integer}
+\addcontentsline{toc}{subsubsection}{\ttfamily Integer.extendedgcd}
+
+Returns the greatest common divisor of \texttt{a,b} as well as Bezout's coefficients via extended gcd. For example:
+
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = 408
+ b = 252
+ c,x,y = Integer.extendedgcd(a,b)
+\end{CAS}
+\[ \gcd(a,b) = \print{c} = \print{a}(\print{x}) + \print{b}(\print{y}) \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = 408
+ b = 252
+ c,x,y = Integer.extendedgcd(a,b)
+\end{CAS}
+\[ \gcd(a,b) = \print{c} = \print{a}(\print{x}) + \print{b}(\print{y}) \]
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+The function \mintinline{lua}{gcdext()} shortcuts \mintinline{lua}{Integer.extendedgcd()}. For example:
+
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = 408
+ b = 252
+ c,x,y = gcdext(a,b)
+\end{CAS}
+\[ \gcd(a,b) = \print{c} = \print{a}(\print{x}) + \print{b}(\print{y}) \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = 408
+ b = 252
+ c,x,y = gcdext(a,b)
+\end{CAS}
+\[ \gcd(a,b) = \print{c} = \print{a}(\print{x}) + \print{b}(\print{y}) \]
+\end{codebox}
+
+\newcoderef{function Integer.max(a,b)}{return Integer, Integer}{a Integer, b Integer}
+\newcoderef{function Integer.min(a,b)}{return Integer, Integer}{a Integer, b Integer}
+\addcontentsline{toc}{subsubsection}{{\ttfamily Integer.max} and {\ttfamily Integer.min}}
+
+Returns the max/min of \texttt{a,b}; the second output is the min/max (respectively).
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = 8
+ b = 7
+ c = Integer.max(a,b)
+\end{CAS}
+\[ \max(\print{a},\print{b}) = \print{c} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = 8
+ b = 7
+ c = Integer.max(a,b)
+\end{CAS}
+\[ \max(\print{a},\print{b}) = \print{c} \]
+\end{codebox}
+
+
+\newcoderef{function Integer.absmax(a,b)}{return Integer, Integer, number}{a Integer, b Integer}
+\addcontentsline{toc}{subsubsection}{\ttfamily Integer.absmax}
+
+Methods for computing the larger magnitude of two integers. Also returns the other integer for sorting purposes, and the number -1 if the two values were swapped, 1 if not.
+
+
+\newcoderef{function Integer.ceillog(a,base)}{return Integer}{a Integer, base Integer}
+\addcontentsline{toc}{subsubsection}{\ttfamily Integer.ceillog}
+
+Returns the ceiling of the log base (defaults to 10) of a. In other words, returns the least n such that $\mathtt{(base)^n > a}$.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = 101
+ b = 10
+ c = Integer.ceillog(a,b)
+\end{CAS}
+\[ \print{c} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = 101
+ b = 10
+ c = Integer.ceillog(a,b)
+\end{CAS}
+\[ \print{c} \]
+\end{codebox}
+
+\newcoderef{function Integer.powmod(a,b,n)}{return Integer}{a Integer,..., n Integer}
+\addcontentsline{toc}{subsubsection}{\ttfamily Integer.powmod}
+
+Returns the \texttt{Integer} $c$ such that $c \equiv a^b \bmod{n}$. This should be used when $a^b$ is potentially large.
+
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = 12341
+ b = 2^16+1
+ p = 62501
+ c = Integer.powmod(a,b,p)
+\end{CAS}
+\[ \print{c} \equiv \print{a}^{\print{b}} \bmod{\print{p}} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = 12341
+ b = 2^16+1
+ p = 62501
+ c = Integer.powmod(a,b,p)
+\end{CAS}
+\[ \print{c} \equiv \print{a}^{\print{b}} \bmod{\print{p}} \]
+\end{codebox}
+
+\newcoderef{function Integer:divremainder(b)}{return Integer, Integer}{b Integer}
+\addcontentsline{toc}{subsubsection}{\ttfamily Integer:divremainder}
+
+Returns the quotient and remainder over the integers. Uses the standard base 10 long division algorithm.
+
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = 408
+ b = 252
+ q,r = Integer.divremainder(a,b)
+\end{CAS}
+\[ \print{a} = \print{b} \cdot \print{q} + \print{r} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = 408
+ b = 252
+ q,r = Integer.divremainder(a,b)
+\end{CAS}
+\[ \print{a} = \print{b} \cdot \print{q} + \print{r} \]
+\end{codebox}
+
+\coderef{function Integer:asnumber()}{return number}
+\addcontentsline{toc}{subsubsection}{\ttfamily Integer:asnumber}
+
+Returns the integer as a floating point number. Can only approximate the value of large integers.
+
+\coderef{function Integer:divisors()}{return table<number, Integer>}
+
+Returns all positive divisors of the integer. Not guaranteed to be in any order.
+
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = 408
+ d = a:divisors()
+\end{CAS}
+\[ \left\{ \lprint{d} \right\} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = 408
+ d = a:divisors()
+\end{CAS}
+\[ \left\{ \lprint{d} \right\} \]
+\end{codebox}
+
+\coderef{function Integer:primefactorization()}{return BinaryOperation}
+\addcontentsline{toc}{subsubsection}{\ttfamily Integer:primefactorization}
+
+Returns the prime factorization of the integer as a \texttt{BinaryOperation}.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = 408
+ pf = a:primefactorization()
+\end{CAS}
+\[ \print{pf} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = 408
+ pf = a:primefactorization()
+\end{CAS}
+\[ \print{pf} \]
+\end{codebox}
+
+\coderef{function Integer:findafactor()}{return Integer}
+\addcontentsline{toc}{subsubsection}{\ttfamily Integer:findafactor}
+
+Return a non-trivial factor of {\ttfamily Integer} via Pollard Rho, or returns {\ttfamily Integer} if {\ttfamily Integer} is prime.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = 4199
+ f = a:findafactor()
+\end{CAS}
+\[ \print{f} \mid \print{a} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = 4199
+ f = a:findafactor()
+\end{CAS}
+\[ \print{f} \mid \print{a} \]
+\end{codebox}
+
+
+\coderef{function Integer:isprime()}{return bool}
+\addcontentsline{toc}{subsubsection}{\ttfamily Integer:isprime}
+
+Uses Miller-Rabin to determine whether {\ttfamily Integer} is prime up to a very large number.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ p = 7038304939
+ if p:isprime() then
+ tex.print(p:tolatex(), "is prime!")
+ end
+\end{CAS}
+\end{minted}
+\tcblower
+\begin{CAS}
+ p = 7038304939
+ if p:isprime() then
+ tex.print(p:tolatex(), "is prime!")
+ end
+\end{CAS}
+\end{codebox}
+
+\coderef{function Rational:reduce()}{return Rational}
+\addcontentsline{toc}{subsubsection}{\ttfamily Rational:reduce}
+
+Reduces a rational expression of integers to standard form. This method is called automatically when a new \texttt{Rational} expression is constructed:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = Rational(8,6)
+\end{CAS}
+\[ \print{a} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = Rational(8,6)
+\end{CAS}
+\[ \print{a} \]
+\end{codebox}
+
+
+\coderef{function Rational:tocompoundexpression()}{return BinaryOperation}
+\addcontentsline{toc}{subsubsection}{\ttfamily Rational:tocompoundexpression}
+
+Converts a \texttt{Rational} expression into the corresponding \texttt{BinaryOperation} expression.
+
+\coderef{function Rational:asnumber()}{return number}
+\addcontentsline{toc}{subsubsection}{\ttfamily Rational:asnumber}
+
+Returns the given rational as an approximate floating point number. Going the other way, the parser in \mintinline{latex}{\begin{CAS}..\end{CAS}} will convert decimals (as written) to fractions. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ a = 0.375
+\end{CAS}
+\[ \print{a} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = 0.375
+\end{CAS}
+\[ \print{a} \]
+\end{codebox}
+
+\coderef{function SqrtExpression:topower()}{return BinaryOperation}
+\addcontentsline{toc}{subsubsection}{\ttfamily SqrtExpression:topower}
+
+Converts a \texttt{SqrtExpression} to the appropriate \texttt{BinaryOperation}. For example, consider:
+\begin{minted}{latex}
+\begin{CAS}
+ a = sqrt(3)
+ b = a:topower()
+\end{CAS}
+\end{minted}
+\begin{CAS}
+ a = sqrt(3)
+ b = a:topower()
+\end{CAS}
+Then:
+\begin{multicols}{2}
+ \begin{center}
+ \underline{Expression shrub for \texttt{a}:}
+
+ \parseshrub{a}
+ \bracketset{action character = @}
+ \begin{forest}
+ for tree = {font = \ttfamily,
+ draw,
+ rounded corners = 1pt,
+ fill = gray!20,
+ s sep = 1cm}
+ @\shrubresult
+ \end{forest}
+
+ \columnbreak
+
+ \underline{Expression shrub for \texttt{b}:}
+
+ \parseshrub{b}
+ \bracketset{action character = @}
+ \begin{forest}
+ for tree = {font = \ttfamily,
+ draw,
+ rounded corners = 1pt,
+ fill = gray!20,
+ s sep = 1.75cm}
+ @\shrubresult
+ \end{forest}
+ \end{center}
+\end{multicols}
+
+\newcoderef{function Equation:solvefor(var)}{return Equation}{var SymbolExpression}
+\addcontentsline{toc}{subsubsection}{\ttfamily Equation:solvefor}
+
+Attempts to solve the equation for a particular variable.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars("x", "y", "z")
+ lhs = e ^ (x^2 * y)
+ rhs = z + 1
+ eq = Equation(lhs, rhs):autosimplify()
+ eqx = eq:solvefor(x)
+\end{CAS}
+\[ \print{eq} \to \print{eqx} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars("x", "y", "z")
+ lhs = e ^ (x^2 * y)
+ rhs = z + 1
+ eq = Equation(lhs, rhs):autosimplify()
+ eqx = eq:solvefor(x)
+\end{CAS}
+\[ \print{eq} \to \print{eqx} \]
+\end{codebox}
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/lualatex/luacas/reference/ref_calculus/ref_calculus.tex b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_calculus/ref_calculus.tex
new file mode 100644
index 00000000000..31d52ab8685
--- /dev/null
+++ b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_calculus/ref_calculus.tex
@@ -0,0 +1,225 @@
+\documentclass{article}
+
+\usepackage{luacas}
+\usepackage{amsmath}
+\usepackage{amssymb}
+
+\usepackage[margin=1in]{geometry}
+\usepackage[shortlabels]{enumitem}
+
+\usepackage{pgfplots}
+\pgfplotsset{compat=1.18}
+\usetikzlibrary{positioning,calc}
+\usepackage{forest}
+\usepackage{minted}
+\usemintedstyle{pastie}
+\usepackage[hidelinks]{hyperref}
+\usepackage{parskip}
+\usepackage{multicol}
+\usepackage[most]{tcolorbox}
+ \tcbuselibrary{xparse,documentation}
+\usepackage{microtype}
+\usepackage{makeidx}
+
+\usepackage[
+backend=biber,
+style=numeric,
+]{biblatex}
+\addbibresource{sources.bib}
+
+\definecolor{rose}{RGB}{128,0,0}
+\definecolor{roseyellow}{RGB}{222,205,99}
+\definecolor{roseblue}{RGB}{167,188,214}
+\definecolor{rosenavy}{RGB}{79,117,139}
+\definecolor{roseorange}{RGB}{232,119,34}
+\definecolor{rosegreen}{RGB}{61,68,30}
+\definecolor{rosewhite}{RGB}{223,209,167}
+\definecolor{rosebrown}{RGB}{108,87,27}
+\definecolor{rosegray}{RGB}{84,88,90}
+
+\definecolor{codegreen}{HTML}{49BE25}
+
+\newtcolorbox{codebox}[1][sidebyside]{
+ enhanced,skin=bicolor,
+ #1,
+ arc=1pt,
+ colframe=brown,
+ colback=brown!15,colbacklower=white,
+ boxrule=1pt,
+ notitle
+}
+
+\newtcolorbox{codehead}[1][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1
+}
+
+\usepackage{varwidth}
+
+\newtcolorbox{newcodehead}[2][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1,
+ fonttitle=\bfseries\ttfamily\footnotesize,
+ coltitle=rosegray,
+ attach boxed title to top text right,
+ boxed title style={frame hidden,
+ size=small,
+ bottom=-1mm,
+ interior style={fill=none,
+ top color=white,
+ bottom color=white}
+ },
+ title={#2}
+}
+
+\makeindex
+
+\newcommand{\coderef}[2]{%
+\begin{codehead}[sidebyside,segmentation hidden]%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{codehead}%
+}
+
+\newcommand{\newcoderef}[3]{%
+\begin{newcodehead}[sidebyside,segmentation hidden]{#3}%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{newcodehead}%
+}
+
+\usetikzlibrary{shapes.multipart}
+\useforestlibrary{edges}
+
+\def\error{\color{red}}
+\def\self{\color{gray}}
+\def\call{$\star$ }
+
+\begin{document}
+\thispagestyle{empty}
+
+\section{Calculus}
+ This section contains reference materials for the calculus functionality of \texttt{luacas}. The classes in this module are diagramed below according to inheritance along with the methods/functions one can call upon them.
+ \begin{itemize}
+ \item {\error\ttfamily\itshape method}: an abstract method;
+ \item {\self\ttfamily\itshape method}: a method that returns the expression unchanged;
+ \item {\ttfamily\itshape method}: method that is either unique, implements an abstract method, or overrides an abstract
+method;
+ \item {\tikz[baseline=-0.5ex]\node[fill=roseorange!30] {\ttfamily\bfseries Class};}: a concrete class.
+ \end{itemize}
+Here is an inheritance diagram of the classes in the calculus module; all these classes inherit from the \texttt{CompoundExpression} branch of the inheritance tree. Most methods are stated, but some were omitted (because they inherit in the obvious way, they are auxiliary and not likely to be interesting to the end-user, etc).
+ \vfill
+\forestset{
+rectcore/.style = {rectangle split,
+ rectangle split parts=2,
+ draw = {rosenavy,thick},
+ rounded corners = 1pt,
+ font = \ttfamily\bfseries,
+ fill = roseblue!#1
+ },
+rectalg/.style = {rectangle split,
+ rectangle split parts=2,
+ draw = {rose,thick},
+ rounded corners = 1pt,
+ font = \ttfamily\bfseries,
+ fill = rose!#1
+ },
+rectcalc/.style = {rectangle split,
+ rectangle split parts=2,
+ draw = {roseorange,thick},
+ rounded corners = 1pt,
+ font = \ttfamily\bfseries,
+ fill = roseorange!#1
+ }
+}
+\forestset{
+ multiple directions/.style={
+ for tree={#1},
+ phantom,
+ for relative level=1{
+ no edge,
+ delay={
+ !c.content/.pgfmath=content("!u")},
+ before computing xy={l=0,s=0}
+ }
+ },
+ multiple directions/.default={},
+ grow subtree/.style={for tree={grow=#1}},
+ grow' subtree/.style={for tree={grow'=#1}}}
+\tikzset{
+ every two node part/.style={font=\ttfamily\itshape\footnotesize}
+}
+\begin{center}
+ \begin{forest}
+ for tree = {node options={align=left},
+ edge = {-stealth}
+ },
+ forked edges
+ [Expression\nodepart{two}$\cdots$,rectcore={0}
+ [CompoundExpressions\nodepart{two}$\cdots$,rectcore={0}
+ [DerivativeExpression\nodepart{two}
+ :new() \\
+ :evaluate()\\
+ :autosimplify()
+ ,rectcalc=30]
+ [DiffExpression\nodepart{two}
+ :new()\\
+ :evaluate()\\
+ :autosimplify()
+ ,rectcalc=30]
+ [IntegralExpression\nodepart{two}
+ :new()\\
+ :isdefinite()\\
+ .table()\\
+ .linearproperties()\\
+ .substitutionmethod()\\
+ .enhancedsubstitutionmethod()\\
+ .rationalfunction()\\
+ .partsmethod()\\
+ .eulersformula()\\
+ .integrate()
+ ,rectcalc=30]
+ ]
+ ]
+ \end{forest}
+\end{center}
+\vfill
+
+\end{document}
+
diff --git a/Master/texmf-dist/doc/lualatex/luacas/reference/ref_calculus/ref_calculus_classes/ref_calculus_classes.tex b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_calculus/ref_calculus_classes/ref_calculus_classes.tex
new file mode 100644
index 00000000000..b08a190625c
--- /dev/null
+++ b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_calculus/ref_calculus_classes/ref_calculus_classes.tex
@@ -0,0 +1,277 @@
+\documentclass{article}
+
+\usepackage{luacas}
+\usepackage{amsmath}
+\usepackage{amssymb}
+
+\usepackage[margin=1in]{geometry}
+\usepackage[shortlabels]{enumitem}
+
+\usepackage{pgfplots}
+\pgfplotsset{compat=1.18}
+\usetikzlibrary{positioning,calc}
+\usepackage{forest}
+\usepackage{minted}
+\usemintedstyle{pastie}
+\usepackage[hidelinks]{hyperref}
+\usepackage{parskip}
+\usepackage{multicol}
+\usepackage[most]{tcolorbox}
+ \tcbuselibrary{xparse,documentation}
+\usepackage{microtype}
+\usepackage{makeidx}
+\usepackage{fontawesome}
+
+\usepackage[
+backend=biber,
+style=numeric,
+]{biblatex}
+\addbibresource{sources.bib}
+
+\definecolor{rose}{RGB}{128,0,0}
+\definecolor{roseyellow}{RGB}{222,205,99}
+\definecolor{roseblue}{RGB}{167,188,214}
+\definecolor{rosenavy}{RGB}{79,117,139}
+\definecolor{roseorange}{RGB}{232,119,34}
+\definecolor{rosegreen}{RGB}{61,68,30}
+\definecolor{rosewhite}{RGB}{223,209,167}
+\definecolor{rosebrown}{RGB}{108,87,27}
+\definecolor{rosegray}{RGB}{84,88,90}
+
+\definecolor{codegreen}{HTML}{49BE25}
+
+\newtcolorbox{codebox}[1][sidebyside]{
+ enhanced,skin=bicolor,
+ #1,
+ arc=1pt,
+ colframe=brown,
+ colback=brown!15,colbacklower=white,
+ boxrule=1pt,
+ notitle
+}
+
+\newtcolorbox{codehead}[1][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1
+}
+
+\usepackage{varwidth}
+
+\newtcolorbox{newcodehead}[2][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1,
+ fonttitle=\bfseries\ttfamily\footnotesize,
+ coltitle=rosegray,
+ attach boxed title to top text right,
+ boxed title style={frame hidden,size=small,bottom=-1mm,
+ interior style={fill=none,
+ top color=white,
+ bottom color=white}},
+ title={#2}
+}
+
+\makeindex
+
+\newcommand{\coderef}[2]{%
+\begin{codehead}[sidebyside,segmentation hidden]%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{codehead}%
+}
+
+\newcommand{\newcoderef}[3]{%
+\begin{newcodehead}[sidebyside,segmentation hidden]{#3}%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{newcodehead}%
+}
+
+\begin{document}
+\setdescription{style=multiline,
+ topsep=10pt,
+ leftmargin=5cm,
+ }
+
+\subsection{Calculus Classes}
+
+There are only a few classes (currently) in the calculus module all of which are concrete:
+\begin{itemize}
+ \item {\ttfamily DerivativeExpression}
+ \item {\ttfamily DiffExpression}
+ \item {\ttfamily IntegralExpression}
+\end{itemize}
+
+\newcoderef{function DerivativeExpression:new(expression, symbol)}{return DerivativeExpression}{expression Expression, symbol SymbolExpression}
+\addcontentsline{toc}{subsubsection}{\ttfamily DerivativeExpression}
+
+Creates a new single-variable derivative operation of the given \texttt{expression} with respect to the given \texttt{symbol}. If \texttt{symbol} is omitted, then \texttt{symbol} takes the default value of \mintinline{lua}{SymbolExpression("x")}. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+vars('x')
+f = DerivativeExpression(sin(x)/x)
+tex.print('\\[', f:tolatex(), '\\]')
+\end{minted}
+\tcblower
+\luaexec{
+ vars('x')
+ f = DerivativeExpression(sin(x)/x)
+ tex.print('\\[', f:tolatex(), '\\]')
+}
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+The function \mintinline{lua}{DD()} shortcuts \mintinline{lua}{DerivativeExpression()}.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = DD(sin(x)/x)
+\end{CAS}
+\[ \print{f} \]
+\end{CAS}
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = DD(sin(x)/x)
+\end{CAS}
+\[ \print{f} \]
+\end{codebox}
+Alternatively, one could also use \mintinline{lua}{diff()} (see below).
+
+\newcoderef{function DiffExpression:new(expression, symbols)}{return DiffExpression}{expression Expression, symbols table<number, Symbol>}
+\addcontentsline{toc}{subsubsection}{\ttfamily DiffExpression}
+
+Creates a new multi-variable higher-order derivative operation of the given \texttt{expression} with respect to the given \texttt{symbols}. As opposed to \texttt{DerivativeExpression}, the argument \texttt{symbols} cannot be omitted. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+vars('x','y')
+f = DiffExpression(sin(x*y)/y,{x,y})
+tex.print('\\[', f:tolatex(), '\\]')
+\end{minted}
+\tcblower
+\luaexec{
+ vars('x','y')
+ f = DiffExpression(sin(x*y)/y,{x,y})
+ tex.print('\\[', f:tolatex(), '\\]')
+}
+\end{codebox}
+We can also use \texttt{DiffExpression} to create higher-order single variable derivatives:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+vars('x')
+f = DiffExpression(sin(x)/x,{x,x})
+tex.print('\\[', f:tolatex(), '\\]')
+\end{minted}
+\tcblower
+\luaexec{
+ vars('x')
+ f = DiffExpression(sin(x)/x,{x,x})
+ tex.print('\\[', f:tolatex(), '\\]')
+}
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+The function \mintinline{lua}{diff()} shortcuts \mintinline{lua}{DiffExpression()}. The arguments of \mintinline{lua}{diff()} can also be given in a more user-friendly, compact form. For example:
+
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x','y')
+ f = diff(sin(x)/x, {x,2})
+ g = diff(sin(x*y)/y,x,{y,2})
+\end{CAS}
+\[ \print{f} = \print*{f} \qquad \print{g} = \print*{g} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x','y')
+ f = diff(sin(x)/x, {x,2})
+ g = diff(sin(x*y)/y,x,{y,2})
+\end{CAS}
+\[ \print{f} = \print*{f} \qquad \print{g} = \print*{g} \]
+\end{codebox}
+
+\newcoderef{function IntegralExpression:new(expression,symbol,lower,upper)}{return IntegralExpression}{expression Expression, symbol SymbolExpression, lower Expression, upper Expression}
+\addcontentsline{toc}{subsubsection}{\ttfamily IntegralExpression}
+
+Creates a new integral operation of the given \texttt{expression} with respect to the given \texttt{symbol} over the given \texttt{lower} and \texttt{upper} bounds. If \texttt{lower} and \texttt{upper} are omitted, then an \emph{indefinite} \texttt{IntegralExpression} is constructed. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small,breaklines]{lua}
+vars('x')
+f = IntegralExpression(sin(sqrt(x)), x)
+g = IntegralExpression(sin(sqrt(x)), x, Integer.zero(), pi)
+tex.print('\\[', f:tolatex(), '\\]')
+tex.print('\\[', g:tolatex(), '\\]')
+\end{minted}
+\tcblower
+\luaexec{
+ vars('x')
+ f = IntegralExpression(sin(sqrt(x)),x)
+ g = IntegralExpression(sin(sqrt(x)),x,Integer.zero(),pi)
+ tex.print('\\[', f:tolatex(), '\\]')
+ tex.print('\\[', g:tolatex(), '\\]')
+}
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+The function \mintinline{lua}{int()} shortcuts \mintinline{lua}{IntegralExpression()}. For example:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ g = int(sin(sqrt(x)),x,0,pi)
+\end{CAS}
+\[ \print{g} = \print*{g} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ g = int(sin(sqrt(x)),x,0,pi)
+\end{CAS}
+\[ \print{g} = \print*{g} \]
+\end{codebox}
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/lualatex/luacas/reference/ref_calculus/ref_calculus_methods/ref_calculus_methods.tex b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_calculus/ref_calculus_methods/ref_calculus_methods.tex
new file mode 100644
index 00000000000..c64baa5934b
--- /dev/null
+++ b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_calculus/ref_calculus_methods/ref_calculus_methods.tex
@@ -0,0 +1,473 @@
+\documentclass{article}
+
+\usepackage{luacas}
+\usepackage{amsmath}
+\usepackage{amssymb}
+
+\usepackage[margin=1in]{geometry}
+\usepackage[shortlabels]{enumitem}
+
+\usepackage{pgfplots}
+\pgfplotsset{compat=1.18}
+\usetikzlibrary{positioning,calc}
+\usepackage{forest}
+\usepackage{minted}
+\usemintedstyle{pastie}
+\usepackage[hidelinks]{hyperref}
+\usepackage{parskip}
+\usepackage{multicol}
+\usepackage[most]{tcolorbox}
+ \tcbuselibrary{xparse,documentation}
+\usepackage{microtype}
+\usepackage{makeidx}
+\usepackage{fontawesome5}
+
+\usepackage[
+backend=biber,
+style=numeric,
+]{biblatex}
+\addbibresource{sources.bib}
+
+\definecolor{rose}{RGB}{128,0,0}
+\definecolor{roseyellow}{RGB}{222,205,99}
+\definecolor{roseblue}{RGB}{167,188,214}
+\definecolor{rosenavy}{RGB}{79,117,139}
+\definecolor{roseorange}{RGB}{232,119,34}
+\definecolor{rosegreen}{RGB}{61,68,30}
+\definecolor{rosewhite}{RGB}{223,209,167}
+\definecolor{rosebrown}{RGB}{108,87,27}
+\definecolor{rosegray}{RGB}{84,88,90}
+
+\definecolor{codegreen}{HTML}{49BE25}
+
+\newtcolorbox{codebox}[1][sidebyside]{
+ enhanced,skin=bicolor,
+ #1,
+ arc=1pt,
+ colframe=brown,
+ colback=brown!15,colbacklower=white,
+ boxrule=1pt,
+ notitle
+}
+
+\newtcolorbox{codehead}[1][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1
+}
+
+\DeclareTotalTCBox{\lilcoderef}{O{} m m}{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ enhanced,
+ nobeforeafter,
+ tcbox raise base,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=1mm,
+ right=1mm,
+ top=1mm,
+ bottom=1mm,
+ oversize,
+ #1
+}{\mintinline{lua}{#2} \mintinline{lua}{#3}}
+
+\usepackage{varwidth}
+
+\newtcolorbox{newcodehead}[2][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1,
+ fonttitle=\bfseries\ttfamily\footnotesize,
+ coltitle=rosegray,
+ attach boxed title to top text right,
+ boxed title style={frame hidden,size=small,bottom=-1mm,
+ interior style={fill=none,
+ top color=white,
+ bottom color=white}},
+ title={#2}
+}
+
+\makeindex
+
+\newcommand{\coderef}[2]{%
+\begin{codehead}[sidebyside,segmentation hidden]%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{codehead}%
+}
+
+\newcommand{\newcoderef}[3]{%
+\begin{newcodehead}[sidebyside,segmentation hidden]{#3}%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{newcodehead}%
+}
+\usepackage{marginnote}
+
+\begin{document}
+\setdescription{style=multiline,
+ topsep=10pt,
+ leftmargin=6.5cm,
+ }
+
+\subsection{Calculus Methods}
+
+\newcoderef{function IntegralExpression.table(integral)}{return Expression|nil}{integral IntegralExpression}
+\addcontentsline{toc}{subsubsection}{\ttfamily IntegralExpression.table}
+
+Attempts to integrate \texttt{integral.expression} with respect to \texttt{integral.symbol} by checking a table of basic integrals; returns nil if the integrand isn't in the table. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = int(cos(x),x)
+ f = f:table()
+ g = int(x*cos(x),x)
+ g = g:table()
+\end{CAS}
+\[ f = \print{f} \qquad g = \print{g} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = int(cos(x),x)
+ f = f:table()
+ g = int(x*cos(x),x)
+ g = g:table()
+ \end{CAS}
+\[ f = \print{f} \qquad g = \print{g} \]
+\end{codebox}
+The table of integrals consists of power functions, exponentials, logarithms, trigonometric, and inverse trigonometric functions.
+
+\newcoderef{function IntegralExpression.linearproperties(integral)}{return Expression|nil}{integral IntegralExpression}
+\addcontentsline{toc}{subsubsection}{\ttfamily IntegralExpression.linearproperties}
+
+Attempts to integrate \texttt{integral.expression} with respect to \texttt{integral.symbol} by using linearity properties (e.g. the integral of a sum/difference is the sum/difference of integrals); returns nil if any individual component cannot be integrated using \mintinline{lua}{IntegralExpression:integrate()}. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = int(sin(x) + e^x,x)
+ g = f:table()
+ f = f:linearproperties()
+\end{CAS}
+\[ f = \print*{f} \qquad g = \print*{g} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = int(sin(x) + e^x,x)
+ g = f:table()
+ f = f:linearproperties()
+\end{CAS}
+\[ f = \print*{f} \qquad g = \print*{g} \]
+\end{codebox}
+
+\newcoderef{function IntegralExpression.substitutionmethod(integral)}{return Expression|nil}{integral IntegralExpression}
+\addcontentsline{toc}{subsubsection}{\ttfamily IntegralExpression.substitutionmethod}
+
+Attempts to integrate \texttt{integral.expression} with respect to \texttt{integral.symbol} via $u$-substitution; returns nil if no suitable substitution is found to be successful.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = int(x*e^(x^2),x)
+ g = int(x*e^x,x)
+ f = f:substitutionmethod()
+ g = g:substitutionmethod()
+\end{CAS}
+\[ f = \print*{f} \qquad g = \print*{g}.\]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = int(x*e^(x^2),x)
+ g = int(x*e^x,x)
+ f = f:substitutionmethod()
+ g = g:substitutionmethod()
+\end{CAS}
+\[ f = \print*{f} \qquad g = \print*{g}.\]
+\end{codebox}
+
+\newcoderef{function IntegralExpression.enhancedsubstitutionmethod(integral)}{return Expression|nil}{integral IntegralExpression}
+\addcontentsline{toc}{subsubsection}{\ttfamily IntegralExpression.enhancedsubstitutionmethod}
+
+Attempts integrate \texttt{integral.expression} with respect to \texttt{integral.symbol} via $u$-substitutions. This method distinguishes itself from the \mintinline{lua}{.substitutionmethod} by attempted to solve $u= g(x)$ for the original variable and then substituting the result into the expression. This behavior is not included in \mintinline{lua}{.substitutionmethod} due to speed concerns. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = int(x^5*sqrt(x^3+1),x)
+ g = f:substitutionmethod()
+ h = f:enhancedsubstitutionmethod()
+\end{CAS}
+\[ g= \print*{g} \]
+\[ h= \print*{h} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = int(x^5*sqrt(x^3+1),x)
+ g = f:substitutionmethod()
+ h = f:enhancedsubstitutionmethod()
+\end{CAS}
+\[ g= \print*{g} \]
+\[ h= \print*{h} \]
+\end{codebox}
+
+
+\newcoderef{function IntegralExpression.trialsubstitutions(Expression)}{return table<number, Expression}{}
+\addcontentsline{toc}{subsubsection}{\ttfamily IntegralExpression.trialsubstitutions}
+
+Generates a list of possible $u$-substitutions to attempt in \texttt{substitutionmethod()} and \texttt{enhancedsubstitutionmethod()}. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = cos(x)/(1+sin(x))
+ f = f:autosimplify()
+ l = IntegralExpression.trialsubstitutions(f)
+\end{CAS}
+$\left\{ \lprint{l} \right\}$.
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = cos(x)/(1+sin(x))
+ f = f:autosimplify()
+ l = IntegralExpression.trialsubstitutions(f)
+\end{CAS}
+$ \left\{ \lprint{l} \right\}$.
+\end{codebox}
+
+
+\newcoderef{function IntegralExpression.rationalfunction(IntegralExpression)}{return Expression|nil}{}
+\addcontentsline{toc}{subsubsection}{\ttfamily IntegralExpression.rationalfunction}
+
+Integrates \texttt{integrand} with respect to \texttt{symbol} via Lazard, Rioboo, Rothstein, and Trager's method in the case when \texttt{expression} is a rational function in the variable \texttt{symbol}. If \texttt{integrand} is not a rational function, then nil is returned.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = (x^2+2*x+2)/(x^2+3*x+2)
+ f = f:autosimplify()
+ g = int(f,x):rationalfunction()
+\end{CAS}
+\[ \int \print{f}\ dx = \print*{g} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = (x^2+2*x+2)/(x^2+3*x+2)
+ f = f:autosimplify()
+ g = int(f,x):rationalfunction()
+\end{CAS}
+\[ \int \print{f}\ dx = \print*{g} \]
+\end{codebox}
+
+In some cases, the \mintinline{lua}{.rationalfunction} method returns non-standard results. For example:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ num = x^2
+ den = ((x+1)*(x^2+2*x+2)):expand()
+ f = (num/den):autosimplify()
+ f = int(f,x):rationalfunction()
+\end{CAS}
+\[ \print{simplify(f)} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ num = x^2
+ den = ((x+1)*(x^2+2*x+2)):expand()
+ f = (num/den):autosimplify()
+ f = int(f,x):rationalfunction()
+\end{CAS}
+\[ \print{simplify(f)} \]
+\end{codebox}
+On the other hand:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ pfrac = parfrac(num,den)
+\end{CAS}
+\[ \print*{int(pfrac,x)} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ pfrac = parfrac(num,den)
+ \end{CAS}
+\[ \print*{int(pfrac,x)} \]
+\end{codebox}
+
+\newcoderef{function IntegralExpression.partsmethod(IntegralExpression)}{return Expression|nil}{}
+\addcontentsline{toc}{subsubsection}{\ttfamily IntegralExpression.partsmethod}
+
+Attempts to integrate \texttt{integral.expression} with respect to \texttt{integral.symbol} via \emph{integration by parts}; returns nil if no suitable application of IBP is found. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ a = int(x*e^x,x)
+ b = a:partsmethod()
+ c = int(e^(x^2),x)
+ d = c:partsmethod()
+\end{CAS}
+\[ b=\print*{b} \]
+\[ d=\print*{d} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ a = int(x*e^x,x)
+ b = a:partsmethod()
+ c = int(e^(x^2),x)
+ d = c:partsmethod()
+\end{CAS}
+\[ b= \print*{b} \]
+\[ d= \print*{d} \]
+\end{codebox}
+
+
+\newcoderef{function IntegralExpression.eulersformula(integral)}{return Expression|nil}{integral IntegralExpression}
+\addcontentsline{toc}{subsubsection}{\ttfamily IntegralExpression.eulersformula}
+
+Attempts to integrate \texttt{integral.expression} with respect to \texttt{integral.symbol} by using the Euler formulas:
+\[ \cos x = \frac{e^{ix} + e^{-ix}}{2} \qquad \sin x = \frac{e^{ix} - e^{-ix}}{2i}.\]
+Per usual, this method returns nil if such a method is unsuccessful (or if the integrand is unchanged after applying the above substitutions). This can often be used as an alternative for integration by parts. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ a = int(e^x*sin(x),x)
+ b = int(x^2,x)
+ c = a:eulersformula()
+ d = b:eulersformula()
+\end{CAS}
+\[ c= \print*{c} \]
+\[ d= \print*{d} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ a = int(e^x*sin(x),x)
+ b = int(x^2,x)
+ c = a:eulersformula()
+ d = b:eulersformula()
+\end{CAS}
+\[ c= \print*{c} \]
+\[ d= \print*{d} \]
+\end{codebox}
+
+\newcoderef{function IntegralExpression.integrate(integral)}{return Expression|nil}{integral IntegralExpression}
+\addcontentsline{toc}{subsubsection}{\ttfamily IntegralExpression.integrate}
+
+Recursive part of the indefinite integral operator; returns nil if the expression could not be integrated. The methods above get called (roughly) in the following order:
+\begin{enumerate}[(i)]
+ \item \mintinline{lua}{.table}
+ \item \mintinline{lua}{.linearproperties}
+ \item \mintinline{lua}{.substitutionmethod}
+ \item \mintinline{lua}{.rationalfunction}
+ \item \mintinline{lua}{.partsmethod}
+ \item \mintinline{lua}{.eulersformula}
+ \item \mintinline{lua}{.enhancedsubstitutionmethod}
+\end{enumerate}
+Between (vi) and (vii), the \mintinline{lua}{.integrate} method will attempt to expand the integrand and retry. The method is recursive in the sense that (most) of the methods listed above will call \mintinline{lua}{.integrate} at some point. For example, after a list of trial substitutions is created, the method \mintinline{lua}{.substitutionmethod} will call \mintinline{lua}{.integrate} to determine whether the new integrand can be integrated via the methods in the above list.
+
+\subsubsection*{Parsing}
+
+Recall the function \mintinline{lua}{int()} which acts as a shortcut for \mintinline{lua}{IntegralExpression:new()}. When \mintinline{lua}{:autosimplify()} is called upon an \texttt{IntegralExpression}, then \mintinline{lua}{IntegralExpression.integrate} is applied. If \mintinline{lua}{nil} is returned, then \mintinline{lua}{:autosimplify()} returns \mintinline{lua}{self}; otherwise the result of \mintinline{lua}{.integrate} is returned and evaluated over the bounds, if any are given. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = cos(x)*e^(sin(x))
+ f = int(f,x,0,pi/2)
+\end{CAS}
+\[ \print{f} = \print*{f}\]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = cos(x)*e^(sin(x))
+ f = int(f,x,0,pi/2)
+\end{CAS}
+\[ \print{f} = \print*{f}\]
+\end{codebox}
+
+On the other hand:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = e^(e^x)
+ f = int(f,x,0,1)
+\end{CAS}
+\[ \print{f} = \print*{f} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = e^(e^x)
+ f = int(f,x,0,1)
+\end{CAS}
+\[ \print{f} = \print*{f} \]
+\end{codebox}
+
+\coderef{function IntegralExpression:isdefinite()}{return bool}
+\addcontentsline{toc}{subsubsection}{\ttfamily IntegralExpression.isdefinite}
+
+Returns \mintinline{lua}{true} of \texttt{IntegralExpression} is definite (i.e. if \texttt{.upper} and \texttt{.lower} are defined fields), otherwise returns \mintinline{lua}{false}.
+
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/lualatex/luacas/reference/ref_core/ref_core.tex b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_core/ref_core.tex
new file mode 100644
index 00000000000..668eda73a1e
--- /dev/null
+++ b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_core/ref_core.tex
@@ -0,0 +1,249 @@
+\documentclass{article}
+
+\usepackage{luacas}
+\usepackage{amsmath}
+\usepackage{amssymb}
+
+\usepackage[margin=1in]{geometry}
+\usepackage[shortlabels]{enumitem}
+
+\usepackage{pgfplots}
+\pgfplotsset{compat=1.18}
+\usetikzlibrary{positioning,calc}
+\usepackage{forest}
+\usepackage{minted}
+\usemintedstyle{pastie}
+\usepackage[hidelinks]{hyperref}
+\usepackage{parskip}
+\usepackage{multicol}
+\usepackage[most]{tcolorbox}
+ \tcbuselibrary{xparse,documentation}
+\usepackage{microtype}
+\usepackage{makeidx}
+
+\usepackage[
+backend=biber,
+style=numeric,
+]{biblatex}
+\addbibresource{sources.bib}
+
+\definecolor{rose}{RGB}{128,0,0}
+\definecolor{roseyellow}{RGB}{222,205,99}
+\definecolor{roseblue}{RGB}{167,188,214}
+\definecolor{rosenavy}{RGB}{79,117,139}
+\definecolor{roseorange}{RGB}{232,119,34}
+\definecolor{rosegreen}{RGB}{61,68,30}
+\definecolor{rosewhite}{RGB}{223,209,167}
+\definecolor{rosebrown}{RGB}{108,87,27}
+\definecolor{rosegray}{RGB}{84,88,90}
+
+\definecolor{codegreen}{HTML}{49BE25}
+
+\newtcolorbox{codebox}[1][sidebyside]{
+ enhanced,skin=bicolor,
+ #1,
+ arc=1pt,
+ colframe=brown,
+ colback=brown!15,colbacklower=white,
+ boxrule=1pt,
+ notitle
+}
+
+\newtcolorbox{codehead}[1][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1
+}
+
+\usepackage{varwidth}
+
+\newtcolorbox{newcodehead}[2][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1,
+ fonttitle=\bfseries\ttfamily\footnotesize,
+ coltitle=rosegray,
+ attach boxed title to top text right,
+ boxed title style={frame hidden,size=small,bottom=-1mm,
+ interior style={fill=none,
+ top color=white,
+ bottom color=white}},
+ title={#2}
+}
+
+\makeindex
+
+\newcommand{\coderef}[2]{%
+\index{\currref!\texttt{#1}}%
+\begin{codehead}[sidebyside,segmentation hidden]%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{codehead}%
+}
+
+\newcommand{\newcoderef}[3]{%
+\index{\currref!\texttt{#1}}%
+\begin{newcodehead}[sidebyside,segmentation hidden]{#3}%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{newcodehead}%
+}
+\usetikzlibrary{shapes.multipart}
+\useforestlibrary{edges}
+
+\def\error{\color{red}}
+\def\self{\color{gray}}
+\def\call{}
+
+\begin{document}
+\thispagestyle{empty}
+
+\section{Core}
+ This section contains reference materials for the core functionality of \texttt{luacas}. The classes in this module are diagramed below according to inheritance along with the methods/functions one can call upon them.
+ \begin{itemize}
+ \item {\error\ttfamily\itshape method}: an abstract method (a method that must be implemented by a subclass to be called);
+ \item {\self\ttfamily\itshape method}: a method that returns the expression unchanged;
+ \item {\ttfamily\itshape method}: a method that is either unique, implements an abstract method, or overrides an abstract method;
+ \item {\tikz[baseline=-0.5ex]\node[fill=roseblue!50] {\ttfamily\bfseries Class};}: a concrete class.
+ \end{itemize}
+
+\forestset{
+rect/.style = {rectangle split,
+ rectangle split parts=2,
+ draw = {rosenavy,thick},
+ rounded corners = 1pt,
+ font = \ttfamily\bfseries,
+ }
+}
+\tikzset{
+ every two node part/.style={font=\ttfamily\itshape\footnotesize}
+}
+\begin{center}
+ \begin{forest}
+ for tree = {node options={align=left},
+ rect,
+ grow= south,
+ parent anchor=south,
+ child anchor=north,
+ edge = {-stealth}
+ },
+ forked edges
+ [Expression\nodepart{two}\begin{minipage}{0.5\textwidth}\vskip-0.2cm\begin{multicols}{2}
+ {\error :evaluate()} \\
+ {\error :autosimplify()} \\
+ :simplify() \\
+ :size() \\
+ {\error :subexpressions()} \\
+ {\error :setsubexpressions()} \\
+ {\error :freeof(symbol)} \\
+ {\error :substitute(map)} \\
+ {\self :expand()} \\
+ {\self :factor()} \\
+ {\self :combine()} \\
+ :getsubexpressionsrec() \\
+ {\error :isatomic()} \\
+ {\error :isconstant()} \\
+ :isrealconstant() \\
+ :iscomplexconstant() \\
+ {\error :order(other)} \\
+ {\self :topolynomial()} \\
+ {\error :tolatex()} \\
+ :type()\end{multicols}\end{minipage}
+ [AtomicExpression\nodepart{two}
+ {\self :tocompoundexpression()} \\
+ {\self :evaluate()} \\
+ {\self :autosimplify()} \\
+ :subexpressions() \\
+ {\self :setsubexpressions()} \\
+ :substitute(map) \\
+ :isatomic() \\
+ :tolatex()
+ [SymbolExpression\nodepart{two}
+ {\call :new(symbol)} \\
+ :freeof(symbol) \\
+ :isconstant() \\
+ :order(other) \\
+ :topolynomial()
+ ,fill = roseblue!50]
+ [ConstantExpression\nodepart{two}
+ :freeof(symbol)\\
+ :isconstant() \\
+ :order(other)
+ ]
+ ]
+ [CompoundExpression\nodepart{two}
+ :freeof(symbol) \\
+ :substitute(map) \\
+ :isatomic() \\
+ :isconstant()
+ [BinaryOperation\nodepart{two}
+ {\call :new(operation,expressions)} \\
+ :evaluate() \\
+ :autosimplify() (!)\\
+ :subexpressions() \\
+ :setsubexpressions() \\
+ :expand() \\
+ :factor() \\
+ :combine() \\
+ :order(other) \\
+ {:iscommutatitve()}\\
+ :topolynomial() \\
+ :tolatex()
+ , fill=roseblue!50]
+ [FunctionExpression\nodepart{two}
+ {\call :new(name,expressions)}\\
+ :evaluate()\\
+ :autosimplify()\\
+ :subexpressions()\\
+ :setsubexpressions()\\
+ :order(other)\\
+ :tolatex()
+ , fill=roseblue!50]
+ ]
+ ]
+ \end{forest}
+\end{center}
+The number of core methods should generally be kept small, since every new type of expression must implement all of these methods. The exception to this, of course, is core methods that call other core methods that provide a unified interface to expressions. For instance, {\ttfamily size()} calls {\ttfamily subexpressions()}, so it only needs to be implemented in the expression interface.
+
+All expressions should also implement the {\ttfamily \_\_tostring} and {\ttfamily \_\_eq} metamethods. Metamethods cannot be inherited using Lua, thus every expression object created by a constructor must assign a metatable to that object.
+
+\begin{itemize}
+ \item {\ttfamily \_\_tostring} provides a human-readable version of an expression for printing within Lua and exporting to external programs.
+
+ \item {\ttfamily \_\_eq} determines whether an expression is structurally identical to another expression.
+\end{itemize}
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/lualatex/luacas/reference/ref_core/ref_core_classes/ref_core_classes.tex b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_core/ref_core_classes/ref_core_classes.tex
new file mode 100644
index 00000000000..77e80aa16f7
--- /dev/null
+++ b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_core/ref_core_classes/ref_core_classes.tex
@@ -0,0 +1,455 @@
+\documentclass{article}
+
+\usepackage{luacas}
+\usepackage{amsmath}
+\usepackage{amssymb}
+
+\usepackage[margin=1in]{geometry}
+\usepackage[shortlabels]{enumitem}
+
+\usepackage{pgfplots}
+\pgfplotsset{compat=1.18}
+\usetikzlibrary{positioning,calc}
+\usepackage{forest}
+\usepackage{minted}
+\usemintedstyle{pastie}
+\usepackage[hidelinks]{hyperref}
+\usepackage{parskip}
+\usepackage{multicol}
+\usepackage[most]{tcolorbox}
+ \tcbuselibrary{xparse,documentation}
+\usepackage{microtype}
+\usepackage{makeidx}
+\usepackage{fontawesome5}
+\usepackage{marginnote}
+
+\usepackage[
+backend=biber,
+style=numeric,
+]{biblatex}
+\addbibresource{sources.bib}
+
+\definecolor{rose}{RGB}{128,0,0}
+\definecolor{roseyellow}{RGB}{222,205,99}
+\definecolor{roseblue}{RGB}{167,188,214}
+\definecolor{rosenavy}{RGB}{79,117,139}
+\definecolor{roseorange}{RGB}{232,119,34}
+\definecolor{rosegreen}{RGB}{61,68,30}
+\definecolor{rosewhite}{RGB}{223,209,167}
+\definecolor{rosebrown}{RGB}{108,87,27}
+\definecolor{rosegray}{RGB}{84,88,90}
+
+\definecolor{codegreen}{HTML}{49BE25}
+
+\newtcolorbox{codebox}[1][sidebyside]{
+ enhanced,skin=bicolor,
+ #1,
+ arc=1pt,
+ colframe=brown,
+ colback=brown!15,colbacklower=white,
+ boxrule=1pt,
+ notitle
+}
+
+\newtcolorbox{codehead}[1][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1
+}
+
+\usepackage{varwidth}
+
+\newtcolorbox{newcodehead}[2][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1,
+ fonttitle=\bfseries\ttfamily\footnotesize,
+ coltitle=rosegray,
+ attach boxed title to top text right,
+ boxed title style={frame hidden,size=small,bottom=-1mm,
+ interior style={fill=none,
+ top color=white,
+ bottom color=white}},
+ title={#2}
+}
+
+\makeindex
+
+\newcommand{\coderef}[2]{%
+\begin{codehead}[sidebyside,segmentation hidden]%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{codehead}%
+}
+
+\newcommand{\newcoderef}[3]{%
+\begin{newcodehead}[sidebyside,segmentation hidden]{#3}%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{newcodehead}%
+}
+
+\begin{document}
+
+\subsection{Core Classes}
+
+There are several classes in the core module; but only some classes are concrete:
+
+\begin{multicols}{2}
+ \begin{center}
+ \underline{Abstract classes:}
+ \begin{itemize}
+ \item \texttt{Expression}
+ \item \texttt{AtomicExpression}
+ \item \texttt{CompoundExpression}
+ \item \texttt{ConstantExpression}
+ \end{itemize}
+
+ \underline{Concrete classes:}
+ \begin{itemize}
+ \item \texttt{SymbolExpression}
+ \item \texttt{BinaryOperation}
+ \item \texttt{FunctionExpression}
+ \end{itemize}
+\end{center}
+\end{multicols}
+
+The abstract classes provide a unified interface for the concrete classes (expressions) using inheritance. \emph{Every} expression in \texttt{luacas} inherits from either {\ttfamily AtomicExpression} or {\ttfamily CompoundExpression} which, in turn, inherit from {\ttfamily Expression}.
+
+\coderef{function SymbolExpression:new(string)}{return SymbolExpression}
+\index{Core!Classes!\texttt{SymbolExpression}}
+\addcontentsline{toc}{subsubsection}{\ttfamily SymbolExpression}
+
+Creates a new \texttt{SymbolExpression}. For example:
+\begin{codebox}[]
+\begin{minted}[breaklines,fontsize=\small]{lua}
+foo = SymbolExpression("bar")
+tex.sprint("The Lua variable ``foo'' is the SymbolExpression: ", foo:tolatex(),".")
+\end{minted}
+\tcblower
+\directlua{
+foo = SymbolExpression("bar")
+tex.sprint("The Lua variable 'foo' is the SymbolExpression: ", foo:tolatex(),".")
+}
+\end{codebox}
+
+\subsubsection*{Fields}
+
+\texttt{SymbolExpression}s have only one field: \texttt{symbol}. In the example above, the string \mintinline{lua}{"bar"} is stored in \mintinline{lua}{foo.symbol}.
+
+\subsubsection*{Parsing}
+
+The command \mintinline{lua}{vars()} in \texttt{test.parser} creates a new \texttt{SymbolExpression} for every string in the argument; each such \texttt{SymbolExpression} is assigned to a variable of the same name. For example:
+
+\begin{minted}{lua}
+vars('x','y')
+\end{minted}
+
+is equivalent to:
+
+\begin{minted}{lua}
+x = SymbolExpression("x")
+y = SymbolExpression("y")
+\end{minted}
+
+\newcoderef{function BinaryOperation:new(operation, expressions)}{return BinaryOperation}{operation function, expressions table<number,Expression>}
+\index{Core!Classes!\texttt{BinaryOperation}}
+\addcontentsline{toc}{subsubsection}{\ttfamily BinaryOperation}
+
+Creates a new \texttt{BinaryOperation} expression. For example:
+
+\begin{codebox}
+\begin{minted}[fontsize=\small]{lua}
+vars('x','y','z')
+w = BinaryOperation(
+ BinaryOperation.ADD,
+ {BinaryOperation(
+ BinaryOperation.MUL,
+ {x,y}
+ ),y,z}
+)
+tex.print("\\[w=",w:tolatex(),"\\]")
+\end{minted}
+\tcblower
+\directlua{
+vars('x','y','z')
+w = BinaryOperation(
+ BinaryOperation.ADD,
+ {BinaryOperation(
+ BinaryOperation.MUL,
+ {x,y}
+ ),y,z}
+)
+tex.print("\\[w=",w:tolatex(),"\\]")
+}
+\end{codebox}
+The variable \texttt{operation} must be a function \mintinline{lua}{function f(a,b)} assigned to one of the following types:
+\bgroup
+\setdescription{style=multiline,
+ topsep=10pt,
+ leftmargin=4.5cm,
+ font=\ttfamily
+ }
+\begin{description}
+ \item[BinaryOperation.ADD:] \mintinline{lua}{return a + b}
+ \item[BinaryOperation.SUB:] \mintinline{lua}{return a - b}
+ \item[BinaryOperation.MUL:] \mintinline{lua}{return a * b}
+ \item[BinaryOperation.DIV:] \mintinline{lua}{return a / b}
+ \item[BinaryOperation.IDIV:] \mintinline{lua}{return a // b}
+ \item[BinaryOperation.MOD:] \mintinline{lua}{return a % b}
+ \item[BinaryOperation.POW:] \mintinline{lua}{return a ^ b}
+\end{description}
+\egroup
+The variable \texttt{expressions} must be a table of \texttt{Expression}s index by Lua numbers.
+
+\subsubsection*{Fields}
+
+\texttt{BinaryOperation}s have the following fields: \texttt{name}, \texttt{operation}, and \texttt{expressions}. In the example above, we have:
+\begin{itemize}
+ \item the variable \texttt{expressions} is stored in \mintinline{lua}{w.expressions};
+ \item \mintinline{lua}{w.name} stores the string \mintinline{lua}{"+"}; and
+ \item \mintinline{lua}{w.operation} stores the function:
+ \begin{minted}{lua}
+BinaryOperation.ADD = function(a, b)
+ return a + b
+end
+ \end{minted}
+\end{itemize}
+
+\begin{multicols}{2}
+The entries of \texttt{w.expressions} can be used/fetched in a reasonable way:
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+$\print{w.expressions[1]} \quad
+ \print{w.expressions[2]} \quad
+ \print{w.expressions[3]}$
+ \end{minted}
+ \tcblower
+$\print{w.expressions[1]} \quad
+ \print{w.expressions[2]} \quad
+ \print{w.expressions[3]}$
+\end{codebox}
+
+\begin{center}
+ \bracketset{action character = @}
+ \parseshrub{w}
+ \begin{forest}
+ for tree = {font = \ttfamily,
+ draw,
+ rounded corners = 1pt,
+ fill = gray!20,
+ l sep = 1.5cm,
+ s sep = 2cm}
+ @\shrubresult
+ \end{forest}
+\end{center}
+\end{multicols}
+
+\subsubsection*{Parsing}
+
+Thank goodness for this. Creating new \texttt{BinaryOperation}s isn't nearly as cumbersome as the above would indicate. Using Lua's powerful metamethods, we can parse expressions easily. For example, the construction of \texttt{w} given above can be done much more naturally using:
+\begin{codebox}
+\begin{minted}[fontsize=\small]{lua}
+vars('x','y','z')
+w = x*y+y+z
+tex.print("\\[w=", w:tolatex(), "\\]")
+\end{minted}
+\tcblower
+\directlua{
+ vars('x','y','z')
+ w = x*y+y+z
+ tex.print("\\[w=", w:tolatex(), "\\]")
+}
+\end{codebox}
+\reversemarginpar
+{\bf Warning:}\marginnote{\color{rose}\faExclamationTriangle} There are escape issues to be aware of with the operator \mintinline{latex}{%}. If you're writing custom \texttt{luacas} functions in a separate \texttt{.lua} file, then there are no issues; use \mintinline{latex}{%} with reckless abandon. But when using the operator \mintinline{latex}{%} within, say \mintinline{latex}{\begin{CAS}..\end{CAS}}, then one should write \mintinline{latex}{\%} in place of \mintinline{latex}{%}:
+
+\begin{codebox}
+\begin{minted}[breaklines,fontsize=\small]{latex}
+\begin{CAS}
+ a = 17
+ b = 5
+ c = a \% b
+\end{CAS}
+\[ \print{c} \equiv \print{a} \bmod{\print{b}} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = 17
+ b = 5
+ c = a \% b
+\end{CAS}
+\[ \print{c} \equiv
+ \print{a} \bmod{\print{b}} \]
+\end{codebox}
+The above escape will {\bf not} work with \mintinline{latex}{\directlua}, but it will work for \mintinline{latex}{\luaexec} from the \texttt{luacode} package. Indeed, the \texttt{luacode} package was designed (in part) to make escapes like this more manageable. Here is the equivalent code using \mintinline{latex}{\luaexec}:
+\begin{codebox}[]
+\begin{minted}[fontsize=\small]{lua}
+a = Integer(17)
+b = Integer(5)
+c = a \% b
+tex.print("\\[",c:tolatex(),"\\equiv",a:tolatex(), "\\bmod{",b:tolatex(),"} \\]")
+\end{minted}
+\tcblower
+\luaexec{
+a = Integer(17)
+b = Integer(5)
+c = a \% b
+tex.print("\\[", c:tolatex(), "\\equiv", a:tolatex(), "\\bmod{", b:tolatex(), "} \\]")
+}
+\end{codebox}
+
+\newcoderef{function FunctionExpression:new(name,expressions)}{return FunctionExpression}{name string|SymbolExpression, expressions table<number,Expression>}
+\index{Core!Classes!\texttt{FunctionExpression}}
+\addcontentsline{toc}{subsubsection}{\ttfamily FunctionExpression}
+
+Creates a generic function. For example:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+vars('x','y')
+f = FunctionExpression('f',{x,y})
+tex.print("\\[",f:tolatex(),"\\]")
+ \end{minted}
+ \tcblower
+ \luaexec{
+ vars('x','y')
+ f = FunctionExpression('f',{x,y})
+ tex.print("\\[",f:tolatex(),"\\]")
+ }
+\end{codebox}
+The variable \texttt{name} can be a string (like above), or another \texttt{SymbolExpression}. But in this case, the variable \texttt{name} just takes the value of the string \mintinline{lua}{SymbolExpression.symbol}. The variable \texttt{expressions} must be a table of \texttt{Expression}s indexed by Lua numbers.
+
+\subsubsection*{Fields}
+\texttt{FunctionExpression}s have the following fields: \texttt{name}, \texttt{expressions}, \texttt{variables}, \texttt{derivatives}. In the example above, we have:
+\begin{itemize}
+ \item the variable \texttt{name}, i.e. the string \mintinline{lua}{'f'}, is stored in \mintinline{lua}{f.name}; and
+ \item the variable \texttt{expressions}, i.e. the table \mintinline{lua}{{x,y}} is stored in \mintinline{lua}{f.expressions}.
+\end{itemize}
+
+Wait a minute, what about \texttt{variables} and \texttt{derivatives}!? The field \texttt{variables} essentially stores a copy of the variable \texttt{expressions} \textit{as long as} the entries in that table are atomic. If they aren't, then \texttt{variables} will default to $x,y,z$, or $x_1,x_2,\ldots$ if the number of variables exceeds $3$. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+vars('s','t')
+f = FunctionExpression('f',{s*s,s+t+t})
+tex.print("The variables of f are:")
+for _,symbol in ipairs(f.variables) do
+ tex.print(symbol:tolatex())
+end
+ \end{minted}
+ \tcblower
+\luaexec{
+ vars('s','t')
+ f = FunctionExpression('f',{s*s,s+t+t})
+ tex.print("The variables of f are:")
+ for _,symbol in ipairs(f.variables) do
+ tex.print(symbol:tolatex())
+ end
+}
+\end{codebox}
+The field \texttt{derivatives} is a table of \texttt{Integer}s indexed by Lua numbers whose length equals \mintinline{lua}{#o.variables}. The default value for this table is a table of (\texttt{Integer}) zeros. So for the example above, we have:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+for _,integer in ipairs(f.derivatives) do
+ if integer == Integer.zero() then
+ tex.print("I'm a zero.\\newline")
+ end
+end
+\end{minted}
+\tcblower
+\luaexec{
+ for _,integer in ipairs(f.derivatives) do
+ if integer == Integer.zero() then
+ tex.print("I'm a zero.\\newline")
+ end
+ end
+}
+\end{codebox}
+We can change the values of \texttt{variables} and \texttt{derivatives} manually (or more naturally by other gizmos found in \texttt{luacas}). For example, keeping the variables from above, we have:
+\begin{multicols}{2}
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{lua}
+f.derivatives = {Integer.one(),
+ Integer.one()}
+tex.print("\\[",
+ f:simplify():tolatex(),
+ "\\]")
+\end{minted}
+\tcblower
+\luaexec{
+ f.derivatives = {Integer.one(),Integer.one()}
+ tex.print("\\[", f:simplify():tolatex(), "\\]")
+}
+\end{codebox}
+
+\begin{center}
+\parseshrub{f}
+\bracketset{action character = @}
+\begin{forest}
+ for tree = {font = \ttfamily,
+ draw,
+ rounded corners = 1pt,
+ fill = gray!20,
+ l sep = 1.5cm,
+ s sep = 0.75cm}
+ @\shrubresult
+\end{forest}
+\end{center}
+\end{multicols}
+
+\subsubsection*{Parsing}
+
+Thank goodness for this too. The parser nested within the \LaTeX{} environment \mintinline{latex}{\begin{CAS}..\end{CAS}} allows for fairly natural function assignment; the name of the function must be declared in \mintinline{lua}{vars(...)} (or rather, as a \texttt{SymbolExpression}) beforehand:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('s','t','f')
+ f = f(s^2,s+2*t)
+ f.derivatives = {1,1}
+\end{CAS}
+\[ \print{f} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('s','t','f')
+ f = f(s^2,s+2*t)
+ f.derivatives = {1,1}
+\end{CAS}
+\[ \print{f} \]
+\end{codebox}
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/lualatex/luacas/reference/ref_core/ref_core_methods/ref_core_methods.tex b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_core/ref_core_methods/ref_core_methods.tex
new file mode 100644
index 00000000000..a88b5a15d8c
--- /dev/null
+++ b/Master/texmf-dist/doc/lualatex/luacas/reference/ref_core/ref_core_methods/ref_core_methods.tex
@@ -0,0 +1,1155 @@
+\documentclass{article}
+
+\usepackage{luacas}
+\usepackage{amsmath}
+\usepackage{amssymb}
+
+\usepackage[margin=1in]{geometry}
+\usepackage[shortlabels]{enumitem}
+
+\usepackage{pgfplots}
+\pgfplotsset{compat=1.18}
+\usetikzlibrary{positioning,calc}
+\usepackage{forest}
+\usepackage{minted}
+\usemintedstyle{pastie}
+\usepackage[hidelinks]{hyperref}
+\usepackage{parskip}
+\usepackage{multicol}
+\usepackage[most]{tcolorbox}
+ \tcbuselibrary{xparse,documentation}
+\usepackage{microtype}
+\usepackage{makeidx}
+
+\usepackage[
+backend=biber,
+style=numeric,
+]{biblatex}
+\addbibresource{sources.bib}
+
+\definecolor{rose}{RGB}{128,0,0}
+\definecolor{roseyellow}{RGB}{222,205,99}
+\definecolor{roseblue}{RGB}{167,188,214}
+\definecolor{rosenavy}{RGB}{79,117,139}
+\definecolor{roseorange}{RGB}{232,119,34}
+\definecolor{rosegreen}{RGB}{61,68,30}
+\definecolor{rosewhite}{RGB}{223,209,167}
+\definecolor{rosebrown}{RGB}{108,87,27}
+\definecolor{rosegray}{RGB}{84,88,90}
+
+\definecolor{codegreen}{HTML}{49BE25}
+
+\newtcolorbox{codebox}[1][sidebyside]{
+ enhanced,skin=bicolor,
+ #1,
+ arc=1pt,
+ colframe=brown,
+ colback=brown!15,colbacklower=white,
+ boxrule=1pt,
+ notitle
+}
+
+\newtcolorbox{codehead}[1][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1
+}
+
+\usepackage{varwidth}
+
+\newtcolorbox{newcodehead}[2][]{
+ enhanced,
+ frame hidden,
+ colback=rosegray!15,
+ boxrule=0mm,
+ leftrule=5mm,
+ rightrule=5mm,
+ boxsep=0mm,
+ arc=0mm,
+ outer arc=0mm,
+ left=3mm,
+ right=3mm,
+ top=1mm,
+ bottom=1mm,
+ toptitle=1mm,
+ bottomtitle=1mm,
+ oversize,
+ #1,
+ fonttitle=\bfseries\ttfamily\footnotesize,
+ coltitle=rosegray,
+ attach boxed title to top text right,
+ boxed title style={frame hidden,size=small,bottom=-1mm,
+ interior style={fill=none,
+ top color=white,
+ bottom color=white}},
+ title={#2}
+}
+
+
+\makeindex
+
+\newcommand{\coderef}[2]{%
+\begin{codehead}[sidebyside,segmentation hidden]%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{codehead}%
+}
+
+\newcommand{\newcoderef}[3]{%
+\begin{newcodehead}[sidebyside,segmentation hidden]{#3}%
+ \mintinline{lua}{#1}%
+ \tcblower%
+ \begin{flushright}%
+ \mintinline{lua}{#2}%
+ \end{flushright}%
+\end{newcodehead}%
+}
+
+\begin{document}
+
+\subsection{Core Methods}
+
+Any of the methods below can be used within \mintinline{latex}{\begin{CAS}..\end{CAS}}. There are times when the parser or \LaTeX{} front-end allows for simpler syntax or usability.
+
+\coderef{function Expression:autosimplify()}{return Expression|table<number, Expression>}
+\index{Core!Methods!\texttt{autosimplify}}
+\addcontentsline{toc}{subsubsection}{\ttfamily autosimplify}
+
+Performs fast simplification techniques on an expression. The return depends on the type of input \texttt{Expression}. Generally, one should call {\ttfamily autosimplify()} on expressions before applying other core methods to them.
+
+Consider the code:
+
+\begin{minted}{latex}
+\begin{CAS}
+ vars('x','y','z')
+ w = x/y + y/z + z/x
+\end{CAS}
+\[ \print{w} = \print{w:autosimplify()} \]
+\end{minted}
+\begin{CAS}
+ vars('x','y','z')
+ w = x/y + y/z + z/x
+\end{CAS}
+The output is as follows:
+\[ \print{w} = \print{w:autosimplify()} \]
+It seems that \texttt{autosimplify()} did nothing; but there are significant structural differences between \texttt{w} and \texttt{w:autosimplify()}:
+
+\begin{multicols}{2}
+ \begin{center}
+ \underline{Expression tree for \texttt{w}}
+
+ \parseforest{w}
+ \bracketset{action character = @}
+ \begin{forest}
+ for tree = {font = \ttfamily}
+ @\forestresult
+ \end{forest}
+
+ \underline{Expression tree for \texttt{w:autosimplify()}}
+
+ \parseforest{w:autosimplify()}
+ \bracketset{action character = @}
+ \begin{forest}
+ for tree = {font = \ttfamily}
+ @\forestresult
+ \end{forest}
+\end{center}
+\end{multicols}
+
+Ironically, the \emph{autosimplified} expression tree on the right looks more complicated than the one on the left! But one of the primary functions of \texttt{autosimplify()} is to take an expression (that truly could be input in a myriad of ways) and convert that expression into something \emph{anticipatable}.
+
+For example, suppose the user inputs:
+\begin{minted}{latex}
+\begin{CAS}
+ w = x/y + (z/x+y/z)
+\end{CAS}
+\end{minted}
+\begin{CAS}
+ w = x/y + (z/x+y/z)
+\end{CAS}
+In this case, the expression trees for \texttt{w} and \texttt{w:autosimplify()}, respectively, look as follows:
+
+\begin{multicols}{2}
+\begin{center}
+\parseforest{w}
+\bracketset{action character = @}
+\begin{forest}
+ for tree = {font = \ttfamily}
+ @\forestresult
+\end{forest}
+
+\parseforest{w:autosimplify()}
+\bracketset{action character = @}
+\begin{forest}
+ for tree = {font = \ttfamily}
+ @\forestresult
+\end{forest}
+\end{center}
+\end{multicols}
+{\bf Note:} \texttt{w:autosimplify()} is exactly the same as it was before despite the different starting point. This is an essential function of \texttt{autosimplify()}.
+
+\subsubsection*{Parsing}
+
+The starred variant of the \LaTeX{} command \mintinline{latex}{\print} will automatically apply the method \texttt{autosimplify()} to its argument:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ a = x+x/2
+\end{CAS}
+\[ \print{a} = \print*{a} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ a = x+x/2
+\end{CAS}
+\[ \print{a} = \print*{a} \]
+\end{codebox}
+Alternatively, you can call \texttt{autosimplify()} directly within \mintinline{latex}{\begin{CAS}..\end{CAS}}:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ a = (x+x/2):autosimplify()
+\end{CAS}
+\[ \print{a} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ a = (x+x/2):autosimplify()
+\end{CAS}
+\[ \print{a} \]
+\end{codebox}
+
+\coderef{function Expression:evaluate()}{return Expression}
+\index{Core!Methods!\texttt{evaluate}}
+\addcontentsline{toc}{subsubsection}{\ttfamily evaluate}
+
+Attempts to apply operations found in the expression tree of \texttt{Expression}. For instance, evaluating a {\ttfamily DerivativeExpression} applies the derivative operator with respect to the {\ttfamily symbol} field to its {\ttfamily expression} field. Evaluating a {\ttfamily BinaryOperation} with its {\ttfamily operation} field set to {\ttfamily ADD} returns the sum of the numbers in the {\ttfamily expressions} field, if possible. If the expression does not represent an operation or is unable to be evaluated, calling {\ttfamily evaluate()} on an expression returns itself.
+
+For example, the code:
+\begin{minted}{latex}
+\directlua{
+ x = Integer(1)/Integer(2)
+ y = Integer(2)/Integer(3)
+ z = BinaryOperation(BinaryOperation.ADD,{x,y})
+}
+\[ \print{z} = \print{z:evaluate()}.\]
+\end{minted}
+produces:
+\directlua{
+ x = Integer(1)/Integer(2)
+ y = Integer(2)/Integer(3)
+ z = BinaryOperation(BinaryOperation.ADD,{x,y})
+}
+\[ \print{z} = \print{z:evaluate()}.\]
+
+\subsubsection*{Parsing}
+
+Arithmetic like above is actually done automatically (via the \texttt{Ring} interface):
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ x = 1/2
+ y = 2/3
+ z = x+y
+\end{CAS}
+\[ z = \print{z} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ x = 1/2
+ y = 2/3
+ z = x+y
+\end{CAS}
+\[ z = \print{z} \]
+\end{codebox}
+
+Otherwise, the \texttt{evaluate()} method will attempt to evaluate all subexpressions, and then stop there:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ y = diff(x^2+x,x)+diff(2*x,x)
+ y = y:evaluate()
+\end{CAS}
+\[ \print{y} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ y = diff(x^2+x,x)+diff(2*x,x)
+ y = y:evaluate()
+\end{CAS}
+\[ \print{y} \]
+\end{codebox}
+Whereas \texttt{autosimplify()} will return $3+2x$; indeed, the \texttt{autosimplify()} method (usually) begins by applying \texttt{evaluate()} first.
+
+\coderef{function Expression:expand()}{return Expression}
+\index{Core!Methods!\texttt{expand}}
+\addcontentsline{toc}{subsubsection}{\ttfamily expand}
+
+Expands an expression, turning products of sums into sums of products.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x','y','z','w')
+ a = x+y
+ b = z+w
+ c = a*b
+\end{CAS}
+\[ \print{c} = \print{c:expand()} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x','y','z','w')
+ a = x+y
+ b = z+w
+ c = a*b
+\end{CAS}
+\[ \print{c} = \print{c:expand()} \]
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+There is an \texttt{expand()} function in the parser; though it calls the \texttt{autosimplify()} method first. So, for example, \mintinline{lua}{expand(c)} is equivalent to \mintinline{lua}{c:autosimplify():expand()}.
+
+\coderef{function Expression:factor()}{return Expression}
+\index{Core!Methods!\texttt{factor}}
+\addcontentsline{toc}{subsubsection}{\ttfamily factor}
+
+Factors an expression, turning sums of products into products of sums. For general \texttt{Expressions} this functionality is somewhat limited. For example:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ a = x-1
+ b = a*x+a
+\end{CAS}
+\[ \print{b} = \print{b:factor()} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x','y')
+ a = x-y
+ b = a*x+a*y
+\end{CAS}
+\[ \print{b} = \print{b:factor()} \]
+\end{codebox}
+On the other hand:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x','y')
+ a = x^2-y^2
+\end{CAS}
+\[ \print{a} = \print{a:factor()} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x','y')
+ a = x^2-y^2
+\end{CAS}
+\[ \print{a} = \print{a:factor()} \]
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+There is a \texttt{factor()} function in the parser that is more class-aware than the basic \texttt{:factor()} method mentioned here. For example:
+\begin{codebox}
+ \begin{minted}[fontsize = \small]{latex}
+\begin{CAS}
+ x = 12512
+\end{CAS}
+\[ \print{x:factor()} = \print{factor(x)} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ x = 12512
+\end{CAS}
+\[ \print{x:factor()} = \print{factor(x)} \]
+\end{codebox}
+
+\coderef{function Expression:freeof(symbol)}{return bool}
+\index{Core!Methods!\texttt{freeof}}
+\addcontentsline{toc}{subsubsection}{\ttfamily freeof}
+
+Determines whether or not {\ttfamily Expression} contains a particular {\ttfamily symbol} somewhere in its expression tree.
+
+The method \texttt{freeof()} is quite literal. For example:
+\begin{codebox}
+\begin{minted}[fontsize=\small]{lua}
+vars('foo','bar')
+baz = foo+bar
+if baz:freeof(foo) then
+ tex.sprint(baz:tolatex(), " is free of ",
+ foo:tolatex(),"!")
+else
+ tex.sprint(baz:tolatex(), " is bound by ",
+ foo:tolatex(),".")
+end
+\end{minted}
+\tcblower
+\directlua{
+vars('foo','bar')
+baz = foo+bar
+if baz:freeof(foo) then
+ tex.sprint(baz:tolatex(), " is free of ",
+ foo:tolatex(),"!")
+else
+ tex.sprint(baz:tolatex(), " is bound by ",
+ foo:tolatex(),".")
+end
+}
+\end{codebox}
+On the other hand, the expression tree for \mintinline{lua}{SymbolExpression("foo")} contains a single node with no edges. With nary a \mintinline{lua}{SymbolExpression("fo")} to find in such an expression tree, we have:
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+vars('foo','fo')
+if foo:freeof(fo) then
+ tex.sprint(foo:tolatex()," is free of ",
+ fo:tolatex(),"!")
+else
+ tex.sprint(foo:tolatex()," is bound by ",
+ fo:tolatex(),'.')
+end
+ \end{minted}
+ \tcblower
+ \directlua{
+vars('foo','fo')
+if foo:freeof(fo) then
+ tex.sprint(foo:tolatex()," is free of ",
+ fo:tolatex(),"!")
+else
+ tex.sprint(foo:tolatex()," is bound by ",
+ fo:tolatex(),'.')
+end
+}
+ \end{codebox}
+
+\coderef{function Expression:isatomic()}{return bool}
+\index{Core!Methods!\texttt{isatomic}}
+\addcontentsline{toc}{subsubsection}{\ttfamily isatomic}
+
+Determines whether an expression is \emph{atomic}. Typically, atomicity is measured by whether the \texttt{Expression} has any subexpression fields. So, for example, \texttt{Integer(5)} and \texttt{Integer(15)} are atomic, and so is \texttt{Integer(20)}. But:
+\begin{minted}{lua}
+BinaryOperation(BinaryOperation.ADD,
+ {Integer(5),Integer(15)})
+\end{minted}
+is non-atomic.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+x = SymbolExpression("x")
+y = x*x+x
+if x:isatomic() then
+ tex.print(tostring(x),"is atomic;")
+end
+if not y:isatomic() then
+ tex.print(tostring(y),"is compound.")
+end
+\end{minted}
+\tcblower
+\directlua{
+x = SymbolExpression("x")
+y = x*x+x
+if x:isatomic() then
+ tex.print(tostring(x),"is atomic;")
+end
+if not y:isatomic() then
+ tex.print(tostring(y),"is compound.")
+end
+}
+\end{codebox}
+Since \texttt{SymbolExpression} inherits from \texttt{AtomicExpression}, we have that \texttt{isatomic()} is taken literally as well. For example:
+\begin{codebox}
+ \begin{minted}[fontsize=\small,breaklines]{lua}
+y = SymbolExpression("x*x+x")
+if not y:isatomic() then
+ tex.print(tostring(y),"is compound.")
+else
+ tex.print("But",tostring(y),"is atomic,
+ from a certain point of view.")
+end
+\end{minted}
+\tcblower
+\directlua{
+ y = SymbolExpression("x*x+x")
+if not y:isatomic() then
+ tex.print(tostring(y),"is compound.")
+else
+ tex.print("But",tostring(y),"is atomic,
+ from a certain point of view.")
+end
+}
+\end{codebox}
+\vskip 0.2cm
+
+\coderef{function Expression:iscomplexconstant()}{return bool}
+\index{Core!Methods!\texttt{iscomplexconstant}}
+\addcontentsline{toc}{subsubsection}{\ttfamily iscomplexconstant}
+
+Determines whether an expression is a complex number in the mathematical sense, such as $3 + \sqrt{2}i$. It's helpful to keep in mind that, oftentimes, content needs to be simplified/evaluated in order to obtain the intended results:
+
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{lua}
+a = (Integer.one() + I) ^ Integer(2)
+if a:iscomplexconstant() then
+ tex.print("$",a:tolatex(),"$ is a complex constant.")
+else
+ tex.print("$",a:tolatex(),"$ is not a complex constant.")
+end
+\end{minted}
+\tcblower
+\begin{center}
+\luaexec{
+ a = (Integer.one() + I) ^ Integer(2)
+ if a:iscomplexconstant() then
+ tex.print("$",a:tolatex(),"$ is a complex constant.")
+ else
+ tex.print("$",a:tolatex(),"$ is not a complex constant.")
+ end
+}
+\end{center}
+\end{codebox}
+While:
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{lua}
+a = (Integer.one()+I) ^ Integer(2)
+a = a:expand():simplify()
+if a:iscomplexconstant() then
+ tex.print("$",a:tolatex(),"$ is a complex constant.")
+else
+ tex.print("$",a:tolatex(),"$ is not a complex constant.")
+end
+\end{minted}
+\tcblower
+\begin{center}
+\luaexec{
+ a = (Integer.one()+I) ^ Integer(2)
+ a = a:expand():simplify()
+ if a:iscomplexconstant() then
+ tex.print("$",a:tolatex(),"$ is a complex constant.")
+ else
+ tex.print("$",a:tolatex(),"$ is not a complex constant.")
+ end
+}
+\end{center}
+\end{codebox}
+
+\coderef{function Expression:isconstant()}{return bool}
+\index{Core!Methods!\texttt{isconstant}}
+\addcontentsline{toc}{subsubsection}{\ttfamily isconstant}
+
+Determines whether an expression is atomic and contains no variables. This method is counterintuitive in some cases. For instance:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+if not pi:isconstant() then
+ tex.print("$\\pi$ is not constant.")
+end
+\end{minted}
+\tcblower
+\luaexec{
+if not pi:isconstant() then
+ tex.print("$\\pi$ is not constant.")
+end
+}
+\end{codebox}
+This is because {\ttfamily isconstant()} is meant to check for certain autosimplification transformations that can be performed on arbitrary {\ttfamily Ring} elements but not on those constants. Use {\ttfamily isrealconstant()} for what mathematicians think of as constants.
+
+\coderef{function Expression:isrealconstant()}{return bool}
+\index{Core!Methods!\texttt{isrealconstant}}
+\addcontentsline{toc}{subsubsection}{\ttfamily isrealconstant}
+
+Determines whether an expression is a real number in the mathematical sense, such as $2$, $\sqrt{5}$, or $\sin(3)$. For example:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{lua}
+if pi:isrealconstant() then
+ tex.print("$\\pi$ is a real constant.")
+end
+\end{minted}
+\tcblower
+\luaexec{
+ if pi:isrealconstant() then
+ tex.print("$\\pi$ is a real constant.")
+ end
+}
+\end{codebox}
+
+\coderef{function Expression:order(Expression)}{return boolean}
+\index{Core!Methods!\texttt{order}}
+\addcontentsline{toc}{subsubsection}{\ttfamily order}
+
+For the goals of autosimplification, \texttt{Expression}s must be ordered. \texttt{Expression:order(other)} method returns \mintinline{lua}{true} if \texttt{Expression} is ``less than'' \texttt{other} according to this ordering.
+
+\begin{multicols}{2}
+On certain classes, the ordering is intuitive:
+
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{lua}
+a = 4
+b = 3
+if a:order(2) then
+ tex.print(a:tolatex(),
+ "is less than",
+ b:tolatex())
+else
+ tex.print(b:tolatex(),
+ "is less than",
+ a:tolatex())
+end
+\end{minted}
+\tcblower
+\begin{CAS}
+ a = 4
+ b = 3
+ if a:order(2) then
+ tex.print(a:tolatex(),
+ "is less than",
+ b:tolatex())
+ else
+ tex.print(b:tolatex(),
+ "is less than",
+ a:tolatex())
+ end
+\end{CAS}
+\end{codebox}
+
+\columnbreak
+
+On \texttt{SymbolExpression}s, the ordering is lexigraphic:
+
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{lua}
+vars('a')
+vars('b')
+if b:order(a) then
+ tex.print(b:tolatex(),
+ "is less than",
+ a:tolatex())
+else
+ tex.print(a:tolatex(),
+ "is less than",
+ b:tolatex())
+end
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('a','b')
+ if b:order(a) then
+ tex.print(b:tolatex(),
+ "is less than",
+ a:tolatex())
+ else
+ tex.print(a:tolatex(),
+ "is less than",
+ b:tolatex())
+ end
+\end{CAS}
+\end{codebox}
+\end{multicols}
+
+Of course, inter-class comparisons can be made as well -- but these are predominantly dictated by typesetting conventions.
+
+\coderef{function Expression:setsubexpressions(subexpressions)}{return Expression}
+\index{Core!Methods!\texttt{setsubexpressions}}
+\addcontentsline{toc}{subsubsection}{\ttfamily setsubexpressions}
+
+Creates a copy of an expression with the list of subexpressions as its new subexpressions. This can reduce code duplication in other methods.
+
+
+\coderef{function Expression:simplify()}{return Expression}
+\index{Core!Methods!\texttt{simplify}}
+\addcontentsline{toc}{subsubsection}{\ttfamily simplify}
+
+Performs more extensive simplification of an expression. This may be slow, so this function is separate from autosimplification and is not called unless the user specifically directs the CAS to do so. The method aims to find an expression tree equivalent to the one given that is ``smaller'' in size as measured by the number of nodes in the expression tree.
+
+The \texttt{simplify()} method does call the \texttt{autosimplify()} method first. Here's an example of where the results of \texttt{autosimplify()} and \texttt{simplify()} differ:
+
+\begin{minted}[breaklines]{latex}
+\begin{CAS}
+ vars('x')
+ a = 1-x+0*x
+ b = 1+1*x
+ c = a*b
+\end{CAS}
+\[ \print{c} = \print{c:autosimplify()} = \print{c:simplify()}. \]
+\end{minted}
+The code above produces:
+\begin{CAS}
+ vars('x')
+ a = 1-x+0*x
+ b = 1+1*x
+ c = a*b
+\end{CAS}
+\[ \print{c} = \print{c:autosimplify()} = \print{c:simplify()}. \]
+
+\subsubsection*{Parsing}
+
+There is a \texttt{simplify()} function for those unfamiliar with Lua methods. So, for example, \mintinline{lua}{c:simplify()} is equivalent to \mintinline{lua}{simplify(c)}.
+
+\coderef{function Expression:size()}{return Integer}
+\index{Core!Methods!\texttt{size}}
+\addcontentsline{toc}{subsubsection}{\ttfamily size}
+
+Returns the number of nodes of the tree that constitutes an expression, or roughly the total number of expression objects that make up the expression.
+
+For example, consider:
+\begin{minted}{latex}
+\begin{CAS}
+ vars('x')
+ a = (1-x+0*x)
+ b = (1+1*x)
+ c = a*b
+\end{CAS}
+\end{minted}
+\begin{CAS}
+ vars('x')
+ a = (1-x+0*x)
+ b = (1+1*x)
+ c = a*b
+\end{CAS}
+Then the expression trees for \texttt{c}, \texttt{c:autosimplify()}, and \texttt{c:simplify()} are as follows:
+
+\begin{multicols}{3}
+ \begin{center}
+ \underline{Tree for \texttt{c}:}
+\parseforest{c}
+\bracketset{action character = @}
+\begin{forest}
+ for tree = {font = \ttfamily}
+ @\forestresult
+\end{forest}
+
+\columnbreak
+
+\underline{Tree for \texttt{c:autosimplify()}:}
+\parseforest{c:autosimplify()}
+\bracketset{action character = @}
+\begin{forest}
+ for tree = {font = \ttfamily}
+ @\forestresult
+\end{forest}
+
+\columnbreak
+
+\underline{Tree for \texttt{c:simplify()}:}
+\parseforest{c:simplify()}
+\bracketset{action character = @}
+\begin{forest}
+ for tree = {font = \ttfamily}
+ @\forestresult
+\end{forest}
+\end{center}
+\end{multicols}
+Accordingly, we have:
+\begin{codebox}
+ \begin{minted}[breaklines,fontsize=\small]{lua}
+tex.print("The size of \\texttt{c} is",
+ tostring(c:size()),"\\newline")
+tex.print("The size of
+ \\texttt{c:autosimplify()} is",
+ tostring(c:autosimplify():size()), "\\newline")
+tex.print("The size of
+ \\texttt{c:simplify()} is",
+ tostring(c:simplify():size()))
+ \end{minted}
+ \tcblower
+ \luaexec{
+ tex.print("The size of \\texttt{c} is", tostring(c:size()),"\\newline")
+ tex.print("The size of \\texttt{c:autosimplify()} is", tostring(c:autosimplify():size()), "\\newline")
+ tex.print("The size of \\texttt{c:simplfy()} is", tostring(c:simplify():size()))
+}
+\end{codebox}
+\vskip 0.2cm
+
+\coderef{function Expression:subexpressions()}{return table<number, Expression>}
+\index{Core!Methods!\texttt{subexpressions}}
+\addcontentsline{toc}{subsubsection}{\ttfamily subexpressions}
+
+Returns a list of all subexpressions of an expression. This gives a unified interface to the instance variables for subexpressions, which have different names across classes. For example, consider:
+\begin{codebox}
+\begin{minted}[breaklines,fontsize=\footnotesize]{latex}
+\begin{CAS}
+ vars('x','y','z')
+ a = x*y+y*z
+ b = int(sin(x),x,0,pi/2)
+\end{CAS}
+\[ a = \print{a} \quad \text{and} \quad b=\print{b}.\]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x','y','z')
+ a = x*y+y*z
+ b = int(sin(x),x,0,pi/2)
+\end{CAS}
+\[ a = \print{a} \quad \text{and} \quad b=\print{b}.\]
+\end{codebox}
+Here are the expression shrubs for \texttt{a} and \texttt{b}:
+
+\begin{multicols}{2}
+\begin{center}
+ \underline{Expression shrub for \texttt{a}}
+
+ \parseshrub{a}
+ \bracketset{action character = @}
+ \begin{forest}
+ for tree = {draw,
+ rectangle,
+ rounded corners=1pt,
+ fill=gray!10,
+ s sep = 2cm,
+ font=\ttfamily}
+ @\shrubresult
+ \end{forest}
+
+ \underline{Expression shrub for \texttt{b}}
+
+\parseshrub{b}
+\bracketset{action character = @}
+\begin{forest}
+ for tree = {draw,
+ rectangle,
+ rounded corners=1pt,
+ fill=gray!10,
+ s sep = 1cm,
+ font=\ttfamily}
+ @\shrubresult
+\end{forest}
+\end{center}
+\end{multicols}
+On the other hand:
+\begin{codebox}
+\begin{minted}[breaklines,fontsize=\small]{lua}
+for _,expr in ipairs(a:subexpressions()) do
+ tex.print("$", expr:tolatex(), "$\\quad")
+end
+\end{minted}
+\tcblower
+\luaexec{
+ for _,expr in ipairs(a:subexpressions()) do
+ tex.print("$", expr:tolatex(), "$\\quad")
+ end
+}
+\end{codebox}
+while:
+\begin{codebox}
+\begin{minted}[breaklines,fontsize=\small]{lua}
+for _,expr in ipairs(b:subexpressions()) do
+ tex.print("$", expr:tolatex(), "$\\quad")
+end
+\end{minted}
+\tcblower
+\luaexec{
+ for _,expr in ipairs(b:subexpressions()) do
+ tex.print("$",expr:tolatex(),"$\\quad")
+ end
+}
+\end{codebox}
+\vskip 0.2cm
+
+\coderef{function Expression:substitute(map)}{return Expression}
+\index{Core!Methods!\texttt{substitute}}
+\addcontentsline{toc}{subsubsection}{\ttfamily substitute}
+
+The input \texttt{map} is a table that maps expressions to expressions; the method then recursively maps each instance of an expression with its corresponding table expression. One should take care when replacing multiple compound expressions in a single command, since there is no guarantee as to the order in which subexpressions in the table are replaced.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('foo','bar','baz')
+ qux = (foo/bar)
+ qux = qux:substitute({[foo]=bar,[bar]=baz})
+\end{CAS}
+\[ \print{qux} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('foo','bar','baz')
+ qux = (foo/bar)
+ qux = qux:substitute({[foo]=bar,[bar]=baz})
+ \end{CAS}
+ \[ \print{qux} \]
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+There is a \texttt{substitute()} function with a slightly more user-friendly syntax. In particular,
+
+\mintinline{lua}{(foo/bar):substitute({[foo]=bar,[bar]=baz})}
+
+is equivalent to
+
+\mintinline{lua}{substitute({[foo]=bar,[bar]=baz}, foo/bar)}
+
+\coderef{function Expression:tolatex()}{return string}
+\index{Core!Methods!\texttt{tolatex}}
+\addcontentsline{toc}{subsubsection}{\ttfamily tolatex}
+
+Converts an expression to \LaTeX{} code. Some folks have strong feelings about how certain things are typeset. Case and point, which of these is your favorite:
+\[ \int \sin(\frac{y}{2})dy \qquad \int \sin\left( \frac{y}{2} \right)dy \qquad \int \sin\left( \frac{y}{2} \right)\, dy \qquad \int \sin\!\left( \frac{y}{2} \right)\, dy \qquad \int \sin\!\left( \frac{y}{2} \right) \mathop{\mathrm{d}y} \qquad \int \sin\mathopen{}\left( \frac{y}{2} \right) \mathop{dy} \quad ?\]
+We've tried to remain neutral:
+
+\begin{codebox}
+\begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('y')
+ f = diff(int(sin(y/2),y),y)
+\end{CAS}
+\[ \print{f} \]
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('y')
+ f = diff(int(sin(y/2),y),y)
+\end{CAS}
+\[ \print{f} \]
+\end{codebox}
+With any luck, we've pleased at least as many people as we've offended. In desperate times, one could rewrite the \texttt{tolatex()} method for any given class. Here, for example, is the \texttt{tolatex()} method as written for the \texttt{DerivativeExpression} class:
+\begin{minted}[breaklines]{lua}
+function DerivativeExpression:tolatex()
+ return '\\frac{d}{d' .. self.symbol:tolatex() .. '}\\left(' .. self.expression:tolatex() .. '\\right)'
+end
+\end{minted}
+But there are heathens that live among us who might prefer:
+\begin{minted}[breaklines]{lua}
+function DerivativeExpression:tolatex()
+ return '\\frac{\\mathrm{d}}{\\mathrm{d}' .. self.symbol:tolatex() .. '}\\left(' .. self.expression:tolatex() .. '\\right)'
+end
+\end{minted}
+If we include the above function in a separate file, say \texttt{mytex.lua}, and use:
+
+\mintinline{latex}{\directlua{dofile('mytex.lua')}}
+
+or include the above function directly into the document via \mintinline{latex}{\directlua} or \mintinline{latex}{\luaexec}, then we would get:
+\begin{codebox}
+\begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = DerivativeExpression(y+sin(y),y)
+\end{CAS}
+\[ \print{f} \]
+\end{minted}
+\tcblower
+\[ \frac{\mathrm{d}}{\mathrm{d}y} \left( y + \sin\mathopen{}\left(y\right) \right).\]
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+The \LaTeX{} command \mintinline{latex}{\print} calls the method \mintinline{lua}{tolatex()} unto its argument and uses \mintinline{lua}{tex.print()} to display the results. The starred variant \mintinline{latex}{\print*} applies the \texttt{autosimplify()} method before applying \mintinline{lua}{tolatex()}.
+
+Additionally, one can use the \texttt{disp()} function within \mintinline{latex}{\begin{CAS}..\end{CAS}}.
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ f = DerivativeExpression(y+sin(y),y)
+ disp(f)
+\end{CAS}
+\end{minted}
+\tcblower
+\begin{CAS}
+ f = DerivativeExpression(y+sin(y),y)
+ disp(f)
+\end{CAS}
+\end{codebox}
+
+The function \texttt{disp} takes two optional boolean arguments both are set to \texttt{false} by default. The first optional boolean controls \emph{inline} vs \emph{display} mode; the second optional boolean controls whether the method \texttt{autosimplify()} is called before printing:
+
+\begin{multicols}{3}
+ \begin{codebox}[]
+\begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ disp(f,true)
+\end{CAS}
+\end{minted}
+\tcblower
+\begin{CAS}
+ disp(f,true)
+\end{CAS}
+\end{codebox}
+ \begin{codebox}[]
+\begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ disp(f,true,true)
+\end{CAS}
+\end{minted}
+\tcblower
+\begin{CAS}
+ disp(f,true,true)
+\end{CAS}
+\end{codebox}
+ \begin{codebox}[]
+\begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ disp(f,false,true)
+\end{CAS}
+\end{minted}
+\tcblower
+\begin{CAS}
+ disp(f,false,true)
+\end{CAS}
+\end{codebox}
+\end{multicols}
+
+
+\coderef{function Expression:topolynomial()}{return Expression | bool}
+\index{Core!Methods!\texttt{topolynomial}}
+\addcontentsline{toc}{subsubsection}{\ttfamily topolynomial}
+
+Attempts to cast \texttt{Expression} into a polynomial type ({\ttfamily PolynomialRing}); there are multiple outputs. The first output is \texttt{self} or \texttt{PolynomialRing}; the second output is \mintinline{lua}{false} or \mintinline{lua}{true}, respectively. \texttt{PolynomialRing} is the name of the class that codifies univariate polynomials proper.
+
+Polynomial computations tend to be significantly faster when those polynomials are stored as arrays of coefficients (as opposed to, say, when they are stored as generic \texttt{BinaryOperation}s). Hence the need for a method like \texttt{topolynomial()}.
+
+{\bf Warning:} the \texttt{topolynomial()} method expects the input to be autosimplified. For example:
+
+\begin{multicols}{2}
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = 3+2*x+x^2
+ f,b = f:topolynomial()
+ if b then
+ tex.print("\\[",f:tolatex(),"\\]")
+ else
+ tex.print("womp womp")
+ end
+\end{CAS}
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = 3+2*x+x^2
+ f,b = f:topolynomial()
+ if b then
+ tex.print("\\[",f:tolatex(),"\\]")
+ else
+ tex.print("\\[ \\text{womp womp} \\]")
+ end
+\end{CAS}
+\end{codebox}
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = 3+2*x+x^2
+ f,b = f:autosimplify():topolynomial()
+ if b then
+ tex.print("\\[",f:tolatex(),"\\]")
+ else
+ tex.print("womp womp")
+ end
+\end{CAS}
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = 3+2*x+x^2
+ f,b = f:autosimplify():topolynomial()
+ if b then
+ tex.print("\\[",f:tolatex(),"\\]")
+ else
+ tex.print("\\[ \\text{womp womp} \\]")
+ end
+\end{CAS}
+\end{codebox}
+\end{multicols}
+
+\subsubsection*{Parsing}
+
+There is a \mintinline{lua}{topoly()} function that applies \mintinline{lua}{:autosimplify()} automatically to the input. For example:
+\begin{codebox}[]
+ \begin{minted}[fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ f = 3+2*x+x^2
+ f = topoly(f)
+\end{CAS}
+The Lua variable \texttt{f} is the \whatis{f}: $\print{f}$.
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ f = 3+2*x+x^2
+ f = topoly(f)
+\end{CAS}
+The Lua variable \texttt{f} is the \whatis{f}: $\print{f}$.
+\end{codebox}
+
+
+\coderef{function Expression:type()}{return Expression | bool}
+\index{Core!Methods!\texttt{type}}
+\addcontentsline{toc}{subsubsection}{\ttfamily type}
+
+Returns the \mintinline{lua}{__index} field in the metatable for \texttt{Expression}. In other words, this function returns the type of \texttt{Expression}. Here's typical usage:
+
+\begin{codebox}
+ \begin{minted}[breaklines,fontsize=\small]{latex}
+\begin{CAS}
+ vars('x')
+ if x:type() == SymbolExpression then
+ tex.print(x:tolatex(), "is a SymbolExpression.")
+ end
+\end{CAS}
+\end{minted}
+\tcblower
+\begin{CAS}
+ vars('x')
+ if x:type() == SymbolExpression then
+ tex.print(x:tolatex(), "is a SymbolExpression.")
+ end
+\end{CAS}
+\end{codebox}
+
+\subsubsection*{Parsing}
+
+The \LaTeX{} command \mintinline{latex}{\whatis} can be used to print the type of \texttt{Expression}:
+
+\begin{codebox}
+ \begin{minted}[fontsize=\small]{latex}
+x is a \whatis{x}
+ \end{minted}
+ \tcblower
+ x is a \whatis{x}
+\end{codebox}
+
+Alternatively, there's a \mintinline{lua}{whatis()} function and a \mintinline{lua}{longwhatis()} function that can be called within a Lua environment (like \mintinline{latex}{\directlua} or \mintinline{latex}{\luaexec}):
+
+\begin{codebox}
+\begin{minted}[fontsize=\small]{lua}
+tex.print(whatis(x), '\\newline')
+tex.print(longwhatis(x))
+\end{minted}
+\tcblower
+\directlua{
+ tex.print(whatis(x), '\\newline')
+ tex.print(longwhatis(x))
+}
+\end{codebox}
+
+
+
+
+\end{document} \ No newline at end of file