WeBWorK Problems

MathQuill used with redefined operatorname

MathQuill used with redefined operatorname

by Paul Seeburger -
Number of replies: 2

I have a Calculus 2 integration problem where I want students to be able to enter their answer using the arcsec (x) form of this inverse trig. function, so I have added this option to the problem as shown below.

But MathQuill does not treat it properly, but instead inserts 'operatorname{arcsec}' in place of "arcsec".

To eliminate this error, do I have to create a custom grader?  Or is there another way I could define the arcsec as a function that would work properly with MathQuill?

Thanks!

Paul

See image below for the error given and the problem code below that:


# DESCRIPTION
# WeBWorK problem written by Paul Seeburger, <pseeburger@monroecc.edu>
# ENDDESCRIPTION



## DBsubject(Calculus - single variable)
## DBchapter(Techniques of integration)
## DBsection(Trigonometric integrals)
## Date(2/5/2014)
## Institution(Monroe Community College)
## Author(Paul Seeburger)
## KEYWORDS('calculus', 'integral', 'antiderivatives', 'indefinite integrals', 'inverse trig', 'arcsec')

## Textbook tags
## HHChapter1('Integration')
## HHSection1('Inverse Trigonometric Integrals')

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGchoicemacros.pl",
"hhAdditionalMacros.pl",
"parserFormulaUpToConstant.pl",
);
 
Context("Numeric");

$a = random(2,9,1);
$asq = $a*$a;
$b = random(2,5,1);
$bsq = $b*$b;
$c = $a*2+1;
$bound = Compute(1.01*($a/$b));

Context()->variables->set(x=>{limits=>[$bound, 10]});

Context()->functions->set( asec => {TeX => '\text {arcsec}'}, );

Context()->flags->set(
  reduceConstants=>0, # no decimals
  reduceConstantFunctions=>1, # combine 4+5*2?
  formatStudentAnswer=>'parsed', # no decimals
);

$aoverb = reduced_frac($a, $b);
$bovera = reduced_frac($b, $a);

$func = Compute("$c/(x*sqrt($bsq x^2 - $asq))");
$antider = Compute("($c/$a) arcsec(|$b x|/$a)");
$afunc = FormulaUpToConstant($antider." + C");

#$afunc->{test_at} = [[1, -$bound], [1, -$bound*2], [1, -$bound*10]];
$afunc->{test_at} = [-$bound, -$bound*2, -$bound*10];


TEXT(beginproblem());
Context()->texStrings;
BEGIN_TEXT

Antidifferentiate. You may need to transform the integrand
first.
$PAR
\(\displaystyle \int\frac {$c}{x \sqrt{$bsq x^2 - $asq}}\, dx =\)
\{ ans_rule(60) \}

END_TEXT
Context()->normalStrings;

ANS($afunc->cmp() );

Context()->texStrings;
BEGIN_SOLUTION
$PAR SOLUTION $PAR

Recognizing that this is NOT a natural log form integral, since we would need a factor of \(x\) in the numerator (and not in the denominator) for that, we check to see if this may be an inverse trig form integral by rewriting the denominator of the integrand. $PAR
We see that \( a = $a \), \( u = $b x \), and \( du = $b \, dx \), $PAR
and we recognize that the integral is in the $BBOLD arcsecant $EBOLD form, 
\[ \int\frac {du}{u\sqrt{u^2 - a^2}} = \frac{1}{a}\text{arcsec}\left(\frac {|u|}{a}\right) + C.\]
Then we are able to evaluate the integral as follows:
\[
  \int\frac {$c}{x \sqrt{$bsq x^2 - $asq}}\, dx =
  $c \int\frac {$b}{$b x \sqrt{($b x)^2 - ($a)^2}}\, dx
\]
\[
  = \frac {$c}{$a} \text{arcsec}\left(\frac{|$b x|}{$a} \right) + C
  = \frac {$c}{$a} \text{arcsec}\left($bovera |x| \right) + C.
\]

END_SOLUTION
Context()->normalStrings;


COMMENT('MathObject version');
ENDDOCUMENT();



In reply to Paul Seeburger

Re: MathQuill used with redefined operatorname

by Glenn Rice -
I just submitted a pull request that removes the operatorname from the text output. You could download the files from that pull request and replace the ones on your server to fix this issue. The pull request is https://github.com/openwebwork/webwork2/pull/1200.

You can also tell your students to use the inverse function notation.  Have them enter sin^(-1) instead.  That works with the current javascript, and webwork recognizes that.
In reply to Glenn Rice

Re: MathQuill used with redefined operatorname

by Paul Seeburger -

Thank you, Glenn!

I appreciate your help on this!  I really don't like having students use the sec^(-1) notation, as I think it is so easy to misunderstand, but I do see that this works, as have some of my students.

I think asec(x) also would work, but again, I don't want my students to develop the habit of writing arcsec x this way.  =)

Paul