I have a quite complex list of equations and inequalities I combine to a boundary condition for my cost function. After investigation of two days I found the bug (I really name it a bug!). One of my equations gets simplified to False, which is not the desired result!
This is one inequality which drives me crazy!
eq = 0.0055356626 + 0.000029 x + 0.000034 y <= 1000.;
All coefficients are machine numbers:
MachineNumberQ /@ Select[Level[eq, {-1}], Head[#] == Real &]
(* {True, True, True, True} *)
Because my variables are real numbers and greater than zero, I have added this assumption to my list of inequalities and equations.
On my system (Win7,64bit, Mathematica 10.1.0 for Microsoft Windows (64-bit) (March 24, 2015))
Simplify[eq, Assumptions -> {x>0, y>0}]
yields False!
Simplify[eq]
just yields 1. x+1.17241 y<=3.44826*10^7
, which is ok.
I have tried different settings for ComplexityFunction
, but I still get False!
Running
TableForm@Table[Simplify[eq/.x_Real:>n*x,Assumptions->{x>0,y>0}],{n,1,20}]
gives an interesting result:
False
False
False
False
1. x+1.17241 y<=3.44826*10^7
False
False
False
1. x+1.17241 y<=3.44826*10^7
1. x+1.17241 y<=3.44826*10^7
False
False
True
False
True
False
True
1. x+1.17241 y<=3.44826*10^7
True
1. x+1.17241 y<=3.44826*10^7
I really don't understand this! What can I do? Is there something totally wrong with my equation setup?
I have restarted the Kernel twice and tested this on two computers: I get the same result.
Could anyone please verify this on other OS and version? Thanks!
UPDATE
Wolframalpha also shows False, but the evaluation seems to involve complex numbers:
UPDATE 2
Using the Assumption {x>=0, y>=0}
is working fine ?!
True
, v9.0, 10.0, 10.1 givesFalse
. $\endgroup$Refine[eq, {x>0, y>0}]
gives slightly different results, and not all correct. Another workaround seems to be to use arbitrary precision numbers:N@Simplify[SetPrecision[eq, $MachinePrecision], Assumptions -> {x > 0, y > 0}]
. (V10.1, Mac OSX) $\endgroup$