## WeBWorK Problems

### how to Compute |x| > 6 in webwork answer ### how to Compute |x| > 6 in webwork answer

by Anushree Sharma -
Number of replies: 3

Dear all,

I am new in webwork

could any one help me to the below problem

Context("Inequalities");

$f = Compute("|x| +$a");   is working

$f = Compute("|x| >$a");   is Not working

Please let me know how can it work

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

by Robin Cruz -

Hi, Praveen,

Your answer needs to be either: Compute("x<$a or x>$a"); or

Compute("(-inf,$a) U ($a,inf)");

In the first case, I believe WeBWorK recognized your expression as a Formula, but the Inequalites context is an alternative way of entering intervals.

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

by Anushree Sharma -

Hi, Robin,

Thanks for quick response

But i want to enter in answer box by student as below

|x|<=6

For this i used code like this

Context("Inequalities");

$f = Compute("|x| >=$a");

It gives error as

'>=' should have a variable on one side and a number on the other; see position 5 of formula

AND it is OK with

Context("Inequalities");

$f = Compute("|x| +$a");

So please give me a solution for the same

With Regards,

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

by D. Brian Walton -
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

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