This problem has been driving me nuts this week as 400 student are trying to do and many of them running into problems.
Here's the problem from the library (and it appears that one bug has
been fixed from the version we're using, but not all of them). rochesterLibrary/setDiffEQ3Separable/ur_de_3_13.pg
Harmless enough problem, basically:
Solve y'= ay^k, y(0)=y_0
The solution is (obviously): (($k+1)*$a*t+$c)**(1/($k1))
The first bug (that looks correct in the current problem library) the
limits for the fun_cmp weren't correct, but that has been fixed and
looks okay now.
BUT WAIT! What if y_0<0 and k is odd, then this solution isn't correct. So, I threw in a simple little code: if ( ( $k/2 ) == int($k/2) ) { $adjust = 1 } else { $adjust = 1; } $answer1 = "$adjust * (($k+1)*$a*t+$c)**(1/($k1))";
BUT WAIT, what if k is even, then the student can factor a negative out
of the exponent, as in my student last night who did this: y = (1/(35t1/1024))^(1/5) = (1/(35t+1/1024))^(1/5)
But now the limits are screwed up again (because perl won't accept a negative to a fractional power).
So, frustrated late last night, I did this: DOCUMENT();
loadMacros( PG.pl, PGbasicmacros.pl, PGchoicemacros.pl, PGanswermacros.pl, PGgraphmacros.pl, PGmatrixmacros.pl, PGnumericalmacros.pl, PGauxiliaryFunctions.pl, PGmorematrixmacros.pl );
TEXT(beginproblem()); $showPartialCorrectAnswers = 1;
$a = random(2,9,1) * random(1,1,2); $k = random(4,6,1); $t0 = 0; $y0 = non_zero_random(6,6,1); $c = 1/$y0**($k1) + ($k1)*$a*$t0;
$tmin = int( $c / ( ($k1) * $a )) ; $lim1 = [ $tmin+2 , $tmin+3 ]; $lim2 = [ $tmin3, $tmin2 ];
if ($a < 0) { $lim = $lim1; } else { $lim = $lim2; }
if ( ( $k/2 ) == int($k/2) ) { $kodd = 0; } else { $kodd = 1; }
if ( $kodd and ($y0 < 0) ) { $adjust = 1; } else { $adjust = 1; }
$answer1 = "$adjust * (($k+1)*$a*t+$c)**(1/($k1))";
$answer2 = "($adjust) * ( ($k+1)*$a*t($c))**(1/($k1))";
BEGIN_TEXT Solve the separable differential equation [ frac{dy}{dt} = $a y^{$k} ,] and find the particular solution satisfying the initial condition [ y($t0) = $y0. ] $BR ( y(t) = ) { NAMED_ANS_RULE(ans1,40) }.
$PAR Hints and warnings (but this may not apply to your webwork question): $BR Remember to check your work by taking derivatives and plugging in the initial condition. $BR Remember that if you take an even root something, there is generally a +/. You may or may not have to be careful of this. (For example, how does one solve x^2=4?) $BR Following the last hint/warning, your solution will not have a +/ in ityou have to figure out if you want the + or the . $PAR
END_TEXT
$ans1 = $inputs_ref>{ans1}; $ans1 = '' unless defined($ans1);
$anshash11 = calleval( fun_cmp( $answer1, vars => 't',limits=> $lim1 ), $ans1); $anshash12 = calleval( fun_cmp( $answer1, vars => 't',limits=> $lim2 ), $ans1);
$anshash21 = calleval( fun_cmp( $answer2, vars => 't',limits=> $lim1 ), $ans1); $anshash22 = calleval( fun_cmp( $answer2, vars => 't',limits=> $lim2 ), $ans1);
if ( 1 == $anshash11>{score} ) { NAMED_ANS(ans1, fun_cmp($answer1, vars => 't',limits=> $lim1 )); } elsif ( 1 == $anshash12>{score} ) { NAMED_ANS(ans1, fun_cmp($answer1, vars => 't',limits=> $lim2 )); } elsif ( 1 == $anshash21>{score} ) { NAMED_ANS(ans1, fun_cmp($answer2, vars => 't',limits=> $lim1 )); } elsif ( 1 == $anshash22>{score} ) { NAMED_ANS(ans1, fun_cmp($answer2, vars => 't',limits=> $lim2 )); } else { NAMED_ANS(ans1, fun_cmp($answer1, vars => 't',limits=> $lim )); }
sub calleval { my ($ans_evaluator,$student_answer) = @_; my $rh_ans_hash = ""; if ( ref($ans_evaluator) eq 'AnswerEvaluator' ) { # new style $rh_ans_hash = $ans_evaluator>evaluate($student_answer); } elsif (ref($ans_evaluator) eq 'CODE' ) { #old style $rh_ans_hash = &$ans_evaluator($student_answer); } else { warn "There is a problem using the answer evaluator"; } return $rh_ans_hash; }
ENDDOCUMENT();
Now, in theory, I'm trying everything possible and if it works, the student should be given credit.
Now, here's the weird behavior. It seems, if you enter a wrong answer,
check answers, then enter the right answer, it will be marked wrong.
But then immediately resubmit the same answer and then it will marked
correct. Very bizarre.
Here's the specifics: use seed 110.
Enter and submit/check these answers:
1) ((12t1/81))^(1/4) (incorrect, marked incorrect w/ error. Fine) 2) ((12t1/81))^(1/4) (correct, marked incorrect w/ error. not ok) 3) ((12t1/81))^(1/4) (correct, marked correct)
Seems bizarre. This assignment is due today. I think I will probably delete this problem from our local problem library.
Blake
< Post or View Comments >
