Here are some comments on your questions:
Point(0,$c/$b)
produces a decimal because Perl computes $c/$b
before Point()
is called, so the coordinates are decimals and not fractions. You are correct to try to use $d
instead, but because the context has changed, it doesn't really know that Fraction objects are special cases of Real numbers, and so complains about the coordinates not being reals. You can fix that by using:
$d = Compute( "$c/$b" )->with(isReal => 1) ;
or perhaps
ANS( Point( 0, $d->with(isReal=>1) ) -> cmp (
...
));
instead. I will modify the Fraction object to include this automatically, but right now I'm temporarily not able to make updates to the WeBWorK archive (because I haven't converted over from CVS to SVN, which is now being used to manage the archive). I'll do that soon.
If you make that change, your correct answers will show up properly (though student answers will show as decimals, since they aren't in Fraction context).
Alternatively, you could use
ANS(Compute("(0,$c/$d)")->cmp(
...
));
since Compute()
always shows the string that was used for the computation as the correct answer.
I'm not sure where such a statement is being produced. I don't see it in the samples I'm using, but that may be because I'm not going through a normal problem assignment to view the results.
You can disable the reduction rules that cause this transformation to occur by using
$LHS = Formula( "$a x + $b y" ) -> reduce("(-x)-y"=>0) ;
which will prevent the rule that converts -x-y to -(x+y). You can also use
$LHS = Formula( "$a x + $b y" ) -> reduce("(-x)-y"=>0,"(-x)+y"=>0) ;
to force the order to be preserved (so that -3x+2y does not become 2y-3x).
Hope those help.
Davide