WeBWorK Problems

how to Compute |x| > 6 in webwork answer

Re: how to Compute |x| > 6 in webwork answer

by D. Brian Walton -
Number of replies: 0
I do not know how to include an inequality as an embedded piece of a formula.  It is important to recognize that WeBWorK does not think of things symbolically.  Your example of "|x|+a" is a valid formula and is actually not really using the Inequalities context (though I'm not really sure how the context rules work in detail here).

The Inequalities context is not designed for the problem you are trying to write.  It is designed to describe basic intervals, and not generic inequalities.  For example, suppose I want the student to describe the interval [1,5].  They might answer the interval directly as "[1,5]".  But they might also want to represent it in inequality form as "x >= 1 and x <= 5".  The Inequalities context allows this to happen, as well as allowing the author to describe intervals through basic inequalities.  It does not deal with solving inequalities.

When I write problems where I want the student to give me the absolute value inequality, I use a three-part answer.  I have done a similar problem where I have an answer blank followed by a pop-up menu followed by another answer blank with instructions that the first answer blank needs to be an absolute value of something.

The solution checker verifies that the actual formulas in the blanks agree with what I am expecting and that the correct inequality was selected in the popup menu.

Here is an example problem I used, modified to be cleaner here so it doesn't have any random aspect.

DOCUMENT();        # First line

loadMacros(
  "PGstandard.pl",
  "MathObjects.pl",
  "parserPopUp.pl",
);

TEXT(beginproblem);

$c = Real(3);
$delta = Real(2);

$a = $c-$delta;
$b = $c+$delta;

$popup = PopUp(["?", ">", ">=", "<", "<="], "<=");

BEGIN_TEXT
Rewrite the statement \(x \in [$a,$b]\) as a distance inequality of the form
\(|x-c| >_{\ge} \delta\) or \(|x-c| <_{\le} \delta\).

$PAR
\(|x - \)\{ ans_rule(5) \}\(|\) \{ $popup->menu() \} \{ ans_rule(5) \}
END_TEXT


###################################
# Answer checking

ANS( $c->cmp, $popup->cmp, $delta->cmp );

ENDDOCUMENT();        # Last line.