## WeBWorK Problems

### Re: Constants and General Solutions to ODEs

by Alex Jordan -
Number of replies: 0
Hi Lynda,

I know you posted this question a long time ago, but I just wrestled with this problem, and the "solution" I came works like this:

Students will be required to use C for the arbitrary constant, and C should be added as a variable to the context.

$answer = Formula("1/(x+C)"); which is the solution to y' = -y^2 Make a custom answer checker that checks for two things: 1. the student's answer solves the differential equation 2. whatever the student has entered in place of C is a linear (and nonconstant) function of C I probably do not have the most efficient way to do this, but my custom checker works like this: ANS($answer->cmp( checker=>sub {
my ( $correct,$student, $ansHash ) = @_; my$dstudent = $student->D('x'); my$lhs = Formula("$dstudent"); my$rhs = Formula("-($student)^2"); my$studentC = Formula("1/$student - x"); my$dstudentC = $studentC->D('C'); my$ddstudentC = $dstudentC->D('C'); if (($lhs == $rhs) && ($ddstudentC == Formula("0")))