Annotation of loncom/html/adm/help/tex/Authoring_Daxe_Math.tex, revision 1.2
1.2 ! raeburn 1: \label{Authoring_Daxe_Math}
1.1 raeburn 2:
3: \textbf{LON-CAPA math syntax}
4:
5: 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.
6:
7: 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.
8:
9: 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).
10:
11: 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).
12: \begin{description}
13: \item[\textmd{\normalsize\textit{Spaces}}]
14:
15: Spaces are always ignored.
16: \item[\textmd{\normalsize\textit{Decimal separators and function parameter separators}}]
17:
18: 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.
19: \item[\textmd{\normalsize\textit{Variables and constants}}]
20:
21: Variable names and constant names are used directly, without any special character before. They are displayed in italics.
22: \item[\textmd{\normalsize\textit{Units}}]
23:
24: 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.
25: \item[\textmd{\normalsize\textit{Parenthesis}}]
26:
27: Parenthesis can be used to specify evaluation order. They are only displayed when necessary.
28: \item[\textmd{\normalsize\textit{Operators}}]
29: \begin{itemize}
30: \item arithmetic: \texttt{+ - * / \^{} }
31: \\
32: \item factorial: \texttt{!}
33: \item relational: \texttt{= \# $<$ $<$= $>$= $>$}
34: \item units: \texttt{`}
35: \\ Example: \texttt{2`m + 3`m = 5`m}
36: \item scalar product for vectors, multiplication for matrices: \texttt{.}
37: \end{itemize}
38: \item[\textmd{\normalsize\textit{Implicit operators}}]
39:
40: \texttt{*} and \texttt{`} are implicit.
41:
42: 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.
43:
44: 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).
45: \item[\textmd{\normalsize\textit{Functions}}]
46:
47: Functions use the syntax \texttt{f(a,b)}.
48: \begin{itemize}
49: \item basic:
50: \begin{verbatim}
51: sqrt(x), abs(x), exp(x)=e^x, factorial(x)=x!\end{verbatim}
52: \item binomial (displayed like a vector):
53: \begin{verbatim}
54: binomial(n,p)=n!/(p!*(n-p)!)\end{verbatim}
55: \item sum and product (requiring symbolic mode):
56: \begin{verbatim}
57: sum(f(x),x,x1,x2), product(f(x),x,x1,x2)\end{verbatim}
58: \item differential, integral, limit:
59: \begin{verbatim}
60: diff(expr, x, n), integrate(expr, x, a, b), limit(expr, x, val, plus/minus)\end{verbatim}
61: \end{itemize}
62: \item[\textmd{\normalsize\textit{Vectors and matrices}}]
63:
64: Vectors and matrices are defined with square brackets. A matrix is made of a list of row vectors.
65: \begin{itemize}
66: \item vectors: \texttt{[1,2,3]}
67: \item matrices: \texttt{[[1,2],[3,4]]}
68: \end{itemize}
69: \item[\textmd{\normalsize\textit{Sets}}]
70:
71: Sets are defined with curly brackets: \texttt{\{1,2,3\}}
72:
73: Operators:
74: \begin{itemize}
75: \item union: \texttt{union(\{1,2\},\{1,3\}) = \{1,2,3\}}
76: \item intersection: \texttt{intersection(\{1,2\},\{1,3\}) = \{1\}}
77: \end{itemize}
78: \end{description}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>