I am running this command in Mathematica 8.0.4.0:
Minimize[(x1*1 - 1)^2 + (x1*0.823202 + x2*1 - 0.7551)^2 +
lambda*(Boole[x1 != 0] + Boole[x2 != 0]), {x1, x2}]
Now, with lambda=0
(negating the Boole
functions), I get:
{7.70372*10^-34, {x1 -> 1., x2 -> -0.068102}}
With lambda=1
, I get:
{2., {x1 -> 1., x2 -> -0.068102}}
It seems to be ignoring the Boole functions, because clearly x2 -> 0
is a better solution:
(x1*1 - 1)^2 + (x1*0.823202 + x2*1 - 0.7551)^2 +
lambda*(Boole[x1 != 0] + Boole[x2 != 0]) /. {x1 -> 1, x2 -> 0}
1.00464
I assume Mathematica is minimizing this function numerically; is it simply incapable of doing this with Boole
functions, given their stepwise nature?