I've been trying to use the "ImplicitEquation" context, and I have it running OK, but the problem I run into is checking multiple equations. It seems that the variable ranges need to be set to particularly friendly ranges for each equation individually. I managed to get it working using the implementation below, but this requires that the two equations be given in a particular order. Is there any way to do this so the order doesn't matter?
There may very well be a better way to do *this particular problem*, since the equations are linear, but can this problem be solved in general for the ImplicitEquation context?
Thanks,
Joe
________________________________________
DOCUMENT();
loadMacros(
"PGstandard.pl", # Standard macros for PG language
"MathObjects.pl",
"source.pl", # allows code to be displayed on certain sites.
"PGcourse.pl", # Customization file for the course
"parserImplicitEquation.pl",
);
# Print problem number and point value (weight) for the problem
TEXT(beginproblem());
# Show which answers are correct and which ones are incorrect
$showPartialCorrectAnswers = 1;
##############################################################
#
# Setup
#
#
Context("ImplicitEquation");
Context()->variables->set(
x=>{limits=>[-2,2]},
y=>{limits=>[-14,0]}
);
$eqn1 = ImplicitEquation("3*x - y = 8");
##############################################################
#
# Text
#
#
Context()->texStrings;
BEGIN_TEXT
Express the given vector equation as a system of linear equations.
$BR
\(
x \left[ \begin {array}{c} 3 \\ 2 \end {array} \right]
+
y \left[ \begin {array}{c} -1 \\ 5 \end {array} \right]
=
\left[ \begin {array}{c} 8 \\ 13 \end {array} \right]
\)
$BR
Equation 1: \{ ans_rule(35) \}
$PAR
END_TEXT
Context()->normalStrings;
##############################################################
#
# FIRST ANSWER
#
#
ANS( $eqn1->cmp() );
##############################################################
#
# SECOND ANSWER
#
#
Context("ImplicitEquation");
Context()->variables->set(
x=>{limits=>[-2,2]},
y=>{limits=>[1.8,3.4]}
);
$eqn2 = ImplicitEquation("2*x + 5*y = 13");
Context()->texStrings;
BEGIN_TEXT
Equation 2: \{ ans_rule(35) \}
END_TEXT
Context()->normalStrings;
ANS( $eqn2->cmp() );
ENDDOCUMENT();