Difference between revisions of "AlgebraicFractions"
m |
m |
||
Line 1: | Line 1: | ||
− | <h2>Algebraic Fractions |
+ | <h2>Algebraic Fractions in Student Answers</h2> |
<!-- Header for these sections -- no modification needed --> |
<!-- Header for these sections -- no modification needed --> |
Revision as of 12:16, 11 January 2010
Algebraic Fractions in Student Answers
This code shows how to format questions in which the answer is an algebraic fraction that has separate answer blanks for the numerator and denominator. This is useful for fractional answers that you want students to simplify as much as possible.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "PGunion.pl", "MathObjects.pl", "PGcourse.pl", ); TEXT(beginproblem()); |
Initialization:
We include the macros file |
Context("Numeric"); $frac = "\frac{d}{dx} \left( \frac{-(x^2+4)}{(x^2-4)^2} \right)"; $num = Formula("2 * x * (x**2 + 12)")->reduce; $den = Formula("(x**2 - 4)**3")->reduce; # # Display the fraction and answer blanks nicely # if ($displayMode eq 'TeX') { $displayfrac = "\[ $frac = ".ans_rule(10).ans_rule(10)." \]"; } else { $displayfrac = ColumnTable( "\( \displaystyle $frac = \)", ans_rule(20).$BR.$HR.ans_rule(20), indent => 0, separation => 10, valign => "MIDDLE" ); } |
Setup:
We define a string
We define a mode-dependent string
For fractions over fractions, to keep the font size large use the display fraction |
Context()->texStrings; BEGIN_TEXT Calculate the indicated derivative. Simplify your answer as much as possible. $BR $BR $BCENTER $displayfrac $ECENTER END_TEXT Context()->normalStrings; |
Main Text:
Everything is as usual. Insert the fraction and answer blanks using |
$showPartialCorrectAnswers = 1; install_problem_grader(~~&std_problem_grader); ANS($num->cmp); ANS($den->cmp); ENDDOCUMENT(); |
Answer Evaluation:
If you want to give students feedback on whether their numerator and denominator are correct, set |