## PREP 2013 Question Authoring - Archived

### ImplicitEquation context with multiple equations

by Joe Wagner -
Number of replies: 4
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();

"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() );

##############################################################
#
#
#

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();

### Re: ImplicitEquation context with multiple equations

by Paul Pearson -
Hi Joe,

Use "parserImplicitPlane.pl" instead of it's evil cousin "parserImplicitEquation.pl". ImplicitPlane is robust and easy to use, whereas ImplicitEquation is fickle and sometimes unreliable. As you noticed, in order to get ImplicitEquation working well, you had to set the domain large enough so that solutions could be found. On the other hand, ImplicitPlane knows a few tricks for evaluating linear equations easily and reliably, so it usually works well without any adjustments.

Note that using "parserImplicitPlane.pl" means using Context("ImplicitPlane"); and the ImplicitPlane("x+y=1"); constructor for this type of MathObject.

To check answers from multiple answer blanks for which the order in which the answers appear does not matter, use the "unorderedAnswer.pl" macro and then replace

ANS( $eqn1->cmp ); ANS($eqn2->cmp );

by

UNORDERED_ANS( $eqn1->cmp,$eqn2->cmp );

You should randomize this question. When you randomize it, be sure to check for equivalent equations (and then avoid using them!).

Best regards,

Paul Pearson

###################################################

DOCUMENT();

"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
"parserImplicitPlane.pl",
"unionTables.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("ImplicitPlane");$eqn1 = ImplicitPlane("3*x - y = 8");
$eqn2 = ImplicitPlane("2*x + 5*y = 13"); ################## # Format the answer blanks nicely with a brace on the left if ($displayMode eq 'TeX') {

$answerblanks = "$$\displaystyle \left\lbrace \begin{array}{l}". ans_rule(35)."\\". ans_rule(35)." \end{array} \right.$$ "; } else { #$displayMode eq 'HTML'

$answerblanks = ColumnTable( "$$\displaystyle \Bigg\lbrace$$" , ans_rule(35).$BR.BR. ans_rule(35) , indent => 0, separation => 10, valign => "MIDDLE" ); } ############################################################## # # Text # # Context()->texStrings; BEGIN_TEXT Express the given vector equation as a system of linear equations. $x \left\lbrack \begin {array}{c} 3 \\ 2 \end {array} \right\rbrack + y \left\lbrack \begin {array}{c} -1 \\ 5 \end {array} \right\rbrack = \left\lbrack \begin {array}{c} 8 \\ 13 \end {array} \right\rbrack$answerblanks

END_TEXT

Context()->normalStrings;

##############################################################
#
#
#

UNORDERED_ANS( $eqn1->cmp(),$eqn2->cmp() );

ENDDOCUMENT();

### Re: ImplicitEquation context with multiple equations

by Joe Wagner -
Thanks, Paul.  I was already aware of "ImplicitPlane," and that's why I mentioned that there were other ways to handle this particular problem in which the equations are linear.  My real question was whether or not this issue could be handled for other (nonlinear) equations.  I'm interpreting your answer to be, more or less, no, at least not in any simple way.

Thanks,

Joe

### Re: ImplicitEquation context with multiple equations

by Paul Pearson -
Hi Joe,

OK, so perhaps the 'evil cousin' characterization was overly dramatic...

For nonlinear equations, you will want to consult the documentation for ImplicitEquation

http://webwork.maa.org/pod/pg_TRUNK/macros/parserImplicitEquation.pl.html

The documentation describes some of the less desirable traits of the ImplicitEquation macro. In the past, I have had to spend a considerable amount of time ensuring that ImplicitEquation answer checking works well every time I use it. My memory may be not be perfect, but here are the three lessons I have learned from experience with ImplicitEquation objects:

1. You should probably specify some solution points to the ImplicitEquation. These points will probably be things that look like ($a+1)/2 for some random element$a.

2. You should probably resize the domain (i.e., the limits) to the ImplicitEquation. Make sure that all the solution points you gave it in part 1 are in the domain you specify.

3. Test the answer checker thoroughly for reliability. Submit the correct answer 10 or 20 times in a row to see if it is marked correct every time. Submit equivalent answers and check them the same way. Do the same reliability testing using different randomizations. Check that the extreme random values work well.

So, the answer is that it may take a little bit more work on your part to ensure that ImplicitEquations work well.

Best regards,

Paul Pearson