The contexts in contextLimitedPolynomial.pl allow to force students to enter a univariate polynomial as a sum of products of coefficients and monomials with the optional restriction that each exponent occurs at most once in this sum.
I could not find a similar context for multivariate polynomials. More specifically I am looking for a context that would force a student to enter a polynomial as a sum of terms (i.e. a product of a coefficient and a monomial) such that the exponents of the terms are pairwise different.
For example, given the answer polynomial is 3x^2+x*y+x I would like to accept
3x^2+x*y+x
as a correct answer, but neither
x(x+y+1)+2x^2
nor
x^2+xy+x+2x^2.
Is this currently possible using MathObjects of type Formula?
In reply to F. Heiderich
Re: contextLimitedPolynomial.pl for multivariate polynomials
by Brittni Lorton -
I also am looking for an answer to this exact question. Any ideas out there if this is possible?
*Brittni
In reply to Brittni Lorton
Re: contextLimitedPolynomial.pl for multivariate polynomials
by Alex Jordan -In the PCC macros folder of the OPL, there is contextForm.pl:
https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/macros/PCC/contextForm.pl
You could try this. After loading this macro library file, then try:
Context("Form");
Context()->variables->are(x=>'Real',y=>'Real');
$answer = Formula("3x^2+xy+x");
If that does not behave as desired, let me know the details, and I may be able to suggest one or two more lines to make it work.