topical media & game development

talk show tell print

lib-present-math-ascii-ASCIIMathTutorial.htm / htm



  <html xmlns:mml="http://www.w3.org/1998/Math/MathML"><head>
  <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  
  <title>ASCIIMath Tutorial</title>
  <script type="text/javascript" src="lib-present-math-ascii-ASCIIMathTutorial-files-ASCIIMathMLwFallback.js"></script>
  <script type="text/javascript" src="lib-present-math-ascii-ASCIIMathTutorial-files-ASCIIMathMLeditor.js"></script>
  <script type="text/javascript" src="lib-present-math-ascii-ASCIIMathTutorial-files-customisations.js"></script>
  <link href="lib-present-math-ascii-ASCIIMathTutorial-files-ASCIIMathTutorialStyle.css" rel="stylesheet" type="text/css">
  </head>
  <body>
  <object id="mathplayer" classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987">
      </object>
       
  
      
  
      
  
      
  
      
  
      <div class="mainContent">
          <div class="headerBox">
              <div class="headerFooterContent">
                  <h1 align="center">
                      ASCIIMath Tutorial</h1>
                  <h3 align="center">
                      James Gray - The Open University</h3>
                  <p>
                      This tutorial and accompanying <a href="http://www.wjagray.co.uk/maths/SymbolList.html">symbol list</a> introduce
                      the ASCIIMath notation and some points of good practice in writing mathematics.
                      To display the mathematics correctly, this page requires Internet Explorer 6 with
                      <a href="http://www.dessci.com/en/products/mathplayer">MathPlayer</a> installed,
                      or Mozilla/Firefox/Netscape 7+ with MathML fonts installed (e.g. download the <a href="http://web.mit.edu/is/topics/webpublishing/mathml/">MIT MathML font packages</a>).
                      If you have these installed you should see a familiar formula here:</p>
                  <p align="center">
   <math title="x=(-b +- sqrt(b^2 - 4ac))/(2a)"><mstyle displaystyle="true" fontfamily="serif"><mi>x</mi><mo>=</mo><mfrac><mrow><mo>-</mo><mi>b</mi><mo>±</mo><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mo>-</mo><mn>4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></mstyle></math></p>
              </div>
          </div>
          <div class="sectionHeader">
              <h2>
                  1. Words and Equations</h2>
          </div>
          <div class="tutorialText">
              <p>
                  ASCIIMath works by transforming the text you type into mathematics. To see how it
                  works, type this text</p>
          </div>
          <div class="mpar">
              Note:
              <br>
   The ` key is normally next to the 1 key on the keyboard.</div>
          <div class="tutorialText">
              <pre>    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`.</pre>
              <p>
                  into this text box:</p>
          <br>
          </div>
          <div class="answer" id="student_answer1_output">The area of a triangle with base <math title="b"><mstyle displaystyle="true" fontfamily="serif"><mi>b</mi></mstyle></math> 
   and height <math title="h"><mstyle displaystyle="true" fontfamily="serif"><mi>h</mi></mstyle></math> is <math title="1/2 bh"><mstyle displaystyle="true" fontfamily="serif"><mfrac><mn>1</mn><mn>2</mn></mfrac><mi>b</mi><mi>h</mi></mstyle></math>. The area 
   of a circle with radius <math title="r"><mstyle displaystyle="true" fontfamily="serif"><mi>r</mi></mstyle></math> is <math title="pi r^2"><mstyle displaystyle="true" fontfamily="serif"><mi>&#960;</mi><msup><mi>r</mi><mn>2</mn></msup></mstyle></math>.<math title=""><mstyle displaystyle="true" fontfamily="serif"><mo></mo></mstyle></math></div>
          <textarea class="entrybox" id="student_answer1" onkeyup="AMdisplay('student_answer1','student_answer1_output',true)">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`.</textarea>
          <br>
          <div class="mpar">
   It is also possible to put the mathematics between dollar signs like this: E=mc^2.
   There is no difference in the output.</div>
          <div class="tutorialText">
              <p>
   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.
   </p>
              <p>
                  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.
              </p>
          </div>
          <div class="answer" id="student_answer2_output">
              Einstein's famous formula is
              <p>
              </p>
   <math title="E=mc^2"><mstyle displaystyle="true" fontfamily="serif"><mi>E</mi><mo>=</mo><mi>m</mi><msup><mi>c</mi><mn>2</mn></msup></mstyle></math>,
   <p>
              </p>
   where <math title="E"><mstyle displaystyle="true" fontfamily="serif"><mi>E</mi></mstyle></math> is energy, <math title="m"><mstyle displaystyle="true" fontfamily="serif"><mi>m</mi></mstyle></math> is mass and <math title="c"><mstyle displaystyle="true" fontfamily="serif"><mi>c</mi></mstyle></math> is the speed of light.
   </div>
          <textarea id="student_answer2" class="entryboxMedium" onkeyup="AMdisplay('student_answer2','student_answer2_output',true)">Einstein's famous formula is
  
  `E=mc^2`,
  
  where `E` is energy, `m` is mass and `c` is the speed of light.</textarea>
          <br>
          <!-- This break and all others below are included so that bizzare behavouir of the floating boxes doesn't occur. -->
          <div class="tutorialText">
              <p>
                  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.
              </p>
          </div>
          <h2>
              2. Symbols</h2>
          <div class="tutorialText">
              <p>
                  If you need to use a mathematical symbol, look it up in the <a href="http://www.wjagray.co.uk/maths/SymbolList.html">
                      symbol list</a>. ASCIIMath has standard functions predefined, so to get <math title="sin x"><mstyle displaystyle="true" fontfamily="serif"><mrow><mo>sin</mo><mi>x</mi></mrow></mstyle></math> just type `sin x` and <math title="ln x"><mstyle displaystyle="true" fontfamily="serif"><mrow><mo>ln</mo><mi>x</mi></mrow></mstyle></math> type `ln x`.</p>
          </div>
          <div class="mpar">
   Remember left-quotes (i.e. `) are used to indicate mathematics.</div>
          <div class="tutorialText">
              <p>
   Greek letters are produced by typing the name of the letter, e.g. `alpha` gives
   <math title="alpha"><mstyle displaystyle="true" fontfamily="serif"><mi>&#945;</mi></mstyle></math> and `beta` gives <math title="beta"><mstyle displaystyle="true" fontfamily="serif"><mi>&#946;</mi></mstyle></math>. To get capital Greek letters, capitalise the
   first letter of the name, e.g. `Sigma` gives <math title="Sigma"><mstyle displaystyle="true" fontfamily="serif"><mo>&#931;</mo></mstyle></math>, whereas `sigma` gives
   <math title="sigma"><mstyle displaystyle="true" fontfamily="serif"><mi>&#963;</mi></mstyle></math>.</p>
              <p>
   For addition and subtraction, just use the symbols on the keyboard. For division,
   type `3 -: 4` to get <math title="3-: 4"><mstyle displaystyle="true" fontfamily="serif"><mn>3</mn><mo>÷</mo><mn>4</mn></mstyle></math> or `3//4` to get <math title="3//4"><mstyle displaystyle="true" fontfamily="serif"><mn>3</mn><mo>/</mo><mn>4</mn></mstyle></math>. There are several symbols
   for multiplication and these are shown in the box below.</p>
          </div>
          <div class="answer" id="student_answer3_output">
   Typing <math title="2xx7 = 14"><mstyle displaystyle="true" fontfamily="serif"><mn>2</mn><mo>×</mo><mn>7</mn><mo>=</mo><mn>14</mn></mstyle></math> and <math title="2 times 7 =14"><mstyle displaystyle="true" fontfamily="serif"><mn>2</mn><mo>×</mo><mn>7</mn><mo>=</mo><mn>14</mn></mstyle></math> gives the same output. 
   <p></p>
   You might also want
   to write this as <math title="2*7=14"><mstyle displaystyle="true" fontfamily="serif"><mn>2</mn><mo>&#8901;</mo><mn>7</mn><mo>=</mo><mn>14</mn></mstyle></math> or even <math title="2**7=14"><mstyle displaystyle="true" fontfamily="serif"><mn>2</mn><mo>&#8902;</mo><mn>7</mn><mo>=</mo><mn>14</mn></mstyle></math>.</div>
          <textarea class="entryboxMedium" id="student_answer3" onkeyup="AMdisplay('student_answer3','student_answer3_output',true)">Typing `2xx7 = 14` and `2 times 7 =14` gives the same output.
  
  You might also want to write this as `2*7=14` or even `2**7=14`.</textarea>
          <br>
          <div class="tutorialText">
              <p>
                  Type the following expressions, referring to the <a href="http://www.wjagray.co.uk/maths/SymbolList.html">symbol list</a>
                  if necessary.
              </p>
              <p>
   <math title="\ \ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> <math title="int cos x dx"><mstyle displaystyle="true" fontfamily="serif"><mo>&#8747;</mo><mrow><mo>cos</mo><mi>x</mi></mrow><mrow><mi>d</mi><mi>x</mi></mrow></mstyle></math> <math title="\ \ \ \ \ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> <math title="f @ g (x)"><mstyle displaystyle="true" fontfamily="serif"><mrow><mi>f</mi><mo>&#8728;</mo></mrow><mrow><mi>g</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow></mstyle></math> <math title="\ \ \ \ \ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> <math title="x in RR"><mstyle displaystyle="true" fontfamily="serif"><mi>x</mi><mo>&#8712;</mo><mo>&#8477;</mo></mstyle></math> <math title="\ \ \ \ \ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> <math title="phi: A -&gt; B"><mstyle displaystyle="true" fontfamily="serif"><mi>&#966;</mi><mo>:</mo><mi>A</mi><mo>&#8594;</mo><mi>B</mi></mstyle></math>
   </p>
          </div>
          <div class="answer" id="student_answer4_output">
          </div>
          <textarea class="entrybox" id="student_answer4" onkeyup="AMdisplay('student_answer4','student_answer4_output',true)"></textarea>
          <br>
          <div class="tutorialText">
              To check your answers, hang the mouse pointer over one of the expressions above.
              After a couple of seconds a box will appear showing the ASCIIMath used to type the
              expression. You can always use this to see the ASCIIMath.</div>
          <h2>
              3. Indices, subscripts, fractions and brackets</h2>
          <div class="mpar" style="margin-top: 0px;">
   Notice the brackets in `e^(2x)` don't appear in the output <math title="e^(2x)"><mstyle displaystyle="true" fontfamily="serif"><msup><mi>e</mi><mrow><mn>2</mn><mi>x</mi></mrow></msup></mstyle></math>. In the expression
   <math title="f^((3)) (x)"><mstyle displaystyle="true" fontfamily="serif"><msup><mi>f</mi><mrow><mrow><mo>(</mo><mn>3</mn><mo>)</mo></mrow></mrow></msup><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mstyle></math> for the third derivative of <math title="f"><mstyle displaystyle="true" fontfamily="serif"><mrow><mi>f</mi><mo></mo></mrow></mstyle></math>, we want the brackets to appear so
   we type `f^((3))(x)`.</div>
          <div class="tutorialText">
              <p>
   To get an index we use the symbol ^, so for example `x^2` gives <math title="x^2"><mstyle displaystyle="true" fontfamily="serif"><msup><mi>x</mi><mn>2</mn></msup></mstyle></math>. An index
   that is anything other than a number or a single letter requires brackets. So to
   get <math title="e^(2x)"><mstyle displaystyle="true" fontfamily="serif"><msup><mi>e</mi><mrow><mn>2</mn><mi>x</mi></mrow></msup></mstyle></math> we type `e^(2x)`, because `e^2x` gives <math title="e^2x"><mstyle displaystyle="true" fontfamily="serif"><msup><mi>e</mi><mn>2</mn></msup><mi>x</mi></mstyle></math>. However `p^32`
   gives <math title="p^32"><mstyle displaystyle="true" fontfamily="serif"><msup><mi>p</mi><mn>32</mn></msup></mstyle></math> and `x^alpha` gives <math title="x^alpha"><mstyle displaystyle="true" fontfamily="serif"><msup><mi>x</mi><mi>&#945;</mi></msup></mstyle></math>.
   </p>
              <p>
   The symbol _ is used for subscripts and they work in the same way as indices. So
   `x_10` gives <math title="x_10"><mstyle displaystyle="true" fontfamily="serif"><msub><mi>x</mi><mn>10</mn></msub></mstyle></math> and it is necessary to use brackets in `x_(ij)` to get <math title="x_(ij)"><mstyle displaystyle="true" fontfamily="serif"><msub><mi>x</mi><mrow><mi>i</mi><mi>j</mi></mrow></msub></mstyle></math>.
   </p>
          </div>
          <br>
          <div class="mpar">
              Remember you can check your answers by hanging the mouse over the expression.</div>
          <div class="tutorialText">
              <p>
                  Use the text box to type the expressions below.
              </p>
              <p>
   <math title="\ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> <math title="e^x"><mstyle displaystyle="true" fontfamily="serif"><msup><mi>e</mi><mi>x</mi></msup></mstyle></math> <math title="\ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> <math title="pi^2"><mstyle displaystyle="true" fontfamily="serif"><msup><mi>&#960;</mi><mn>2</mn></msup></mstyle></math> <math title="\ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> <math title="(x + 1)^2"><mstyle displaystyle="true" fontfamily="serif"><msup><mrow><mo>(</mo><mi>x</mi><mo>+</mo><mn>1</mn><mo>)</mo></mrow><mn>2</mn></msup></mstyle></math> <math title="\ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> <math title="x^3 + 4x^2 - 5"><mstyle displaystyle="true" fontfamily="serif"><msup><mi>x</mi><mn>3</mn></msup><mo>+</mo><mn>4</mn><msup><mi>x</mi><mn>2</mn></msup><mo>-</mo><mn>5</mn></mstyle></math> <math title="\ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> <math title="a_(nm)"><mstyle displaystyle="true" fontfamily="serif"><msub><mi>a</mi><mrow><mi>n</mi><mi>m</mi></mrow></msub></mstyle></math> <math title="\ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> <math title="x_2^3"><mstyle displaystyle="true" fontfamily="serif"><mrow><msubsup><mi>x</mi><mn>2</mn><mn>3</mn></msubsup></mrow></mstyle></math>
   </p>
          </div>
          <br>
          <div class="answer" id="student_answer5_output">
          </div>
          <textarea class="entrybox" id="student_answer5" onkeyup="AMdisplay('student_answer5','student_answer5_output',true)"></textarea>
          <div class="tutorialText">
              <p>
                  The index and subscript notation is used to put the upper and lower limits on integrals
                  and sums, as in the examples below.</p>
          </div>
          <div class="answer" id="student_answer6_output">
   <math title="sum_(k=1)^n k = 1+2+ cdots +n=(n(n+1))/2"><mstyle displaystyle="true" fontfamily="serif"><mrow><munderover><mo>&#8721;</mo><mrow><mi>k</mi><mo>=</mo><mn>1</mn></mrow><mi>n</mi></munderover></mrow><mi>k</mi><mo>=</mo><mn>1</mn><mo>+</mo><mn>2</mn><mo>+</mo><mo>&#8943;</mo><mo>+</mo><mi>n</mi><mo>=</mo><mfrac><mrow><mi>n</mi><mrow><mo>(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo>)</mo></mrow></mrow><mn>2</mn></mfrac></mstyle></math>
   <p>
              </p>
   <math title="int_0^1 x^2 dx"><mstyle displaystyle="true" fontfamily="serif"><mrow><msubsup><mo>&#8747;</mo><mn>0</mn><mn>1</mn></msubsup></mrow><msup><mi>x</mi><mn>2</mn></msup><mrow><mi>d</mi><mi>x</mi></mrow></mstyle></math></div>
          <textarea class="entryboxMedium" id="student_answer6" onkeyup="AMdisplay('student_answer6','student_answer6_output',true)">`sum_(k=1)^n k = 1+2+ cdots +n=(n(n+1))/2`
  
  `int_0^1 x^2 dx`</textarea>
          <br>
          <div class="tutorialText">
              <p>
   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
   </p>
              <p>
   <math title="\ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> <math title="1/(x+1)"><mstyle displaystyle="true" fontfamily="serif"><mfrac><mn>1</mn><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow></mfrac></mstyle></math>
   </p>
              <p>
   is achieved by typing `1/(x+1)`. What do you think would be produced by typing
   `1/x+1`?
   </p>
              <p>
   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.
   </p>
              <p>
   <math title="\ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> <math title="(x+1)/(x+1)"><mstyle displaystyle="true" fontfamily="serif"><mfrac><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow></mfrac></mstyle></math> <math title="\ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> <math title="(x+1)/x^2"><mstyle displaystyle="true" fontfamily="serif"><mfrac><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow><msup><mi>x</mi><mn>2</mn></msup></mfrac></mstyle></math> <math title="\ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> <math title="1/3245"><mstyle displaystyle="true" fontfamily="serif"><mfrac><mn>1</mn><mn>3245</mn></mfrac></mstyle></math> <math title="\ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> <math title="dy/dx"><mstyle displaystyle="true" fontfamily="serif"><mfrac><mrow><mi>d</mi><mi>y</mi></mrow><mrow><mi>d</mi><mi>x</mi></mrow></mfrac></mstyle></math>
   <math title="\ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> <math title="(ab)/(cd)"><mstyle displaystyle="true" fontfamily="serif"><mfrac><mrow><mi>a</mi><mi>b</mi></mrow><mrow><mi>c</mi><mi>d</mi></mrow></mfrac></mstyle></math>
   </p>
          </div>
          <div class="answer" id="student_answer7_output">
          </div>
          <textarea class="entrybox" id="student_answer7" onkeyup="AMdisplay('student_answer7','student_answer7_output',true)"></textarea>
          <br>
          <div class="tutorialText">
              <p>
                  Remember that we can get a one line fraction by using //.</p>
          </div>
          <div class="answer" id="student_answer8_output">
   You may wish to use this for fractions that appear as indices, because it is easier
   to read <math title="e^(x//2)"><mstyle displaystyle="true" fontfamily="serif"><msup><mi>e</mi><mrow><mi>x</mi><mo>/</mo><mn>2</mn></mrow></msup></mstyle></math> than <math title="e^(x/2)"><mstyle displaystyle="true" fontfamily="serif"><msup><mi>e</mi><mrow><mfrac><mi>x</mi><mn>2</mn></mfrac></mrow></msup></mstyle></math>.</div>
          <textarea class="entryboxMedium" id="student_answer8" onkeyup="AMdisplay('student_answer8','student_answer8_output',true)">You may wish to use this for fractions that appear as indices, because it is easier to read `e^(x//2)` than `e^(x/2)`.</textarea>
          <br>
          <div class="tutorialText">
              <p>
   Finally, use `sqrt(x)` for <math title="\sqrt(x)"><mstyle displaystyle="true" fontfamily="serif"><msqrt><mrow><mi>x</mi></mrow></msqrt></mstyle></math> and `root(x)(y)` for <math title="root(x)(y)"><mstyle displaystyle="true" fontfamily="serif"><mroot><mrow><mi>y</mi></mrow><mrow><mi>x</mi></mrow></mroot></mstyle></math>. Use
   the box below to type the formula for the solutions of the equation <math title="ax^2+bx+c=0"><mstyle displaystyle="true" fontfamily="serif"><mi>a</mi><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mi>b</mi><mi>x</mi><mo>+</mo><mi>c</mi><mo>=</mo><mn>0</mn></mstyle></math>,
   where <math title="a !=0"><mstyle displaystyle="true" fontfamily="serif"><mi>a</mi><mo>&#8800;</mo><mn>0</mn></mstyle></math>.</p>
          </div>
          <div class="answer" id="student_answer9_output">
          </div>
          <textarea class="entrybox" id="student_answer9" onkeyup="AMdisplay('student_answer9','student_answer9_output',true)"></textarea>
          <br>
          <div class="tutorialText">
              <p>
                  [Hint: the formula appears at the top of this page and you may need to use the symbol
                  list.]</p>
          </div>
          <h2>
              4. Spaces, multiple lines and text</h2>
          <div style="margin-top: 0px;" class="mpar">
              In some browsers, the words quad and qquad will produce longer spaces than a backslash
              and a space.</div>
          <div class="tutorialText">
              <p>
   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.
   </p>
          </div>
          <div class="answer" id="student_answer10_output">
              We set
              <p>
              </p>
   <math title="a=3, \ \ \ b=-3,\ \ "><mstyle displaystyle="true" fontfamily="serif"><mi>a</mi><mo>=</mo><mn>3</mn><mo>,</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mi>b</mi><mo>=</mo><mo>-</mo><mn>3</mn><mo>,</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> and <math title="\ \ c=2"><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mi>c</mi><mo>=</mo><mn>2</mn></mstyle></math>.
   <p>
              </p>
   Thus <math title="(a+b)(c+b)=0"><mstyle displaystyle="true" fontfamily="serif"><mrow><mo>(</mo><mi>a</mi><mo>+</mo><mi>b</mi><mo>)</mo></mrow><mrow><mo>(</mo><mi>c</mi><mo>+</mo><mi>b</mi><mo>)</mo></mrow><mo>=</mo><mn>0</mn></mstyle></math>.</div>
          <textarea class="entryboxMedium" id="student_answer10" onkeyup="AMdisplay('student_answer10','student_answer10_output',true)">We set
  
  `a=3, \ \ \ b=-3,\ \ ` and `\ \ c=2`.
  
  Thus `(a+b)(c+b)=0`.</textarea>
          <br>
          <div class="tutorialText">
              <p>
                  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.
              </p>
              <p>
   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 <math title="x"><mstyle displaystyle="true" fontfamily="serif"><mi>x</mi></mstyle></math>.
   </p>
          </div>
          <div class="answer" id="student_answer11_output">
   Using the quadratic formula, the roots of <math title="x^2-6x+4=0"><mstyle displaystyle="true" fontfamily="serif"><msup><mi>x</mi><mn>2</mn></msup><mo>-</mo><mn>6</mn><mi>x</mi><mo>+</mo><mn>4</mn><mo>=</mo><mn>0</mn></mstyle></math> are
   <p></p>
   <math title="x = (-6 +- sqrt((-6)^2 - 4 (1)(4)))/(2 xx 1)"><mstyle displaystyle="true" fontfamily="serif"><mi>x</mi><mo>=</mo><mfrac><mrow><mo>-</mo><mn>6</mn><mo>±</mo><msqrt><mrow><msup><mrow><mo>(</mo><mo>-</mo><mn>6</mn><mo>)</mo></mrow><mn>2</mn></msup><mo>-</mo><mn>4</mn><mrow><mo>(</mo><mn>1</mn><mo>)</mo></mrow><mrow><mo>(</mo><mn>4</mn><mo>)</mo></mrow></mrow></msqrt></mrow><mrow><mn>2</mn><mo>×</mo><mn>1</mn></mrow></mfrac></mstyle></math>
   <p></p>
   <math title="\ \ = (-6 +- sqrt(36 - 16))/2"><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>=</mo><mfrac><mrow><mo>-</mo><mn>6</mn><mo>±</mo><msqrt><mrow><mn>36</mn><mo>-</mo><mn>16</mn></mrow></msqrt></mrow><mn>2</mn></mfrac></mstyle></math>
   <p></p>
   <math title="\ \ =(-6 +- sqrt(20))/2"><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>=</mo><mfrac><mrow><mo>-</mo><mn>6</mn><mo>±</mo><msqrt><mrow><mn>20</mn></mrow></msqrt></mrow><mn>2</mn></mfrac></mstyle></math>
   <p></p>
   <math title="\ \ = -0.8 or 2.2 \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>=</mo><mo>-</mo><mn>0.8</mn><mrow><mspace width="1ex"></mspace><mtext>or</mtext><mspace width="1ex"></mspace></mrow><mn>2.2</mn><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math>to 1 decimal place.</div>
          <textarea class="entryboxLarge" id="student_answer11" onkeyup="AMdisplay('student_answer11','student_answer11_output',true)">Using the quadratic formula, the roots of `x^2-6x+4=0` are
  
  `x = (-6 +- sqrt((-6)^2 - 4 (1)(4)))/(2 xx 1)`
  
  `\ \ = (-6 +- sqrt(36 - 16))/2`
  
  `\ \ =(-6 +- sqrt(20))/2`
  
  `\ \ = -0.8 or 2.2 \ \ \ `to 1 decimal place.</textarea>
          <br>
          <div class="mpar" style="margin-top: -30px;">
                  There is a full stop at the end of the last line in this example because
                  it is at the end of a sentence, albeit a sentence with a lot of mathematics in it.
          </div>
          <div class="tutorialText">
          <p>
   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.</p></div>
          <br>
          <div class="answer" id="student_answer11a_output"><math title="sin = &quot;opp&quot;/&quot;hyp&quot; \ \ \ and \ \ \ cos = text(adj)/text(hyp)"><mstyle displaystyle="true" fontfamily="serif"><mrow><mo>sin</mo><mo>=</mo></mrow><mfrac><mrow><mtext>opp</mtext></mrow><mrow><mtext>hyp</mtext></mrow></mfrac><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mrow><mspace width="1ex"></mspace><mtext>and</mtext><mspace width="1ex"></mspace></mrow><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mrow><mo>cos</mo><mo>=</mo></mrow><mfrac><mrow><mtext>adj</mtext></mrow><mrow><mtext>hyp</mtext></mrow></mfrac></mstyle></math>.</div>
          <textarea class="entrybox" id="student_answer11a" onkeyup="AMdisplay('student_answer11a','student_answer11a_output',true)">`sin = "opp"/"hyp" 
  \ \ \  and \ \ \ 
  cos = text(adj)/text(hyp)`.</textarea>
          <br>
          <h2>
              5. Matrices and advanced alignment</h2>
          <div class="tutorialText">
              <p>
                  The ASCIIMath notation for matrices is demonstrated below.
              </p>
          </div>
          <div class="answer" id="student_answer12_output">
   A <math title="3xx3"><mstyle displaystyle="true" fontfamily="serif"><mn>3</mn><mo>×</mo><mn>3</mn></mstyle></math> matrix,<math title="((1,2,3),(4,5,6),(7,8,9))"><mstyle displaystyle="true" fontfamily="serif"><mrow><mo>(</mo><mtable><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd><mtd><mn>3</mn></mtd></mtr><mtr><mtd><mn>4</mn></mtd><mtd><mn>5</mn></mtd><mtd><mn>6</mn></mtd></mtr><mtr><mtd><mn>7</mn></mtd><mtd><mn>8</mn></mtd><mtd><mn>9</mn></mtd></mtr></mtable><mo>)</mo></mrow></mstyle></math>, and a <math title="2xx1"><mstyle displaystyle="true" fontfamily="serif"><mn>2</mn><mo>×</mo><mn>1</mn></mstyle></math> matrix, or vector, <math title="((1),(0))"><mstyle displaystyle="true" fontfamily="serif"><mrow><mo>(</mo><mtable><mtr><mtd><mn>1</mn></mtd></mtr><mtr><mtd><mn>0</mn></mtd></mtr></mtable><mo>)</mo></mrow></mstyle></math>.
   <p>
              </p>
   The outer brackets determine the delimiters e.g. <math title="|(a,b),(c,d)|=ad-bc"><mstyle displaystyle="true" fontfamily="serif"><mrow><mo>|</mo><mtable><mtr><mtd><mi>a</mi></mtd><mtd><mi>b</mi></mtd></mtr><mtr><mtd><mi>c</mi></mtd><mtd><mi>d</mi></mtd></mtr></mtable><mo>|</mo></mrow><mo>=</mo><mi>a</mi><mi>d</mi><mo>-</mo><mi>b</mi><mi>c</mi></mstyle></math>.
   <p>
              </p>
   A general <math title="m xx n"><mstyle displaystyle="true" fontfamily="serif"><mi>m</mi><mo>×</mo><mi>n</mi></mstyle></math> matrix <math title="((a_(11), cdots , a_(1n)),(vdots, ddots, vdots),(a_(m1), cdots , a_(mn)))"><mstyle displaystyle="true" fontfamily="serif"><mrow><mo>(</mo><mtable><mtr><mtd><msub><mi>a</mi><mrow><mn>11</mn></mrow></msub></mtd><mtd><mo>&#8943;</mo></mtd><mtd><msub><mi>a</mi><mrow><mn>1</mn><mi>n</mi></mrow></msub></mtd></mtr><mtr><mtd><mo>&#8942;</mo></mtd><mtd><mo>&#8945;</mo></mtd><mtd><mo>&#8942;</mo></mtd></mtr><mtr><mtd><msub><mi>a</mi><mrow><mi>m</mi><mn>1</mn></mrow></msub></mtd><mtd><mo>&#8943;</mo></mtd><mtd><msub><mi>a</mi><mrow><mi>m</mi><mi>n</mi></mrow></msub></mtd></mtr></mtable><mo>)</mo></mrow></mstyle></math>
   </div>
          <textarea class="entryboxLarge" id="student_answer12" onkeyup="AMdisplay('student_answer12','student_answer12_output',true)">A `3xx3` matrix,
  `((1,2,3),(4,5,6),(7,8,9))`,
  and a `2xx1` matrix, or vector, `((1),(0))`.
  
  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)))`</textarea>
          <br>
          <div class="tutorialText">
              <p>
                  Alter the text in the box above so that it starts with
              </p>
              <p>
   <math title="\ \ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math>A <math title="3 xx 2"><mstyle displaystyle="true" fontfamily="serif"><mn>3</mn><mo>×</mo><mn>2</mn></mstyle></math> matrix ,<math title="((1,2),(3,4),(5,6))"><mstyle displaystyle="true" fontfamily="serif"><mrow><mo>(</mo><mtable><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd></mtr><mtr><mtd><mn>3</mn></mtd><mtd><mn>4</mn></mtd></mtr><mtr><mtd><mn>5</mn></mtd><mtd><mn>6</mn></mtd></mtr></mtable><mo>)</mo></mrow></mstyle></math>,...
   </p>
              <p>
   In the general <math title="m xx n"><mstyle displaystyle="true" fontfamily="serif"><mi>m</mi><mo>×</mo><mi>n</mi></mstyle></math> matrix, we used `cdots` for centred dots. This can be
   useful when writing infinite series, for example
   </p>
          </div>
          <div class="answer" id="student_answer13_output">
   <math title="e^x = 1+x+1/(2!)x^2 + 1/(3!)x^3 + cdots "><mstyle displaystyle="true" fontfamily="serif"><msup><mi>e</mi><mi>x</mi></msup><mo>=</mo><mn>1</mn><mo>+</mo><mi>x</mi><mo>+</mo><mfrac><mn>1</mn><mrow><mn>2</mn><mo>!</mo></mrow></mfrac><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mfrac><mn>1</mn><mrow><mn>3</mn><mo>!</mo></mrow></mfrac><msup><mi>x</mi><mn>3</mn></msup><mo>+</mo><mo>&#8943;</mo></mstyle></math>.</div>
          <textarea class="entrybox" id="student_answer13" onkeyup="AMdisplay('student_answer13','student_answer13_output',true)">`e^x = 1+x+1/(2!)x^2 + 1/(3!)x^3 + cdots `.</textarea>
          <div class="tutorialText">
              <p>
   Similarly, for low dots, as in <math title="1, ldots, n"><mstyle displaystyle="true" fontfamily="serif"><mn>1</mn><mo>,</mo><mo>...</mo><mo>,</mo><mi>n</mi></mstyle></math> use `...` or `ldots`.
   </p>
              <p>
   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.
   </p>
          </div>
          <div class="answer" id="student_answer14_output">
   <math title="|x|= {(x , if x ge 0 text(,)),(-x , if x &lt;0.):}"><mstyle displaystyle="true" fontfamily="serif"><mrow><mo>|</mo><mi>x</mi><mo>|</mo></mrow><mo>=</mo><mrow><mo>{</mo><mtable columnalign="left"><mtr><mtd><mi>x</mi></mtd><mtd><mrow><mspace width="1ex"></mspace><mo>if</mo><mspace width="1ex"></mspace></mrow><mi>x</mi><mo>&#8805;</mo><mn>0</mn><mrow><mtext>,</mtext></mrow></mtd></mtr><mtr><mtd><mo>-</mo><mi>x</mi></mtd><mtd><mrow><mspace width="1ex"></mspace><mo>if</mo><mspace width="1ex"></mspace></mrow><mi>x</mi><mo>&lt;</mo><mn>0</mn><mo>.</mo></mtd></mtr></mtable></mrow></mstyle></math></div>
          <textarea class="entrybox" id="student_answer14" onkeyup="AMdisplay('student_answer14','student_answer14_output',true)">`|x|= {(x , if x ge 0 text(,)),(-x , if x &lt;0.):}`</textarea>
          <br>
          <div class="tutorialText">
              <p>
   Notice the use of `text( )` round
   the comma after <math title="x ge 0"><mstyle displaystyle="true" fontfamily="serif"><mi>x</mi><mo>&#8805;</mo><mn>0</mn></mstyle></math> 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.
   </p>
          </div>
          <div class="mpar">
              You can look up symbols in the <a href="http://www.wjagray.co.uk/maths/SymbolList.html">symbol list</a>.</div>
          <div class="tutorialText">
              <p style="text-align: center;">
   <math title="((1,2,3,4),(a,b,c,d))"><mstyle displaystyle="true" fontfamily="serif"><mrow><mo>(</mo><mtable><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd><mtd><mn>3</mn></mtd><mtd><mn>4</mn></mtd></mtr><mtr><mtd><mi>a</mi></mtd><mtd><mi>b</mi></mtd><mtd><mi>c</mi></mtd><mtd><mi>d</mi></mtd></mtr></mtable><mo>)</mo></mrow></mstyle></math> <math title="\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ "><mstyle displaystyle="true" fontfamily="serif"><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo><mo>&nbsp;</mo></mstyle></math> <math title="{:(f:,[0,6], -&gt;, RR),( ,x ,|-&gt;, x^2+1):}"><mstyle displaystyle="true" fontfamily="serif"><mrow><mtable columnalign="left"><mtr><mtd><mrow><mi>f</mi><mo>:</mo></mrow></mtd><mtd><mrow><mo>[</mo><mn>0</mn><mo>,</mo><mn>6</mn><mo>]</mo></mrow></mtd><mtd><mo>&#8594;</mo></mtd><mtd><mo>&#8477;</mo></mtd></mtr><mtr><mtd></mtd><mtd><mi>x</mi></mtd><mtd><mo>&#8614;</mo></mtd><mtd><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mn>1</mn></mtd></mtr></mtable></mrow></mstyle></math>
   </p>
          </div>
          <br>
          <div class="answer" id="student_answer15_output">
          </div>
          <textarea class="entrybox" id="student_answer15" onkeyup="AMdisplay('student_answer15','student_answer15_output',true)"></textarea>
          <div class="footerBox">
              <div class="headerFooterContent">
                  <h3>
                      Acknowledgements</h3>
                  <p>
                      The ASCIIMath syntax and javascripts were developed by Peter Jipsen (Chapman University).
                      Further information can be found at the <a href="http://www1.chapman.edu/%7Ejipsen/mathml/asciimath.html">
                          ASCIIMath Homepage</a>.
                  </p>
                  <p>
                      The javascripts for this page were adapted from Peter Jipsen's <a href="http://math.chapman.edu/email/">
                          ASCIIMath email editor</a> by Keith Brunton at Edinburgh University.
                  </p>
              </div>
          </div>
      </div>
  </body></html>
  


(C) Æliens 27/08/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.