Inequalities into Standard Form
- To: mathgroup at yoda.physics.unc.edu
- Subject: Inequalities into Standard Form
- From: Ronald D. Notestine <ronald at sccs.chukyo-u.ac.jp>
- Date: Wed, 22 Jun 94 22:35:58 +0900
Some time ago, I wrote asking how to put
linear inequalities into standar form:
with all variable terms on the lhs, and
the constant term on the rhs. I wrote that
I could make such a function myself, but
hoped for something built-in or ready-made.
Eventually, I asked WRI tech support, and
am glad I did. Edmund Greaves, of WRI,
immediately started in on the problem, and
has sent me a far neater, and watertight,
function than anything I would have made.
Here is the function supplied by Ed Greaves
of Wolfram Research:
(I have to hand type everything, so any
mistakes are mine.)
convertIneq[ x_[lhs_,rhs_] ] :=
Module{temp,const,result},
temp = Expand[ lhs - rhs ]; (*all terms to rhs*)
const = If[Head$ at {(J[temp] === Plus,
Select[temp, NumberQ],
0];
result = x[temp-const, -const];
(* If a negative rhs is okay, done *)
(* If need rhs non-negative... *)
If[const>0,
result = Map[ Minus, result];
result = result /. {Less -> Greater,
LessEqual->GreaterEqual,
Greater->Less,
GreaterEqual->LessEqual}];
result
]
I hope this is of help to any one with similar problems.