WeBWorK Problems

Context("Fraction") and FormulaUpToConstant

Context("Fraction") and FormulaUpToConstant

by Chrissy Safranski -
Number of replies: 0
Can I not use both FormulaUpToConstant for an indefinite integral and Context("Fraction") at the same time?  The only reason I'm trying to is that I would like the correct answer to display as the fraction, rather than the decimal.  I'm not trying to limit what students can enter.  

If I change FormulaUpToConstant to Formula or Compute, then I don't get any errors and the display of the correct answer is what I want, but leaving it as FormulaUpToConstant gives errors from the context pl files and from the Differentiaion parser.  I really want students to practice giving the +C, so I like using FormulaUpToConstant instead of writing the +C in the text.  

-----------------------------------
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"contextFraction.pl",
"answerHints.pl",
"parserFormulaUpToConstant.pl",
 "PGcourse.pl",   
);

sub context::Fraction::Real::cmp_defaults
{Value::Real::cmp_defaults(@_)};

TEXT(beginproblem());
$showPartialCorrectAnswers = 1;

Context("Fraction");
Context()->variables->are(x=>"Real",dx=>"Real");
Context()->{error}{msg}{"Variable 'd' is not defined in this context"} = 
  "Don't leave a space - type 'dx' (without quotes).";

$a=random(2,10,1)*random(-1,1,2);

$u=Compute("x");
$dvnodx = Compute("e^($a x)");
$ddvnodx = $dvnodx->D->reduce;
$dv = Compute("$dvnodx dx");
$dunodx=$u->D;
$du= Compute("$dunodx dx")->reduce;
$v=Compute("1/$a* e^($a x)")->reduce;
$uv = ($u)*($v)->reduce;
$vdu = $v*$du->reduce;
$ans=FormulaUpToConstant("1/$a x e^($a x)-1/($a)^2 e^($a x)");