1
$\begingroup$

Mathematica is unable to find the trivial solution to a system of equations. Why? And how can you fix this? See the example below

NSolve[{0.5 a - 0.1 d - 0.5 f d - 0.05 d b - 0.05 d c == 0, 
    -0.05 f + 0.3 a + 0.1 d + 0.5 f d + 0.03 b + 0.05 d b + 
    0.2 a (0.5 f + 0.05 b + 0.05 c) + 0.01 c + 0.05 d c == 0, 
    0.0125 f - 0.13 b == 0, 
    0.0375 f - 0.11 c == 0, 
    -0.8 a + 0.1 b - 0.2 a (0.5 f + 0.05 b + 0.05 c) + 0.1 c == 0}, 
 {d, f, b, c, a}, Reals]

returns the solutions

{{d -> -0.557011, f -> -8.40212, b -> -0.807896, c -> -2.86436, 
  a -> 4.77322}, {d -> 0.034582, f -> 3.30048, b -> 0.317354, 
  c -> 1.12516, a -> 0.126042}, {d -> 1.11643, f -> -0.201318, 
  b -> -0.0193575, c -> -0.0686313, a -> -0.0112953}}

which is all well and good, but totally missed the solution a=b=c=d=f=0.

I don't understand why mathematica is not returning the trivial solution, are there some options I need to specify for it to find the trivial solution?

Solve can sort of find the trivial solution (but not any others).

Solve::ratnz: Solve was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result. >>

{{d -> 0, f -> 0., b -> 0, c -> 0, a -> 0}}
| improve this question | | | | |
$\endgroup$
  • 2
    $\begingroup$ Its a method problem try Method -> {"UseSlicingHyperplanes" -> False} $\endgroup$ – cyrille.piatecki Sep 22 '16 at 8:06
  • 1
    $\begingroup$ NSolve also warns you "NSolve::infsolns: Infinite solution set has dimension at least 1. Returning intersection of solutions with (153196 a)/195501-(41688 b)/65167-(153968 c)/195501+(185938 d)/195501+(38650 f)/65167 == 1," which pretty much explains it. It should not be unexpected since you have five equations and six unknowns. $\endgroup$ – Michael E2 Sep 22 '16 at 10:29
  • 1
    $\begingroup$ @MichaelE2 - there are only 5 unknowns, a b c d f., however I'll check through for independence. $\endgroup$ – Esme_ Sep 23 '16 at 3:34
  • $\begingroup$ Thanks @cyrille.piatecki - that found me the trivial solutions (but no others). Feeling more comfortable with using this approach since it can find what I know to be true. Now to generalise to the problem I really need to solve ... $\endgroup$ – Esme_ Sep 23 '16 at 3:35
  • $\begingroup$ @Esme_ Oops, yep, 5 unknowns. I must've inserted a e manually.. Sorry about that. $\endgroup$ – Michael E2 Sep 23 '16 at 10:18
1
$\begingroup$
eq = SetPrecision[
{0.5 a - 0.1 d - 0.5 f d - 0.05 d b - 0.05 d c == 0, 
-0.05 f + 0.3 a + 0.1 d + 0.5 f d + 0.03 b + 0.05 d b + 
          0.2 a (0.5 f + 0.05 b + 0.05 c) + 0.01 c + 0.05 d c == 0, 
0.0125 f - 0.13 b == 0, 
0.0375 f - 0.11 c == 0, 
-0.8 a + 0.1 b - 0.2 a (0.5 f + 0.05 b + 0.05 c) + 0.1 c == 0}, 
30];

sol= NSolve[eq, {d, f, b, c, a}, Reals]
{{d -> -0.0295255572154826154092346605969, 
  f -> -21.3769623310349877877253230598, 
  b -> -2.05547714721490271578201289861, 
  c -> -7.2876007946710182575252163264, 
  a -> 0.65284757118928026344705707724}, 
{d -> 0, f -> 0, b -> 0, c -> 0, a -> 0}}

eq /. sol
{{True, True, True, True, True}, {True, True, True, True, True}}

This outcome might satisfy, but with Rationalize, we get a better overview.

 eq2 = Rationalize[
    {0.5 a - 0.1 d - 0.5 f d - 0.05 d b - 0.05 d c == 0, 
    -0.05 f + 0.3 a + 0.1 d + 0.5 f d + 0.03 b + 0.05 d b + 
              0.2 a (0.5 f + 0.05 b + 0.05 c) + 0.01 c + 0.05 d c == 0, 
    0.0125 f - 0.13 b == 0, 
    0.0375 f - 0.11 c == 0, 
    -0.8 a + 0.1 b - 0.2 a (0.5 f + 0.05 b + 0.05 c) + 0.1 c == 0}, 
    0];
sol2 = Solve[eq2, {d, f, b, c, a}, Reals]

enter image description here

"a" is parameter! You have infinity solutions.

sol2/. a -> 0
{{d -> 0, f -> 0, b -> 0, c -> 0}}

sol2 /. a -> 1
{{d -> -(1735/23533), f -> -(4576/347), b -> -(440/347), c -> -(1560/347)}}

and so on!

| improve this answer | | | | |
$\endgroup$
0
$\begingroup$

Your observation is contrary to mine in Mathematica 8. Here NSolve only finds the trivial Null solution. I checked the first solution of yours and it returns false.

  {d = -0.557011, f = -8.40212, b = -0.807896, c = -2.86436, 
 a = 4.77322}
 0.5 a - 0.1 d - 0.5 f d - 0.05 d b - 0.05 d c == 0
    False

Curious...

| improve this answer | | | | |
$\endgroup$
  • $\begingroup$ Note that it's rare that plugging in a machine-precision solution into an equation of the form lhs == 0 returns True, because of rounding error. E.g. x^2 - 2 == 0 /. x -> Sqrt[2.]. $\endgroup$ – Michael E2 Sep 22 '16 at 10:56
  • $\begingroup$ Thank you @MichaelE2 I wasn't aware of this. With rewi answer it becomes even more clear and I got the same result. $\endgroup$ – crx Sep 22 '16 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.