PREP 2014 Question Authoring - Archived

Exactness: student answers and display of expressions

Exactness: student answers and display of expressions

by Murphy Waggoner -
Number of replies: 4
I was avoiding writing the questions for the exponential form/polar form of complex numbers because I knew I would be frustrated with the exactness issues: i.e., (A) that students should enter pi/4 as pi/4 instead of a decimal approximation. (B) But also, I want the code to be robust, but I can't seem to create one variable that both displays the square roots exactly and evaluate for the answers.

(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.


In reply to Murphy Waggoner

Re: Exactness: student answers and display of expressions

by Darwyn Cook -
The answer to A is a bit tricky. You want to accept pi/4, but what about 2pi/8? If you only want pi/4 you could set up the answer as a string, but you are bound to have a student enter 1/4*pi, and that is not the same string as pi/4. If you use a string the answer will only be marked correct if the student enters exactly pi/4.

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.


In reply to Darwyn Cook

Re: Exactness: student answers and display of expressions

by Murphy Waggoner -
I'd be happy to accept any correct multiple of pi, just not the decimal approximation.  I guess one way would be to have the pi there already as text next to the answer blank and expect them to enter the multiple.  I wouldn't mind 0.25 then.  But that doesn't seem very authentic.


In reply to Murphy Waggoner

Re: Exactness: student answers and display of expressions

by Murphy Waggoner -
In this case, if the answer was arctan (3/4) there wouldn't be a pi in the answer, and so hardwiring the pi is a bad idea.  In this case I would want them to enter arctan (3/4) as the exact answer (or arctan (0.75) = arctan (6/8)).
In reply to Darwyn Cook

Re: Exactness: student answers and display of expressions

by Murphy Waggoner -
One work around I have seen is to have the students enter p for pi and then have the answer as an expression in terms of the variable p.  But then if the student entered pi/4 it would be counted wrong.  Again, not very authentic.