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

Thank in ADV.

Praveen

This forum has a limit to the number of forum postings you can make in a given time period - this is currently set at 10 posting(s) in 1 day

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

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

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.