# Question Writing Oddities

## Purpose of this document

This document describes some of the common pitfalls and oddities of the IMathAS question language. For detailed question language reference, please refer to the help file.

## IMathAS Question Writing Oddities

#### Fractional Exponent Display

Fractional exponents do not seem to display well with MathML. For example, x^(2/3) will display as x^(2/3). The best approach is to try x^(2//3), which renders as x^(2//3). If you want to raise up the exponent higher, a silly trick to try is x^({::}^(2/3)). The {::} creates an invisible item. This renders as x^({::}^(2/3)).

#### Curly Braces

Beware of using curly braces {}. While curly braces can be used for display or for grouping, like in the TeX-style \frac{3}{5}, strange things can happen if you place variables inside the curly braces. This is because PHP, the back-end interpreter, uses curly braces to isolate variables from surrounding text.

For example, if you wanted to display 3x rather than 3*x, then you need to enter 3x rather than 3*x. With a variable coefficient, writing $ax doesn't work, since the interpreter thinks that "$ax" is the variable. Curly braces can avoid this, allowing you to write {$a}x to achieve the desired result. Alternatively, writing$a x works as well. In rendered math (inside backticks), extra spaces are removed.

As a side effect, writing \frac{$a}{$b} causes problems, since the interpreter essentially removes the curly braces during variable interpolation, leaving \frac34 (if $a=3,$b=4). A simple way to avoid this is to add spaces: enter \frac{ $a }{$b } instead, and the interpreter will leave the curly braces alone, leaving \frac{ 3 }{ 4 }, which will correctly display as the desired 3/4.

When defining variables for Function type answer, beware that if the variable shares a letter with a function being used, you have to be a bit careful. For example, if $variables="r", and you typed$answer = "rsqrt(2)", the system will get confused. This can be solved by putting an explicit multiplication between the r and the square root: $answer = "r*sqrt(2)". Students in their entry will also need to either put an explicit multiplication sign, or at least leave a space between the variable and the function name #### Makepretty If you define: $a,$b,$c = rand(-5,5,3)
$eqn = "$a x^2 + $b x +$c"


then there is potential your $eqn would display as 4x^2+-3x+2 (that's 4x^2+-3x+2). To clean up the double sign issue, use the makepretty function: $eqn = makepretty("$a x^2 +$b x + $c")  Makepretty is automatically run on$answer for Function type problems

#### Less than and Greater than signs

Because HTML uses angle brackets to denote HTML tags, and since IMathAS allows HTML tags for formatting purposes, the use of < and > in problem text can sometimes be problematic. The system attempts to differential between HTML tags and inequalities, but does not always do so successfully.

Generally, same direction inequalities are handled okay, such as 3 < x < 5. But mixed inequalities, such as "x < 3 and x > 1" are sometimes mishandled. To avoid this, it is recommended that you use the HTML &lt; and &gt; in place of < and >. Inside backticks (rendered as math), lt and gt are sufficient to denote < and >. You can also use le and ge or leq and geq inside backticks for le and ge.