Math & Computer Science Server > ASCIIMathML Tutorial

 

 

ASCIIMathML
The notation for mathematics on our Moodle server

Authored by Chapman University undergraduate students

Introduction

The standard Moodle editor is used to type mathematical formulas online. This helpfile explains how to proceed and contains many examples. The notation used for formulas is similar to what you would type on a graphing calculator, and allows you to present even very complicated mathematical formulas clearly and easily. The process of typing math is very simple. There are two buttons on the editor you need to use.

The Insert New Math button looks like on the editor menu. If you click this button (or alternatively press the back-quote key next to the 1-key) then two back-quote symbols will appear within a red box. Now anything you type in between these two back-quotes will be converted into math (once you click outside the red box). For example:

\`math + is + fun\` typed in the red box will show up as `math + is + fun`. To display the text in a red box using standard math notation, simply click outside of the red box or use the arrow keys to move the cursor outside of the red box. To edit the displayed math, click the math text (now rendered in a red color) and you will be able to edit the formula.

Another useful button is the Calculate button that looks like If you type an expression in a red box and press this button the editor will calculate the answer and insert it for you (if possible). This feature will not work if the expression contains unknown variables such as `x` or `y`, or if the expression is syntactically incorrect, and in this case the phrase "don't know" is inserted. In particular, functions like sin and sqrt (short for squareroot) should be followed by parentheses when using the Calculate button (i.e. type sqrt(2) rather than sqrt2, even though they both display the same).

If you are reading a Moodle page with mathematics on it, you can see how the math was typed by hovering the mouse over the red text. A small text box will show what was typed to produce the formula. So you can study how a particular math expression is typed on a keyboard.

You can also use the Insert Math Symbols button on the editor menu to select specific symbols from a popup window. However once you become familiar with the standard keyboard version of each symbol, it is usually faster to type them out.

Basics

The editor uses the same basic symbols for simple calculations. Addition "+", Subtraction "-", Multiplication "*", and Division "/" can be easily entered in the editor. The order of operations is (almost) the same as for a calculator. For example:

\`1+2-3*4/5+6 = 6.6\` which looks like `1+2-3*4/5+6 = 6.6` in the editor.
As you can see, the editor follows the standard order of operations by completing multiplication and division before doing the addition and subtraction (but note that division has priority over multiplication in the display). You can group subexpressions using parentheses just like on a regular calculator.

\`(1+2)-3*4/(5+6) = 1.90909\` which looks like `(1+2)-3*4/(5+6) = 1.90909 ` in the editor.

Notice in the previous example how 5+6 was not shown in parentheses. There may be times where you need to show that 2 components of an equation are combined. For example if you wanted to show what factors were going to be canceled in a large expression, it helps to group the factors together visibly. For example:

\`(1+x)/(3+x)*(3+x)/(5+x)=(1+x)/(5+x)\` will show up as `(1+x)/(3+x)*(3+x)/(5+x)=(1+x)/(5+x)`

It would help the reader to see what you are planning on simplifying. In order to do this, you could put double parentheses around the first set of parentheses. In the previous example, simply change (3+x) to ((3+x)).

\`(1+x)/((3+x))*((3+x))/(5+x)=(1+x)/(5+x)\` will show up as `(1+x)/((3+x))*((3+x))/(5+x)=(1+x)/(5+x)`

Exponents are common in equations you will encounter. It is important to know how the editor handles exponents. Similar to a calculator, the editor uses the ^ key (shift-6) to denote the operation of exponentiation. For example:

\`2^3 = 8\` would be read as "2 cubed equals 8" and would appear as `2^3 = 8`

As always, proper formatting will help eliminate frustrations in the future so here are some tips on how to properly use exponents. The editor reads equations mostly from left to right and groups expressions together in that order (unless the grouping is changed by parentheses). For example:

\`2^2^3 = 64\` because the editor resolves it as (2^2)^3 which is 4^3 so `2^2^3=64`

\`2^(2^3) = 256\` because the editor resolves 2^3 = 8 and then solves 2^8 so `2^(2^3)=256`

Similarly, \`2^2^2^2\` is read as `2^2^2^2` which is 256. If you wanted to have each value be to the next power, use parentheses like this:

\`2^(2^(2^2))\` is now `2^(2^(2^2))=65536`

\`2^1/2 = 1\` (`2^1/2 = 1`) according to the editor because there are no parentheses. And even if you do use parentheses, this won't show up well in the editor.

\`2^(1/2)=1.4142135623730951\` shows up as `2^(1/2)=1.4142135623730951`

It almost looks like \`1/22\` (`1/22`). If you are going to use fractions in your exponents, you can make them appear more like exponents by using a double forward slash "//".

\`2^(1//2)\` will now look like `2^(1//2)` which allows the reader to see that the fraction is an exponent.

\`2^(1/2)\` is just the square root of 2. This is the most commonly used root, and the editor has a built in function for this.

\`sqrt(x)\` will display the square root of what is in the parenthesis. `sqrt(x)` or `sqrt(2)=1.4142135623730951`

What if you want to display cube roots and beyond? Rather than typing everything in fractions, you can simply use the root function of the editor.

\`root 3 x\` will be read by the editor as `root 3 x` but again, formatting is important. Basically, the syntax is:

\`root("power of root")("value under root")\` which will be `root("power of root")("value under root")`

Below are more examples.

Examples of Powers and Roots

What to type

How it looks

\`x^(m+n) = (x^m)*(x^n)\` `x^(m+n) = (x^m)*(x^n)`
x^(m-n) = (x^m)/(x^n)`x^(m-n) = (x^m)/(x^n)`
(x^m)^n = x^(m*n) `(x^m)^n = x^(m*n)`
(x*y)^n = (x^n)*(y^n) `(x*y)^n = (x^n)*(y^n)`
(x/y)^n = (x^n)/(y^n)`(x/y)^n = (x^n)/(y^n)`
x^-n = 1/(x^n)`x^-n = 1/(x^n)`
x^(m//n) = root(n)(x^m)

`x^(m//n) = root(n)(x^m)`

There can even be more extreme combinations such as \`sqrt(sqrt(root(3)(x)))\` which would appear as `sqrt(sqrt(root(3)(x)))`

Trigonometric functions are commonplace in calculus. Understanding how the editor interprets these functions is vital. The abbreviations are similar to a scientific calculator. For example:

\`sin(pi/2)=1\` will appear as `sin(pi/2)=1`. Other functions are presented below.

Trigonometric Functions

Function Abbreviation Example How it looks
Sine sin(x) \`sin(theta)=cos((pi/2)-theta)\` `sin(theta)=cos((pi/2)-theta)`
Cosine cos(x) \`cos(theta)=sin((pi/2)-theta)\` `cos(theta)=sin((pi/2)-theta)`
Tangent tan(x) \`tan(theta)=sin(theta)/cos(theta)\` `tan(theta)=sin(theta)/cos(theta)`
Cotangent cot(x) \`cot(theta)=cos(theta)/sin(theta)\` `cot(theta)=cos(theta)/sin(theta)`
Secant sec(x) \`sec(theta)=1/cos(theta)\` `sec(theta)=1/cos(theta)`
Cosecant csc(x) \`csc(theta)=1/sin(theta)\` `csc(theta)=1/sin(theta)`

In order to use squares of trigonometric functions, you don't type it out as it normally is presented in the book. \`sin^2(pi/3)+cos^2(pi/3)=undefined\` which should be one. However the editor does not evaluate `sin^2(pi/3)+cos^2(pi/3)="undefined"` In order to have the functions squared, simply put the exponent after the value \`sin(x)^2 or (sin(x))^2\` which is `sin(x)^2 or (sin(x))^2`. For example:

\`sin(pi/3)^2+(cos(pi/3))^2=1\` which is `sin(pi/3)^2+(cos(pi/3))^2=1`

The editor has stored values which can be used with simple keywords. Common values such as pi and e can be used in equations and still be evaluated using the calculator feature of the editor. Here are just a few examples.

Common Constants and Symbols in ASCIIMath

Symbol wanted

What to type

How it looks

less(greater) than

\`< or >\`

`< or >`

less(greater) than or equal

\`<= or >=\`

`<= or >=`

approximately equal

\`~~\`

`~~`

epsilon or delta

\`epsilon or delta\`

`epsilon or delta`

x approaches infinity

\`x -> oo\`

`x -> oo`

theta

\`theta\`

`theta`

pi

\`pi\`

`pi` Ex: `2pi=6.2831853`

e

\`e\`

`e` Ex: `2e=5.43656365`

set of natural numbers

\`NN\`

`NN`

set of real numbers

\`RR\`

`RR`

set of integers

\`ZZ\`

`ZZ`

sum of

\`sum\`

`sum`

product of

\`prod\`

`prod`

Examples of these symbols in real problems will be presented in the next section:

ASCIIMath in Calculus and beyond.

If you need additional specific symbols, you can use the Insert Math Symbols button or take a look at http://www1.chapman.edu/~jipsen/mathml/asciimathsyntax.html