# Why does FindInstance fail when Solve succeeds on these simple constraints?

Why does

FindInstance[{a, b} > 0.27 && a == 10^8 && b == 2, {a, b}]


fail even though

Solve[{a, b} > 0.27 && a == 10^8 && b == 2, {a, b}]


works fine?

How do I make it succeed in such scenarios (when I only want one of potentially many roots)?

• @Artes: My previous question is actually unrelated to this issue, hence why I asked a separate question. Yes I am sure the system interprets this correctly; the same behavior holds for FindInstance[a > 0.27 && b > 0.27 && a == 10^8 && b == 2, {a, b}]. Did you try running it? Also, what do you mean what is my problem? My problem is that FindInstance doesn't find the obvious solution, and I'm trying to figure out how to make it work. Commented Mar 22, 2016 at 9:53
• Try e.g. FindInstance[a > 27/100 && b > 27/100 && a == 10^8 && b == 2, {a, b}]. Then decide how to formulate the problem. Commented Mar 22, 2016 at 9:56
• @Artes: I can't really pick and choose what equations the user gives me when I'm using this as a subroutine... also, see my comment on the answer below. Commented Mar 22, 2016 at 10:05
• My first though {a, b} > .27 is not a valid inequality (It is never true). Somewhat puzzled why Solve works though. Commented Mar 22, 2016 at 16:05
• @george2079 from the way it is treated, I take it > is listable Commented Mar 22, 2016 at 18:51

I found a solution myself: call Reduce[] on the input of FindInstance[]:

FindInstance[Reduce[{a, b} > 0.27 && a == 10^8 && b == 2, {a, b}], {a, b}]


I'm guessing it's a bug; if someone can figure out why this is happening, I'd still like to know.

I can't find in the documentation that the input expressions need to be exact numbers, but if you look at all the examples of FindInstance, you see they all use rational numbers. So rationalize your expression and it works,

FindInstance[Rationalize[{a, b} > 0.27 && a == 10^8 && b == 2], {a, b}]
(* {{a -> 100000000, b -> 2}} *)


There is some bug going on here, you can see that for some values FindInstance returns an answer, while for others it does not,

{wk, nwk} =
Reap[Do[If[
Length@FindInstance[a == 10^8 && b == 2 && {a, b} > n, {a, b}] <
1, Sow[n, tag1], Sow[n, tag2]], {n, 0, 1, .01}]][[2]]
(* {{0., 0.03, 0.05, 0.06, 0.08, 0.09, 0.11, 0.14, 0.16, 0.17,
0.19, 0.2, 0.22, 0.25, 0.28, 0.3, 0.31, 0.33, 0.34, 0.36, 0.39,
0.41, 0.42, 0.44, 0.45, 0.47, 0.5, 0.53, 0.55, 0.56, 0.58, 0.59,
0.61, 0.64, 0.66, 0.67, 0.69, 0.7, 0.72, 0.75, 0.78, 0.8, 0.81,
0.83, 0.84, 0.86, 0.89, 0.91, 0.92, 0.94, 0.95, 0.97, 1.}, {0.01,
0.02, 0.04, 0.07, 0.1, 0.12, 0.13, 0.15, 0.18, 0.21, 0.23, 0.24,
0.26, 0.27, 0.29, 0.32, 0.35, 0.37, 0.38, 0.4, 0.43, 0.46, 0.48,
0.49, 0.51, 0.52, 0.54, 0.57, 0.6, 0.62, 0.63, 0.65, 0.68, 0.71,
0.73, 0.74, 0.76, 0.77, 0.79, 0.82, 0.85, 0.87, 0.88, 0.9, 0.93,
0.96, 0.98, 0.99}} *)


There is an error message which isn't reported,

Trace[
FindInstance[{a, b} > 0.27 && a == 10^8 && b == 2, {a, b}],
Message[___]]
(* {{Message[FindInstance::lpsnf], Message[Message::msgl,\$MessageList]}}} *)


As far as I can tell, this message simply means no solution can be found,

• I guess this works (+1) but it's more of a workaround rather than an explanation or solution. Commented Mar 22, 2016 at 10:01
• Especially, note that the documentation says, FindInstance gives results in the same form as Solve if an instance exists, and if it does not... which means it has to return a solution if and only if Solve would find a solution. Commented Mar 22, 2016 at 10:03
• @Mehrdad This seems to be a bug of some kind, but a really minor one. Is there a more complex example where this happens to you? If you can find out what the error message FindInstance::lpsnf means then you may find out what is happening here Commented Mar 22, 2016 at 10:06
• My example was actually way more complicated than this... I spent 15 minutes simplifying it, because in my experience when I don't do that then people vote me down and tell me to simplify it to a minimum bare-bones example. =P I'm also not sure where you saw the error (I didn't see it?) but it doesn't really explain what is going on either. Commented Mar 22, 2016 at 10:10

maybe this will help someone understand the problem:

FindInstance[a > 0.1 && a == 2^24 - 1, {a}]


{{a -> 1.67772*10^7}}

FindInstance[a > 0.1 && a == 2^24, {a}]


{}

Obviously the real inequality is forcing the whole analysis to be real, but something seems to be single precision under the hood.

Giving "any" precision to the real value fixes things:

FindInstance[a > .116 && a == 2^24, {a}]
`

{{a -> 1.67772160000000*10^7}}

• +1 it did not occur to me this was a single-precision-ness issue, thanks for that! Commented Mar 22, 2016 at 19:41