Thanks,
Mary Cameron
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserPopUp.pl",
"answerHints.pl",
"compoundProblem.pl",
"problemRandomize.pl", # to get more problem practice
"parserImplicitPlane.pl", # for VA and HA linear equations
);
TEXT(beginproblem());
# Show which answers are correct and which ones are incorrect
$showPartialCorrectAnswers = 1;
ProblemRandomize(when => "Correct", onlyAfterDue => 0);
Context("Numeric");
############################## Setup
# Choose two different vertical asymptotes
@va = ();
$va[1] = random(-9,9,1);
do { $va[2] = random(-9,9,1); } until ( $va[1] != $va[2]) ;
$denom = Formula( "x^2 - ($va[1] + $va[2]) * x + $va[1] * $va[2]" ) -> reduce ( "(-x)-y" => 0, "(-x)+y" => 0 );
$f = Formula("1/$denom");
@answers = ();
################### The following WORKS -- checking just ONE linear equation:
#Context("ImplicitPlane")->variables->are(x=>"Real",y=>"Real");
#$v1 = ImplicitPlane("x=$va[1]") ; # vertical asymptote equation
#$answers[1] = ImplicitPlane("x=$va[1]") ; # vertical asymptote equation WORKS
#$answers[1] = ImplicitPlane( $v1 ) ; # also works (if put $v1 defined before this)
################### The following FAILS -- Want to check Two linear equation answers as a list of two linear equations
Context("ImplicitPlane")->variables->are(x=>"Real",y=>"Real");
$v1 = ImplicitPlane("x=$va[1]") ; # vertical asymptote equation
$v2 = ImplicitPlane("x=$va[2]") ; # vertical asymptote equation
$answers[1] = List( $v1, $v2 );
################### more FAILURES
#$answers[1] = List ( ImplicitPlane( $v1 ) , ImplicitPlane( $v2 ) ); # FAILS Can't locate object method "blank" via package "ImplicitPlane::formula"
#$answers[1] = List ( $v1, $v2 ); # FAILS ... "blank"
#$answers[1] = List ( "$v1" ); # also FAILS with just one... "blank"
#$answers[1] = List ( "x=$va[1]", "x=$va[2]" ); # FAILS ... "blank"
#$answers[1] = List ( $va[1], $va[2] ); # correct answers are like 4, 5 rather than "x=4", and "x=5".
#$answers[1] = List ( "$va[1]", "$va[2]" ); # same problem here -- 4,5 is correct "
$ans_eval[1] = $answers[1] ->cmp();
################################# Text #1
Context()->texStrings;
BEGIN_TEXT
${BBOLD}Part 1 of 3:${EBOLD}
Enter the equation(s) for the vertical asymptotes of \( f(x) = \displaystyle $f \)
$BR If there is more than one vertical asymptote, separate the equations with commas.
$BR If there are no vertical asymptotes, enter "NONE"
$BR The equations for the vertical asymptotes of \( f(x) \) are
\{ ans_rule(20) \}
END_TEXT
################################ Answers #1
Context()->normalStrings;
ANS( $ans_eval[1] );
ENDDOCUMENT();