
Capture, Manipulate, and Display Precise Mathematical Notation




The InertForm package gives you tools to prevent simplification and evaluation so that you can examine exactly what was entered.
For example, when students use Math Apps, they are sometimes asked to enter a mathematical expression into a Math Entry box. By default, when Maple is asked what the student entered, Maple applies the same automatic simplification rules as it would if the expression was entered elsewhere in Maple. For example “2/4” would be returned as “1/2”.
Consider the following input expressions in boxes A and B:
Typing these expressions at a prompt or using the normal access functions for getting the expressions out of the math container will trigger some automatic builtin simplifications.
$\mathrm{DocumentTools}:\mathrm{Do}\left(\mathrm{\%BoxA}\right)\;$
$\mathrm{DocumentTools}:\mathrm{Do}\left(\mathrm{\%BoxB}\right)\;$
Most of the time, this is what you want, since you are interested in the mathematical result, not the form it was entered in. But occasionally, you want to know exactly that the student entered, because you want the answer in a particular form. With the InertForm package, you can capture the exact input.
The InertForm package allows you to extract the contents of a math entry box in a notation that will not evaluate. This notation has the advantage of being an unambiguous representation of a mathematical expression that follows strict rules which make it easy to take apart and compare with the desired response.
$\mathrm{InertForm}:\mathrm{FromMathContainer}\left(\mathrm{BoxA}\right)\;$
${\mathrm{\%/}}{}\left({2}{\,}{4}\right)$
 (3) 
$\mathrm{InertForm}:\mathrm{FromMathContainer}\left(\mathrm{BoxB}\right)\;$
${\mathrm{\%*}}{}\left({8}{\,}{\mathrm{\%/}}{}\left({\mathrm{\%sqrt}}{}\left({4}\right){\,}{\mathrm{\%^}}{}\left({4}{\,}{2}\right)\right)\right)$
 (4) 
The syntax of a InertForm expression is such that:
•

The operator or function name is prefixed with a % symbol.

•

Operators appear in a prefix location (before the operands), so 1 + 2 will appear as +(1,2), noting that + will be rewritten as %+.

This concept also allows you to easily build up expressions so they can be displayed in a precise way.
$\mathrm{expr}\u2254\mathrm{`\%/`}\left(\mathrm{`\%+`}\left(1comma;2\right)comma;3\right)semi;$
${\mathrm{\%/}}{}\left({\mathrm{\%+}}{}\left({1}{\,}{2}\right){\,}{3}\right)$
 (5) 
$\mathrm{InertForm}:\mathrm{Display}\left(\mathrm{expr}\right)semi;$
${\mathrm{\%/}}{}\left({\mathrm{\%+}}{}\left({1}{\,}{2}\right){\,}{3}\right)$
 (6) 
The gray + symbol gives you a hint of the underlying structure, and cut & paste will preserve the underlying form. The Display command also provides an option to make it appear as a noninert structure in every way.
$\mathrm{InertForm}:\mathrm{Display}\left(\mathrm{expr}comma;apos;\mathrm{inert}apos;equals;\mathrm{false}\right)semi;$
$\frac{{1}{+}{2}}{{3}}$
 (7) 
The InertForm package also provides commands for parsing 1D math expressions. For example, consider the following input expressions in text boxes C and D:
Again, let's compare the standard way of getting the values from text boxes.
$\mathrm{DocumentTools}:\mathrm{Do}\left(\mathrm{\%TextBoxC}\right)\;$
Note: The following command is expected to display an error message, as 3xy is not correct Maple syntax. Instead, 3*x*y is expected.
$\mathrm{DocumentTools}:\mathrm{Do}\left(\mathrm{\%TextBoxD}\right)\;$
${}$
The Parse command will operate on the string returned by GetProperty.
$\mathrm{InertForm}:\mathrm{Parse}\left(\mathrm{DocumentTools}:\mathrm{GetProperty}\left(\mathrm{TextBoxC}comma;''value''\right)\right)semi;$
${\mathrm{\%+}}{}\left({1}{\,}{1}\right)$
 (9) 
Implicit multiplication is available as an option. Note that variable names will be assumed to be one character long in this case.
$\mathrm{InertForm}:\mathrm{Parse}\left(\mathrm{DocumentTools}:\mathrm{GetProperty}\left(\mathrm{TextBoxD}comma;''value''\right)comma;\mathrm{implicitmultiply}\right)semi;$
${\mathrm{\%+}}{}\left({\mathrm{\%*}}{}\left({3}{\,}{\mathrm{\%*}}{}\left({x}{\,}{y}\right)\right){\,}{}{\mathrm{\%*}}{}\left({x}{\,}{y}\right){\,}{\mathrm{\%sin}}{}\left({x}\right)\right)$
 (10) 
These expressions can be displayed at any time using the Display command.
$\mathrm{InertForm}:\mathrm{Display}\left(\right)\;$
${\mathrm{\%+}}{}\left({1}{\,}{1}\right)$
 (11) 
$\mathrm{InertForm}:\mathrm{Display}\left(\right)\;$
${\mathrm{\%+}}{}\left({\mathrm{\%*}}{}\left({3}{\,}{\mathrm{\%*}}{}\left({x}{\,}{y}\right)\right){\,}{}{\mathrm{\%*}}{}\left({x}{\,}{y}\right){\,}{\mathrm{\%sin}}{}\left({x}\right)\right)$
 (12) 
They can also be converted to regular infixform in order to compute results.
$\mathrm{InertForm}:\mathrm{Value}\left(\right)\;$
${2}{}{x}{}{y}{\+}{\mathrm{sin}}{}\left({x}\right)$
 (13) 
${}$
${}$
${}$
