WeBWorK Problems

Tolerance problems - exp(...) works fine, but e^(...) is "wrong"

Tolerance problems - exp(...) works fine, but e^(...) is "wrong"

by Philip Loewen -
Number of replies: 2

I'm using PGML and some subset of my students are getting correct answers marked wrong, for the reason in the subject line. If they enter "exp(-6x)*[...]" just like I did when composing the answer, they get the happy green flash, whereas if they enter a form that should be mathematically equivalent as "e^(-6x)*[...]" they get marked wrong. How do I fix this?

Here are the key lines in my problem source file. I define the answer like this:

$sinecase    = FormulaUpToConstant("exp(-$k*x)*( -(m)/(m^2+$k^2)*cos(m*x) - ($k)/(m^2+$k^2)*sin(m*x))") -> reduce();

I use the answer-checker as follows:

Answer:  [``\ \int e^{-[$k] x}\sin(m x)\,dx =\ ``][____________________________________________]{$sinecase}

By requesting diagnostics in the second line shown here, I can see that the issue is that some relative tolerance threshold is exceeded at a level around 1E-11. I tried to address this by changing the original definition of the desired answer as follows, but this did not work:

$sinecase    = FormulaUpToConstant("exp(-$k*x)*( -(m)/(m^2+$k^2)*cos(m*x) - ($k)/(m^2+$k^2)*sin(m*x))")
               -> with(  tolType => 'relative', tolerance => 0.001) -> reduce();

Beyond, "How do I fix this?" I would like to know if there is some comparatively self-contained nugget of deeper WW understanding that I could add to my limited stock in order to defend myself against inviting this problem back in the future.

Thanks, Philip


In reply to Philip Loewen

Re: Tolerance problems - exp(...) works fine, but e^(...) is "wrong"

by Alex Jordan -

It sounds like you could restrict the test point domain. Something like

Context()->variables->set(x => { limits => [-1/$k, 1/$k] });
And then the argument to exp() or e^() will be small. You could change those "1"s to something larger if you like.