WeBWorK Problems

simplifying square roots

Re: simplifying square roots

by Valerio De Angelis -
Number of replies: 0
I wasn't quite able to make it work. If I use Context("LimitedRadical") as in your example, I find that the system will mark the answer 1/(6sqrt(2)) as incorrect and gives the message "You must simplify your answer further". It does not give the custom message in $evaluator. I then tried using Context("Numeric") and then the custom message is displayed every time, no matter how the answer is entered.

Below is the code I used.
I like  ...[__]{$evaluator}{20}   to adjust the width
Thanks


DOCUMENT();       

loadMacros("PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"AnswerFormatHelp.pl",
"PGcourse.pl",
"contextFraction.pl",
"contextLimitedRadical.pl",
"parserOneOf.pl",
"answerHints.pl"
);

TEXT(beginproblem());



$a=random(1,9,1);

$c = list_random(2,3,5,6,7,10); #square-free
$b = random(2,4,1);
$d = $b**2*$c;

$b2 = 2*$b;
$b2c = $b2*$c;
Context("LimitedRadical");
$ansA = Formula("1/($b2*sqrt($c))");
$ansB = Formula("sqrt($c)/$b2c");


$evaluator = $ansB->cmp()->withPostFilter(AnswerHints($ansA => ["Rationalize the denominator", replaceMessage=>1]));
BEGIN_PGML

Use algebra to find the exact value of the following limits. Do not use decimals.



[``\lim_{x\rightarrow [$d]} \frac{\sqrt{x}-\sqrt{[$d]}}{x-[$d]}=``][_]{$evaluator}{20}



END_PGML
BEGIN_PGML_SOLUTION
*SOLUTION*



[``\lim_{x\rightarrow [$d]} \frac{\sqrt{x}-\sqrt{[$d]}}{x-[$d]}=\frac{\sqrt{[$c]}}{[$b2c]}``]



END_PGML_SOLUTION

ENDDOCUMENT();