Greetings,
I could use some help figuring out why the following code seems to work fine (marks correct answers as correct) for most seeds (for example 708 and 700), but not for seed 2944.
Any hints as to where I should focus my efforts here?
Thanks!
###############################################################
##############################################
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"freemanMacros.pl",
"unionTables.pl",
"contextFraction.pl",
);
##############################################
Context("Numeric");
Context()->flags->set(reduceConstants=>0,reduceConstantFunctions=>0);
Context()->variables->are(x=>'Real',y=>'Real',C=>'Real');
$a = random(1,20,1);
$b = random(1,20,1);
$a2b2 = $a**2+$b**2;
$ay = Formula("$a y")->reduce;
$ax = Formula("$a x")->reduce;
$bx = Formula("$b x")->reduce;
$acos = Formula("$a cos($bx)")->reduce;
$bsin = Formula("$b sin($bx)")->reduce;
Context()->flags->set(reduceConstants=>0,reduceConstantFunctions=>0);
Context()->variables->are(x=>'Real',y=>'Real',C=>'Real');
$answer = Formula("1/$a2b2($acos+$bsin)+C/(e^($ax))");
##############################################
Context()->texStrings;
BEGIN_TEXT
\{beginproblem()\}
$PAR
Find the general solution of the first-order linear differential equation
\[y' +$ay= \cos($bx)\]
$PAR
Use $BBOLD C$EBOLD for the arbitrary constant. $PAR $PAR
Note: Your solution may require Integration by parts (twice), or alternatively you could use item 20 in the table of integrals (in the text).
$PAR
\(y = \) \{ans_rule(50)\}
END_TEXT
Context()->normalStrings;
##############################################
$showPartialCorrectAnswers = 1;
ANS( $answer->cmp( checker=>sub {
my ( $correct, $student, $ansHash ) = @_;
my $dstudent = $student->D('x');
my $lhs = Formula("$dstudent+$a*$student");
my $rhs = Formula("cos($b*x)");
my $studentC = Formula("($student-1/$a2b2*($acos+$bsin))*(e^($ax))");
my $dstudentC = $studentC->D('C');
my $ddstudentC = $dstudentC->D('C');
if (($lhs == $rhs) && ($ddstudentC == Formula("0")))
{ if ($dstudentC != Formula("0"))
{return 1}
else {Value->Error("Your answer is not the most general solution.")}
}
else {return 0};
} ) );
ENDDOCUMENT();
WeBWorK Problems
Correct answer marked wrong with certain seeds
This forum has a limit to the number of forum postings you can make in a given time period - this is currently set at 10 posting(s) in 1 day