Prevent expression simplification with InertForm

By default, expressions are automatically simplified by the Maple engine, however, this simplification can be prevented easily with InertForm. In the examples below, we'll show how to add a simplifiable equation to question text with MathML, how to grade it and how to ask for an exact expression.
Let's start with the algorithm. The code below shows how to generate and use InertForm for equation presentation:
$a = range(3,9,3); $b = rint(15); # (optional) As you can see the equation gets simplified. $my_equation = maple("$b*x*y + 3/$a*x*y"); # (optional) This will generate InertForm code $inert_form_equation = maple("use InertForm:NoSimpl in $b*x*y + 3/$a*x*y: end "); # The code below generates a MathML code that can be placed in question text. $simpl_equation = maple("use InertForm:NoSimpl in $b*x*y + 3/$a*x*y: end: printf(InertForm:ToMathML(%)) ");
In many cases InertForm parse to MathML is an overkill, similar functionality can be achieved with the following:
$a = range(3,9,3); $b = rint(15); $simpl_equation = mathml("$b*x*y + 3/$a*x*y","nosimplify");
But how can we prevent students from entering the original, nonsimplified expression into the answer field? The answer is easy: Mathematica Formula response area with option Formula without simplification:
InertForm package can also be used to ask for a specific form of equation. As an example, we'd like students to enter a polynomial \( 2*x^3 + x^2 + 6*x \), in that specific form, hence avoiding commutative properties.
First, we'll need to find the InertForm of the polynomial. This can be done with Maple or by reusing part of earlier Maple TA algorithm:
# This will generate InertForm code $inert_form_equation = maple("use InertForm:NoSimpl in 2*x^3 + x^2 + 6*x : end ");
This time we're interested in the InertForm code:
`%+`(`%*`(2,`%^`(x,3)),`%^`(x,2),`%*`(6,x))
It's not important to understand what it means and how it is generated, just consider it as a different notation of the earlier polynomial.
The only thing that remains is the Maple grading code:
use InertForm:NoSimpl in $RESPONSE: end: evalb( (`%+`(`%*`(2,`%^`(x,3)),`%^`(x,2),`%*`(6,x))) = % )