WeBWorK Main Forum

Possible to mandate algebraic expressions be fully simplified? (not same as reduced)

Possible to mandate algebraic expressions be fully simplified? (not same as reduced)

by Christian Seberino -
Number of replies: 5
Possible to mandate that Webwork answers be fully simplified?

e.g. x will be accepted but not 5*x/5 or x*(x + 1) / (x + 1)

It is a common exercise in algebra to ask students to try to simplify
algebraic expressions.   It appears Webwork only checks for
*equivalency* rather than *simplification*.

cs
In reply to Christian Seberino

Re: Possible to mandate algebraic expressions be fully simplified? (not same as reduced)

by Robin Cruz -

Christian,

If you are dealing with polynomials, Davide Cervone wrote a specialized context to handle the issues you've mentioned: contextLimitedPolynomial.pl.

The answers must be a polynomials with simplified coefficients and all like terms combined.  You can find documentation for specialized contexts at: 

http://webwork.maa.org/wiki/Specialized_contexts

--Robin Cruz 

Here's an example:----------------------------------------------

DOCUMENT();loadMacros(
  "PGstandard.pl",
  "MathObjects.pl",
  "contextLimitedPolynomial.pl");

TEXT(beginproblem());

######################################
#  Setup

($a1,$a0) = (random(3,7,1), non_zero_random(1,5,1));   
($b1,$b0) = (non_zero_random(1,2,1),non_zero_random(1,5,1));

$poly1 = Formula("$a1 x + $a0")->reduce;
$poly2 = Formula("$b1 x + $b0")->reduce;

######################################
#  Main text

Context()->texStrings;

BEGIN_TEXT
Multiply the polynomials:  \( ( $poly1 ) ( $poly2 ) \)
$PAR
Answer:  \{ ans_rule(40) \}
END_TEXT

Context()->normalStrings;

######################################
#  Answer

Context("LimitedPolynomial-Strict");

($c2,$c1,$c0) = ($a1*$b1,$a1*$b0+$a0*$b1,$a0*$b0);
$ans = Formula("$c2*x^2 + $c1*x + $c0")->reduce;
ANS($ans->cmp);

ENDDOCUMENT();

In reply to Robin Cruz

Re: Possible to mandate algebraic expressions be fully simplified? (not same as reduced)

by Christian Seberino -
Thanks!  What about rational expressions?  (e.g. fractions of polynomials?)

I remember reading that "simplification" is a deep complex subject that 
isn't trivial to program.  Is that why there may not exist this feature
for general expressions?

cs
In reply to Christian Seberino

Re: Possible to mandate algebraic expressions be fully simplified? (not same as reduced)

by Davide Cervone -
The list Robin linked to is good, but not complete. There are two other contexts that you might try: contextPolynomialFactors.pl and contextRationalFunction.pl. The first is a context in which students are encouraged to enter polynomials in factored form, and the second is one in which they can enter quotients of polynomials. Both include options for controlling how strict the requirements are. See the POD documentation for these for details.

While the RationalFunction-Strict context may be what you want to use, it may still be possible for students to type unreduced answers. The MathObjects library is not a full-fledged computer algebra system, and the operations it performs are pretty simple-minded. As you say, true simplification is a non-trivial action, and is outside the scope of MathObjects.

Davide
In reply to Davide Cervone

Re: Possible to mandate algebraic expressions be fully simplified? (not same as reduced)

by Christian Seberino -
Davide

Here's an out of the box idea for you to file away....

(I'm not saying Webwork has to do this...it is easy to spew ideas like I'm doing.)

Ever heard of the Sage open source computer algebra system (sagemath.org)???
Sage can be utilized from programs like Webwork.
In principle, Webwork could add an optional dependency on Sage that would 
allow Webwork to leverage Sage to add a new context that would truly
require full simplification!

cs


In reply to Christian Seberino

Re: Possible to mandate algebraic expressions be fully simplified? (not same as reduced)

by Davide Cervone -
This is already a sage-webwork bridge that allows WeBWorK problems to use Sage for computation. I'm not familiar with how it works, but perhaps others can say more.

Davide