WeBWorK Problems

contextLimitedPolynomial.pl for multivariate polynomials

contextLimitedPolynomial.pl for multivariate polynomials

by F. Heiderich -
Number of replies: 2
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
as a correct answer, but neither

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?
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:


You could try this. After loading this macro library file, then try:

$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.