### Exactness: student answers and display of expressions

by Murphy Waggoner -(A) I have done a search of the UsingWW forums and the MAA WW wiki and the web for how to require students to enter exact trig values, and the only reference I can find is: #ANS(exact_no_trig($answer[$n]));

However, it won't work here. Maybe I am not including the right libraries, but isn't exact_no_trig and old answer checker? I can find examples where it is used, but cannot find an example where it is used with MathObjects.

Can I require exact trig answers and user MathObjects? Will the same answer checker allow exact answers like arctan(5/4)?

(B) At first I created a Formula:

$z[0] = Formula("$x[0] sqrt(2) + $y[0] sqrt(2) i");

Using that I could calculate the answer with

$answer = Complex(arg($z[0]));

But when I displayed it using \( $z[0] \) the sqrt(2)s showed up as decimals. Strangely, a pi shows up as pi if I replace the sqrt(2) with pi.

Formula wouldn't let me put in \sqrt{2}. So, I ended up creating a LaTeX string for displaying, but then had to create a calculation separately. Now, if I want to change the complex number, I have to change it in two places.

It is okay the way it is, but clunky. Maybe that is the nature of WebWork and pg, and I will learn to embrace it. But if I am missing some nice fix I'd like to know.

DOCUMENT(); # This should be the first executable line in the problem.

loadMacros(

"PG.pl",

"PGbasicmacros.pl",

"MathObjects.pl",

"PGanswermacros.pl"

);

TEXT(beginproblem());

Context("Complex");

#####################################

# Create the numbers for the questions

# a point at a pi/4 angle

$x[0] = random( 2, 6, 1)*random(-1,1,2);

$y[0] = $x[0]*random(-1,1,2);

$z[0] = "$x[0]\sqrt{2} + $y[0] \sqrt{2}\ i";

$answer[0] = Complex("abs($x[0] sqrt(2) + $y[0] sqrt(2) i)");

$answer[1] = Complex("arg($x[0] sqrt(2) + $y[0] sqrt(2) i)")->with(period => 2*pi);

$num_ans = @answer;

Context()->texStrings;

BEGIN_TEXT

Write the following numbers in the polar form. Make sure that \(r > 0\) and write angles in radians with exact values (no decimal approximations):

$PAR

$PAR

(a) \( \displaystyle z = $z[0]\)

$PAR

\( r = \) \{ans_rule(15)\}, \( \theta = \) \{ans_rule(15)\}

END_TEXT

#####################

# check answers

Context()->normalStrings;

# Show students which answers are correct (... = 1)

#$showPartialCorrectAnswers = 1;

for ( $n = 0; $n <= $num_ans - 1; $n++ )

{

ANS($answer[$n]->cmp);

#ANS(exact_no_trig($answer[$n]));

}

ENDDOCUMENT(); # This should be the last executable line in the problem.

### Re: Exactness: student answers and display of expressions

by Darwyn Cook -There are two options: reduce the student answer and compare to pi/4, or accept decimal answers to a large number of decimal places. Even if you use high end software like Sage or mathematica reduce is a tricky thing, and is best avoided.

One possible method for reducing fractions is here:

http://webwork.maa.org/wiki/AlgebraicFractions#.U-qZoWOTFSA

The students input the numerator and denominator separately, you could use the multanswer checker to check for a "reduced" answer by dividing their denominator into their numerator. That still would not prevent a student from entering pi/4 into the numerator and 1 as the denominator.