WeBWorK Problems

limits in integrals

limits in integrals

by Darwyn Cook -
Number of replies: 2
The following code causes an unexpected error, Webwork displays the second digit of the upper limit of integration in the integrand. The fix is simple enough when it's caught, parenthesis around the $b in the tex command handles it. Doesn't seem like desirable behavior though

DOCUMENT();

loadMacros(
"PGbasicmacros.pl",
"PGanswermacros.pl",
"PGauxiliaryFunctions.pl",
"MathObjects.pl",
);

$showPartialCorrectAnswers = 1;

##############################################################################
##
## Problem and Answer Set Up
##

$a = random(1,9,1);
$b = Compute("10");
$f = Formula("x");
TEXT(beginproblem());

Context()->texStrings;
BEGIN_TEXT
\[
\begin{aligned}
\int\limits_$a^$b $f dx &&\\
\end{aligned}
\]

END_TEXT
Context()->normalStrings;

ENDDOCUMENT();

In reply to Darwyn Cook

Re: limits in integrals

by Michael Gage -
This is standard TeX behavior. \int_0^10 dx will give you the integral from 0 to 1 of 0. Unless braces are used TeX always assumes the following input has only one character. To be safe then one should always use braces \int_{0}^{10} even in standard TeX and some TeX editors encourage this.

It might not be intuitive, but TeX is unlikely to change.

It's a good idea to always use the braces in PG code even when you don't always need them. You never know when some variable will change from one character to two.