## 1. Words and Equations

ASCIIMath works by transforming the text you type into mathematics. To see how it works, type this text

The \` key is normally next to the 1 key on the keyboard.

The area of a triangle with base `b` and height `h` is `1/2 bh`. The area of a circle with radius `r` is `pi r^2`.

into this text box:

As you type, the output appears in the grey coloured area next to the text entry box. We want to type mathematics and text, so to indicate mathematics we enclose it between left-quotes, like this: \`E=mc^2\`. Because you type the mathematics directly, it is quick and easy to include a lot of mathematics in your text.

It is easier to read longer formulae if you put them on a separate line, as you can see in the text box below (and the output to the right). Take a look at any standard mathematics book to see the use of mathematics in the text and on separate lines.

`E=mc^2`,

where `E` is energy, `m` is mass and `c` is the speed of light.

Try removing the blank lines above and below the equation in the text box above. After doing this, the equation will no longer appear on a separate line in the output. This is intentional, as sometimes you will want to type an equation on a separate line (for easy editing) without that occurring in the output.

## 2. Symbols

If you need to use a mathematical symbol, look it up in the symbol list. ASCIIMath has standard functions predefined, so to get `sin x` just type \`sin x\` and `ln x` type \`ln x\`.

Greek letters are produced by typing the name of the letter, e.g. \`alpha\` gives `alpha` and \`beta\` gives `beta`. To get capital Greek letters, capitalise the first letter of the name, e.g. \`Sigma\` gives `Sigma`, whereas \`sigma\` gives `sigma`.

For addition and subtraction, just use the symbols on the keyboard. For division, type \`3 -: 4\` to get `3-: 4` or \`3//4\` to get `3//4`. There are several symbols for multiplication and these are shown in the box below.

Type the following expressions, referring to the symbol list if necessary.

`\ \ \ \ \ ` `int cos x dx` `\ \ \ \ \ \ \ \ ` `f @ g (x)` `\ \ \ \ \ \ \ \ ` `x in RR` `\ \ \ \ \ \ \ \ ` `phi: A -> B`

## 3. Indices, subscripts, fractions and brackets

To get an index we use the symbol ^, so for example \`x^2\` gives `x^2`. An index that is anything other than a number or a single letter requires brackets. So to get `e^(2x)` we type \`e^(2x)\`, because \`e^2x\` gives `e^2x`. However \`p^32\` gives `p^32` and \`x^alpha\` gives `x^alpha`.

The symbol _ is used for subscripts and they work in the same way as indices. So \`x_10\` gives `x_10` and it is necessary to use brackets in \`x_(ij)\` to get `x_(ij)`.

Use the text box to type the expressions below.

`\ \ \ \ ` `e^x` `\ \ \ \ ` `pi^2` `\ \ \ \ ` `(x + 1)^2` `\ \ \ \ ` `x^3 + 4x^2 - 5` `\ \ \ \ ` `a_(nm)` `\ \ \ \ ` `x_2^3`

The index and subscript notation is used to put the upper and lower limits on integrals and sums, as in the examples below.

`int_0^1 x^2 dx`

As you can see above, the symbol \`/\` is used for fractions. Unless they are very simple expressions, the denominator and numerator must be enclosed in brackets (which don't appear in the output). So, for example

`\ \ \ \ ` `1/(x+1)`

is achieved by typing \`1/(x+1)\`. What do you think would be produced by typing \`1/x+1\`?

Both \`x_n/10\` and \`(x_n)/(10)\` give the same output, so sometimes it is not necessary to use brackets. Try typing the following expressions and experiment with using/missing out brackets to produce the same output.

`\ \ \ \ ` `(x+1)/(x+1)` `\ \ \ \ ` `(x+1)/x^2` `\ \ \ \ ` `1/3245` `\ \ \ \ ` `dy/dx` `\ \ \ \ ` `(ab)/(cd)`

Remember that we can get a one line fraction by using //.

Finally, use \`sqrt(x)\` for `\sqrt(x)` and \`root(x)(y)\` for `root(x)(y)`. Use the box below to type the formula for the solutions of the equation `ax^2+bx+c=0`, where `a !=0`.

[Hint: the formula appears at the top of this page and you may need to use the symbol list.]

## 4. Spaces, multiple lines and text

ASCIIMath should generate spaces that are about right in the output, but if you want to get an extra space in the mathematics you can use a backslash and a space i.e. \`\ \`. Extra spaces are especially useful when you want to put more than one expression on a line, as in the example below.

`a=3, \ \ \ b=-3,\ \ ` and `\ \ c=2`.

Thus `(a+b)(c+b)=0`.

Notice that the punctuation of the sentence appears in the middle line even though it is mainly mathematical formulae. When beginning to type mathematics it might feel strange to include punctuation, but it is important to do so.

When answering questions that require several lines of working you may like to follow the format of the example below. Because the second, third and fourth lines have been indented it makes it clear that all lines are equal to `x`.

On the last line in the example above we have used the word "or". ASCIIMath recognises the words "or", "and" and "if". Any other words need to be enclosed in inverted commas or using \`text(some words)\`. Try removing the inverted commas in the example below to see their effect.

## 5. Matrices and advanced alignment

The ASCIIMath notation for matrices is demonstrated below.

The outer brackets determine the delimiters e.g. `|(a,b),(c,d)|=ad-bc`.

A general `m xx n` matrix `((a_(11), cdots , a_(1n)),(vdots, ddots, vdots),(a_(m1), cdots , a_(mn)))`

Alter the text in the box above so that it starts with

`\ \ \ \ \ `A `3 xx 2` matrix ,`((1,2),(3,4),(5,6))`,...

In the general `m xx n` matrix, we used \`cdots\` for centred dots. This can be useful when writing infinite series, for example

Similarly, for low dots, as in `1, ldots, n` use \`...\` or \`ldots\`.

The matrix notation can be used for aligning material. When doing this, we will want to draw matrices without delimiters. For this purpose, we can type \`{:\` and \`:}\` to get invisible brackets. This is necessary when defining a function by cases.

Notice the use of \`text( )\` round the comma after `x ge 0` to indicate that it really is a comma and not part of the matrix syntax. Try to write the matrix below and then try to write the function definition using a matrix with two invisible brackets.

`((1,2,3,4),(a,b,c,d))` `\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ` `{:(f:,[0,6], ->, RR),( ,x ,|->, x^2+1):}`