\label{Authoring_Daxe_Math}

\textbf{LON-CAPA math syntax}

As usual, the \texttt{$<$m$>$} element can be used for math with a LaTeX syntax. It can be inserted with the \texttt{\$} button in the toolbar or the \texttt{ctrl-T} shortcut.

Daxe also supports a new LON-CAPA element: the \texttt{$<$lm$>$} element, which allows for a simpler syntax for math. To use the \texttt{$<$lm$>$} element to insert a math expression use the √x button or the \texttt{ctrl-E} shortcut. In the future this syntax may also be used to evaluate \texttt{$<$formularesponse$>$}, but for now its use in \texttt{$<$formularresponse$>$} is limited to the real-time preview of the expression entered in the answer textbox.

Below is a description of the syntax used by \texttt{$<$lm$>$} for displaying math (there is more to this syntax when it is used for evaluation, which is not described here).

Since it can be used for evaluation, it describes mathematical operations rather than appearance (as opposed to LaTeX, which describes how the math should \emph{appear}). Display is the same when the math operations are the same, for instance \texttt{2*(x)} will be displayed just like \texttt{2x}. One advantage to that system is that math will be displayed in a consistent way; disadvantages are that display cannot be chosen precisely, and also the \texttt{$<$lm$>$} element will only be available on servers running LON-CAPA 2.12 (and for now, only at MSU where a modified 2.11.4 with some 2.12 features included, pre-release, has been deployed).
\begin{description}
        \item[\textmd{\normalsize\textit{Spaces}}]

Spaces are always ignored.
        \item[\textmd{\normalsize\textit{Decimal separators and function parameter separators}}]

To keep compatible with previous \texttt{$<$formularesponse$>$} syntax, only \texttt{``.''} can be used as a decimal separator, and \texttt{``,''} is used to separate function and vector/matrix parameters.
        \item[\textmd{\normalsize\textit{Variables and constants}}]

Variable names and constant names are used directly, without any special character before. They are displayed in italics.
        \item[\textmd{\normalsize\textit{Units}}]

Unit names are used directly. They are displayed with a straight font. LON-CAPA has a list of known units and a list of known constants to differentiate them in units mode.
        \item[\textmd{\normalsize\textit{Parenthesis}}]

Parenthesis can be used to specify evaluation order. They are only displayed when necessary.
        \item[\textmd{\normalsize\textit{Operators}}]
\begin{itemize}
        \item arithmetic: \texttt{+ - * / \^{} }
\\
        \item factorial: \texttt{!}
        \item relational: \texttt{= \# $<$ $<$= $>$= $>$}
        \item units: \texttt{`}
\\ Example: \texttt{2`m + 3`m = 5`m}
        \item scalar product for vectors, multiplication for matrices: \texttt{.}
\end{itemize}
        \item[\textmd{\normalsize\textit{Implicit operators}}]

\texttt{*} and \texttt{`} are implicit.

The parser will try to guess which operator is missing whenever possible. The choice between \texttt{*} and \texttt{`} depends on the mode for interpreting equations.

Example: \texttt{2c+3m/s} is understood in unit mode to be \texttt{2*c + 3`(m/s)}. In symbolic mode, it would be interpreted \texttt{2*c + (3*m)/s} (\texttt{m} and \texttt{s} being variables).
        \item[\textmd{\normalsize\textit{Functions}}]

Functions use the syntax \texttt{f(a,b)}.
\begin{itemize}
        \item basic:
\begin{verbatim}
sqrt(x), abs(x), exp(x)=e^x, factorial(x)=x!\end{verbatim}
        \item binomial (displayed like a vector):
\begin{verbatim}
binomial(n,p)=n!/(p!*(n-p)!)\end{verbatim}
        \item sum and product (requiring symbolic mode):
\begin{verbatim}
sum(f(x),x,x1,x2), product(f(x),x,x1,x2)\end{verbatim}
        \item differential, integral, limit:
\begin{verbatim}
diff(expr, x, n), integrate(expr, x, a, b), limit(expr, x, val, plus/minus)\end{verbatim}
\end{itemize}
        \item[\textmd{\normalsize\textit{Vectors and matrices}}]

Vectors and matrices are defined with square brackets. A matrix is made of a list of row vectors.
\begin{itemize}
        \item vectors: \texttt{[1,2,3]}
        \item matrices: \texttt{[[1,2],[3,4]]}
\end{itemize}
        \item[\textmd{\normalsize\textit{Sets}}]

Sets are defined with curly brackets: \texttt{\{1,2,3\}}

Operators:
\begin{itemize}
        \item union: \texttt{union(\{1,2\},\{1,3\}) = \{1,2,3\}}
        \item intersection: \texttt{intersection(\{1,2\},\{1,3\}) = \{1\}}
\end{itemize}
\end{description}
