I noticed that NSolve
isn't running properly when I have some seemingly harmless numbers in my expression. Here is a simple example:
NSolve[1/x == 10^15, x]
(* {} *)
Interestingly, if I run this over a list of different powers many of them are failing (but not all):
Cases[#, {x_, {}}] &@ Table[{i, NSolve[1/x == 10^i, x]}, {i, Range[1, 50]}]
(* {{15, {}}, {18, {}}, {21, {}}, {23, {}}, {24, {}}, {25, {}},
{26, {}}, {29, {}}, {30, {}}, {32, {}}, {34, {}}, {39, {}},
{42, {}}, {43, {}}, {45, {}}, {49, {}}} *)
Why is this happening and is there is a generic workaround?
Note: I'm using Mathematica on Linux x86 10.0.2.0
WorkingPrecision
to anything other than the default value, it works. $\endgroup$ – J. M.'s ennui♦ Apr 25 '16 at 17:57(10.0)^i
instead:{{15, {}}, {18, {}}, {21, {}}, {24, {}}, {30, {}}, {34, {}}, {37, {}}, {43, {}}, {46, {}}}
I wonder if the answer is related to the binary (floating-point) representation of 1/10 or something like that. $\endgroup$ – Michael Seifert Apr 25 '16 at 20:20Cases[Table[{v, NSolve[1/x == v, x]}, {v, RandomReal[10, 1000] 10^13}], {x_, {}}]
$\endgroup$ – george2079 Apr 25 '16 at 20:25Solve
, which works fine. $\endgroup$ – David G. Stork Apr 25 '16 at 20:48