1
$\begingroup$

Simplify is a nice fast function that cleans up simple inequalities. For example:

Simplify[c (a - b) > 0, Assumptions -> c > 0]

a > b

But I need the output inequality of the form expr > 0, and ultimately I want to extract expr. So I wrote a tiny function that gets it:

getGtrZero[expr_, assump_] := Part[#, 1] - Part[#, 2] &@Simplify[expr > 0, assump]

Test:

getGtrZero[c (a - b), c > 0]

a - b

This seems to be working ok, but this crucially requires that the output uses the function Greater. Is this a robust way to get the simplified expr that is going to be greater than zero?

Assumptions about input inequality: The input inequality will always have head Greater and will be a comparison of two simple polynomials of various symbols (involving only plus, minus and times).

$\endgroup$
1
  • $\begingroup$ Simplify[c (a - b) < 0, Assumptions -> c > 0] /. {x__ > y__ -> x - y > 0, x__ < y__ -> y - x > 0}? $\endgroup$ Oct 7 '14 at 16:06
2
$\begingroup$

You can force Simplify to return inequalities with head Greater and right hand side 0 by adapting the ComplexityFunction and adding a transformation function that will convert a Less expression to a Greater expression:

Simplify[a<0, 
ComplexityFunction->(If[#[[2]]===0 && Head[#]===Greater,1,1000] LeafCount[#1]&),
TransformationFunctions->{If[Head[#]===Less, Greater[-#[[1]],-#[[2]]], #]& , Automatic}
]

(* -a > 0 *)

Simplify[c (a - b) > 0,
Assumptions -> c > 0, 
ComplexityFunction -> (If[#[[2]] === 0, 1, 1000] LeafCount[#1] &),
TransformationFunctions -> {If[Head[#] === Less, Greater[-#[[1]], -#[[2]]], #] & , Automatic}
]

(* a - b > 0 *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.