This page copied from: help in R-project - by Philippe Grosjean ]]
ASCIIMathML is a very simple way to enter nicely formatted mathematical equations in a Wiki document (as well as in any HTML page).
The main aims of the ASCIIMathML syntax are: – 1. close to standard mathematical notation – 2. easy to read – 3. easy to type
Always enclose your equations between double dollar signs. If you type things like:
$$x^2$$ or $$a_(mn)$$ or $$a_{mn}$$ or $$(x+1)/y$$ or $$sqrtx$$
…You pretty much get what you expect: $$x^2$$ or $$a_(mn)$$ or $$a_{mn}$$ or $$(x+1)/y$$ or $$sqrtx$$. The choice of grouping parenthesis is up to you (they don't have to match either). If the displayed expression can be parsed uniquely without them, they are omitted. Printing the list of constant symbols (below) may be helpful (but is not necessary if you know the LaTeX equivalents, because ASCIIMathML also understands LaTeX commands).
The remainder of this page gives a fairly detailed specification of the ASCII syntax. The expressions described here correspond to a wellspecified subset of Presentation MathML and behave in a predictable way.
The syntax is very permissive and does not generate syntax errors. This allows mathematically incorrect expressions to be displayed, which is important for teaching purposes. It also causes less frustration when previewing formulas.
The parser uses no operator precedence and only respects the grouping brackets, subscripts, superscript, fractions and (square) roots. This is done for reasons of efficiency and generality. The resulting MathML code can quite easily be processed further to ensure additional syntactic requirements of any particular application.
Here is a definition of the grammar used to parse ASCIIMathML expressions. In the Backus-Naur form given below, the letter on the left of the ::= represents a category of symbols that could be one of the possible sequences of symbols listed on the right. The vertical bar | separates the alternatives.
c ::= [A-z] | numbers | greek letters | other constant symbols (see below)
u ::= 'sqrt' | 'text' | 'bb' | other unary symbols for font commands
b ::= 'frac' | 'root' | 'stackrel' binary symbols
l ::= ( | [ | { | (: | {: left brackets
r ::= ) | ] | } | :) | :} right brackets
S ::= c | lEr | uS | bSS | "any" simple expression
E ::= SE | S/S |S_S | S^S | S_S^S expression (fraction, sub-, super-, subsuperscript)
l($$S_(11)$$,...,$$S_(1n)$$),(...),($$S_(m1)$$,...,$$S_(mn)$$)r or l[$$S_(11)$$,...,$$S_(1n)$$],[...],[$$S_(m1)$$,...,$$S_(mn)$$]r.
Here 'l' and 'r' stand for any of the left and right brackets (just like in the grammar they do not have to match). For example:
{(S_(11),...,S_(1n)),(vdots,ddots,vdots),(S_(m1),...,S_(mn))]
displays as $${(S_(11),…,S_(1n)),(vdots,ddots,vdots),(S_(m1),…,S_(mn))]$$. Note that each row must have the same number of expressions, and there should be at least two rows.
A string of digits, optionally preceded by a minus sign, and optionally followed by a decimal point (a period) and another string of digits, is parsed as a single token and converted to a MathML number. If it is not desirable to have a preceding minus sign as operator in front of the number, a space should be inserted: $$x -1$$ (x -1) differs from $$x - 1$$ (x - 1), although it is mathematically the same expression.
alpha ⇒ $$alpha$$, beta ⇒ $$beta$$, chi ⇒ $$chi$$, delta ⇒ $$delta$$, Delta ⇒ $$Delta$$, epsilon ⇒ $$epsilon$$, varepsilon ⇒ $$varepsilon$$, eta ⇒ $$eta$$, gamma ⇒ $$gamma$$, Gamma ⇒ $$Gamma$$, iota ⇒ $$iota$$, kappa ⇒ $$kappa$$, lambda ⇒ $$lambda$$, Lambda ⇒ $$Lambda$$, mu ⇒ $$mu$$, nu ⇒ $$nu$$, omega ⇒ $$omega$$, Omega ⇒ $$Omega$$, phi ⇒ $$phi$$, varphi ⇒ $$varphi$$, Phi ⇒ $$Phi$$, pi ⇒ $$pi$$, Pi ⇒ $$Pi$$, psi ⇒ $$psi$$, Psi ⇒ $$Psi$$, rho ⇒ $$rho$$, sigma ⇒ $$sigma$$, Sigma ⇒ $$Sigma$$, tau ⇒ $$tau$$, theta ⇒ $$theta$$, vartheta ⇒ $$vartheta$$, Theta ⇒ $$Theta$$, upsilon ⇒ $$upsilon$$, xi ⇒ $$xi$$, Xi ⇒ $$Xi$$, zeta ⇒ $$zeta$$.
+ ⇒ $$+$$, - ⇒ $$-$$, * ⇒ $$*$$, * * ⇒ $$**$$, xx ⇒ $$xx$$, -: ⇒ $$-:$$, @ ⇒ $$@$$, o+ ⇒ $$o+$$, ox ⇒ $$ox$$, o. ⇒ $$o.$$, sum ⇒ $$sum$$, prod ⇒ $$prod$$, ^^ ⇒ $$^^$$, ^^^ ⇒ $$^^^$$, vv ⇒ $$vv$$, vvv ⇒ $$vvv$$, nn ⇒ $$nn$$, nnn ⇒ $$nnn$$, uu ⇒ $$uu$$, uuu ⇒ $$uuu$$.
= ⇒ $$=$$, != ⇒ $$!=$$, < ⇒ $$<$$, > ⇒ $$>$$, <= ⇒ $$<=$$, >= ⇒ $$>=$$, -< ⇒ $$-<$$, >- ⇒ $$>-$$, in ⇒ $$in$$, !in ⇒ $$!in$$, sub ⇒ $$sub$$, sup ⇒ $$sup$$, sube ⇒ $$sube$$, supe ⇒ $$supe$$, -= ⇒ $$-=$$, ~= ⇒ $$~=$$, ~~ ⇒ $$~~$$, prop ⇒ $$prop$$.
and ⇒ $$and$$, or ⇒ $$or$$, not ⇒ $$not$$, = > ⇒ $$⇒$$, if ⇒ $$if$$, iff ⇒ $$iff$$, AA ⇒ $$AA$$, EE ⇒ $$EE$$, _|_ ⇒ $$_|_$$, TT ⇒ $$TT$$, |– ⇒ $$|–$$, |== ⇒ $$|==$$.
() ⇒ $$()$$, [] ⇒ $$[]$$, {} ⇒ $${}$$, (::) ⇒ $$(::)$$.
int ⇒ $$int$$, oint ⇒ $$oint$$, del ⇒ $$del$$, grad ⇒ $$grad$$, + - ⇒ $$+-$$, O/ ⇒ $$O/$$, oo ⇒ $$oo$$, aleph ⇒ $$aleph$$, /_ ⇒ $$/_$$, :. ⇒ $$:.$$, |…| ⇒ $$|…|$$, cdots ⇒ $$cdots$$, vdots ⇒ $$vdots$$, ddots ⇒ $$ddots$$, |\| ⇒ $$|\|$$, |quad| ⇒ $$|quad|$$, diamond ⇒ $$diamond$$, square ⇒ $$square$$, |__ ⇒ $$|__$$, __| ⇒ $$__|$$, |~ ⇒ $$|~$$, ~| ⇒ $$~|$$ CC ⇒ $$CC$$, NN ⇒ $$NN$$, QQ ⇒ $$QQ$$, RR ⇒ $$RR$$, ZZ ⇒ $$ZZ$$.
These are recognized as standard functions: sin, cos, tan, csc, sec, cot, sinh, cosh, tanh, log, ln, det, dim, lim, mod, gcd, lcm, min, max.
hat x ⇒ $$hat x$$, bar x ⇒ $$bar x$$, ul x ⇒ $$ul x$$, vec x ⇒ $$vec x$$, dot x ⇒ $$dot x$$, ddot x ⇒ $$ddot x$$.
uarr ⇒ $$uarr$$, darr ⇒ $$darr$$, rarr ⇒ $$rarr$$, - > ⇒ $$→$$, larr ⇒ $$larr$$, harr ⇒ $$harr$$, rArr ⇒ $$rArr$$, lArr ⇒ $$lArr$$, hArr ⇒ $$hArr$$.
bb A ⇒ $$bb A$$, bbb A ⇒ $$bbb A$$, cc A ⇒ $$cc A$$, tt A ⇒ $$tt A$$, fr A ⇒ $$fr A$$, sf A ⇒ $$sf A$$.
Partly inspired from ASCIIMathML examples.
This page copied from: help in R-project - by Philippe Grosjean ]]