Richard B. Kreckel [kreckel@zino.physik.uni-mainz.de] wrote:
The trouble starts already with trivial expressions: If a>0 and b>0, then (a+b)>0. But (a-b) would have to return false, as would (b-a). This makes it already difficult for sums. Ternary logic would help a bit, here. :-)
You wouldn't need it to be accurate 100% of the time. Like some other functions in the library, is_negative should be true if "it can be determined that..." and false should mean either false or it cannot be determined. In using this for simplifications and rearrangements, it only means that a particular simplification wouldn't be applied. I wonder if "cheating" and using evalf would get you into trouble? i.e. evalf(a-b) < 0 Cheers, -- Bob Bob McElrath (rsmcelrath@students.wisc.edu) Univ. of Wisconsin at Madison, Department of Physics