First, you don't need to load parserCustomization.pl
(and shouldn't) since it is loaded automatically when MathObjects.pl
is loaded. You should, however, load PGcourse.pl
as the last macro file. This serves a similar function to parserCustomization.pl
but will work even with problems that don't load MathObjects.pl
.
Second, in terms of the values of $a
and $b
, you could use non_zero_random()
rather than random()
. This would prevent either variable from being zero (whereas yours allows one or the other to be zero).
If you do use the if-then
, you don't need the extra parentheses around the equality checks. You can do
if ($a == 0 && $b == 0) {$b = 2}Third, you don't need to use two separate variables for the partial derivatives and their reduced versions. You could just do
$fx = $f->D('x')->reduce;But the derivative function already includes an automatic call to
reduce()
, so there is no need to add that yourself (other than the hack that I mentioned earlier to convert to string and parse again).
Finally, you may want to make your answer blanks a like wider, as vectors can take some space to type, especially if students are going to include computations as part of their answers (as they often do for this type of problem).
The rest looks good!