## WeBWorK Problems

### Answer up to multiplication by a nonzero constant and added variables ### Answer up to multiplication by a nonzero constant and added variables

by David Protas -
Number of replies: 2
Is it possible to have an answer with an added variable checked up to a nonzero parameter multiple? I have an ODE with solutions given implicitly by F(x,y) = C. I want students to enter F(x,y). I have written the answer (in old style code, which I plan to update) as
ANS(fun_cmp("k($ans) + c", var=>['x','y'], params=>['k','c'] ) ); The trouble is that 0 is counted as a correct answer. Can anyone help? In reply to David Protas ### Re: Answer up to multiplication by a nonzero constant and added variables by Gavin LaRose - Hi David, Maybe something like the following?  Context("Numeric")->variables->are( x=>'Real', y=>'Real' );$ans = "...";
$ansObj = Compute($ans );
...
ANS( $ansObj->cmp( checker=> sub { my ($correct, $student,$self ) = @_;
my $context = Context()->copy;$context->flags->set(no_parameters=>0);
$context->variables->add( c=>'Parameter', k=>'Parameter' ); my$c = Formula($context,'c'); my$k = Formula($context,'k');$student = Formula($context,$student);
$correct = Formula($context,"$k*($ans) + $c"); return$correct == $student && Compute(0) !=$student;
}));


(This is shamelessly copied from the techniques page on adaptive parameters: <http://http://webwork.maa.org/wiki/AdaptiveParameters>.)

Gavin 