LimitsOfIntegration: Difference between revisions

From WeBWorK_wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 27: Line 27:
"PGstandard.pl",
"PGstandard.pl",
"MathObjects.pl",
"MathObjects.pl",
"unionTables.pl",
"PGunion.pl",
);
);
TEXT(beginproblem());
TEXT(beginproblem());
Line 35: Line 35:
<p>
<p>
<b>Initialization:</b>
<b>Initialization:</b>
We need to include the macros file <code>unionTables.pl</code>.
We need to include the macros file <code>PGunion.pl</code>.
</p>
</p>
</td>
</td>
Line 46: Line 46:
<pre>
<pre>
Context("Numeric");
Context("Numeric");
#
#
# display the integral nicely
# display the integral nicely
Line 52: Line 53:
   $integral =
   $integral =
     '\[\int_{'.ans_rule(4).'}^{'.ans_rule(4).'}'.
     '\[\int_{'.ans_rule(4).'}^{'.ans_rule(4).'}'.
         ans_rule(35).'\,dx\]';
         ans_rule(10).'\,dx\]';
} else {
} else {
   $integral =
   $integral =
  $PAR.
  $BCENTER.
   BeginTable().
   BeginTable().
     Row(['\(\displaystyle \int\)',
     Row(['\(\displaystyle \int\)',
       ans_rule(4).$BR.$BR.ans_rule(4),
       ans_rule(4).$BR.$BR.ans_rule(4),
       ans_rule(35),
       ans_rule(10),
       '\(dx\).'],separation=>2).
       '\(dx\).'],separation=>2).
   EndTable().
   EndTable();
  $ECENTER;
}
}
</pre>
</pre>
</td>
</td>
Line 83: Line 80:
Context()->texStrings;
Context()->texStrings;
BEGIN_TEXT
BEGIN_TEXT
\( \displaystyle \int_1^3 x^2 \, dx = \)
Set up the integral of \( x^2 \) from 1 to 3.
$PAR
$BCENTER
$integral
$integral
$ECENTER
END_TEXT
END_TEXT
Context()->normalStrings;
Context()->normalStrings;

Revision as of 05:15, 27 April 2010

Answer Blanks in the Limits of an Integral


This PG code shows how to put answer blanks into the limits of an integral.

Problem Techniques Index

PG problem file Explanation
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGunion.pl",
);
TEXT(beginproblem());

Initialization: We need to include the macros file PGunion.pl.

Context("Numeric");

#
# display the integral nicely
#
if ($displayMode eq 'TeX') {
  $integral =
    '\[\int_{'.ans_rule(4).'}^{'.ans_rule(4).'}'.
         ans_rule(10).'\,dx\]';
} else {
  $integral =
   BeginTable().
     Row(['\(\displaystyle \int\)',
       ans_rule(4).$BR.$BR.ans_rule(4),
       ans_rule(10),
       '\(dx\).'],separation=>2).
   EndTable();
}

Setup: We define a mode dependent integral with three answer blanks.

Context()->texStrings;
BEGIN_TEXT
Set up the integral of \( x^2 \) from 1 to 3.
$PAR
$BCENTER
$integral
$ECENTER
END_TEXT
Context()->normalStrings;

Main Text: The problem text section of the file is as we'd expect. We insert the integral with answer blanks using $integral.

$showPartialCorrectAnswers = 1;

ANS( Real(3)->cmp() );
ANS( Real(1)->cmp() );
ANS( Formula("x^2")->cmp() );

ENDDOCUMENT();

Answer Evaluation: As is the answer.

Problem Techniques Index