3
$\begingroup$

The following system of equations has $6$ solutions $(ct=8,8,8,8,7,9)$ but Mathematica doesn't give any solution:

NSolve[{ Sqrt[EAx^2 + 0.0625 EAy^2] (EBx) + (EAx) Sqrt[
              EBx^2 + 0.0625 EBy^2] == 0, 
         0.25 Sqrt[EAx^2 + 0.0625 EAy^2] EBy + 0.25 EAy Sqrt[EBx^2 + 0.0625 EBy^2] == 0, 
         EAy - EBy == 0, 
         -1 + 4 EAx^2 + EAy^2 == 0, 
         -1 + 4 EBx^2 + EBy^2 == 0,
         -8 + ct + EAx - EBx == 0},
       {ct, EAx, EAy, EBx, EBy}, Reals, WorkingPrecision -> 13]
 NSolve::infsolns: Infinite solution set has dimension at least 1.
 Returning intersection of solutions with 
  (38650 ct)/65167-(41688 EAx)/65167-(153968 EAy)/195501+(185938 
   EBx)/195501+(153196 EBy)/195501 == 1. >>

 {}

Why ?

$\endgroup$
  • 1
    $\begingroup$ You have 6 equations for 5 variables there. $\endgroup$ – KraZug May 19 '17 at 9:53
  • $\begingroup$ Are you sure all the equations are correct? If you name the list of equations eqs, you can even Rationalize them, and check with exact Solve. But Solve[Rationalize[eqs] /. ct -> 8, {EAx, EAy, EBx, EBy}, Reals] returns {}, so there are actually no solutions for this. Since you claim that you know that solutions exist for ct == 8, can you give the values of the other variables that solve the equations? $\endgroup$ – Marius Ladegård Meyer May 19 '17 at 9:54
  • $\begingroup$ Solve[{Sqrt[EAx^2 + 1/16 EAy^2] (EBx) + (EAx) Sqrt[ EBx^2 + 1/16 EBy^2] == 0, 1/4 Sqrt[EAx^2 + 1/16 EAy^2] EBy + 1/4 EAy Sqrt[EBx^2 + 1/16 EBy^2] == 0, EAy - EBy == 0, -1 + 4 EAx^2 + EAy^2 == 0, -1 + 4 EBx^2 + EBy^2 == 0, -8 + ct + EAx - EBx == 0, ct \[Element] Reals}, {ct, EAx, EAy, EBx, EBy}] $\endgroup$ – Artes May 19 '17 at 10:03
  • $\begingroup$ @KraZug There are 6 equations but the system is not overdetermined since the equations are not independent. $\endgroup$ – Artes May 19 '17 at 12:49
  • $\begingroup$ @MariusLadegårdMeyer There are actually 6 solutions where ct is real, but another variables are not neccessarily real. See my answer. $\endgroup$ – Artes May 19 '17 at 14:09
4
$\begingroup$

Since one expects an appropriate number of solutions it is reasonable to play with Solve or Reduce rather than with NSolve, and such a conclusion is quite obvious for experienced users, but by no means there is a direct hint in documentation pages. There is a number of various issues related to distinction between symbolic and numeric capabilities of the system, I would recommend e.g. these posts to read carefully: Issue with NSolve as well as Backslide in NSolve in V11.1?. Basically one could belive there should be one to one correspondence between Solve and NSolve results, however implementation reality appears to be slightly different, the former function is much more sophisticated and has had more updates than the latter and this is why sometimes they provide inequivalent results besides issues qualified as simple bugs. Moreover, even a specific usage of Solve sometimes may seem quite unreasonable for an unexperienced users, nevertheless one can get much more with Solve than with NSolve.

To proceed further first we should evaluate Rationalize[{0.0625, 0.25 }] and substitute exact values to the original system. Now we have:

system = {Sqrt[EAx^2 + 1/16 EAy^2] EBx + EAx Sqrt[ EBx^2 + 1/16 EBy^2] == 0, 
          1/4 Sqrt[EAx^2 + 1/16 EAy^2] EBy + 1/4 EAy Sqrt[EBx^2 + 1/16 EBy^2] == 0, 
          EAy - EBy == 0, 
          -1 + 4 EAx^2 + EAy^2 == 0, 
          -1 + 4 EBx^2 + EBy^2 == 0,
          -8 + ct + EAx - EBx == 0};

Although there are $6$ equations for $5$ variables the system is not contradictory since the equations are not independent and can be reduced to a system of $5$ equations.

The warning returned by NSolve appears to be false since it seems a reminiscence from what can be observed with

Reduce[system, {ct, EAx, EAy, EBx, EBy}];
Reduce::useq: The answer found by Reduce contains unsolved equation(s)
{0==-(1/2) Sqrt[1+12 EAx^2],0==-(1/2) Sqrt[1+12 EAx^2]}. 
A likely reason for this is that the solution set depends on branch cuts of Wolfram 
Language functions. >>

One can figure out that the problem with warning is not harmful. Evaluate Reduce[0 == -(1/2) Sqrt[1 + 12 EAx^2], EAx]. In fact, we get 6 solutions if we assume ct is real and allowing different variables to be complex:

Solve[ Join[ system, {ct ∈ Reals}], {ct, EAx, EAy, EBx, EBy}]

enter image description here

When playing with the domain specification Reals we can find only completely real solutions, there will be only two of them:

Solve[ system, {ct, EAx, EAy, EBx, EBy}, Reals]
  {{ct -> 7, EAx -> 1/2, EAy -> 0, EBx -> -(1/2), EBy -> 0},
  {ct -> 9, EAx -> -(1/2), EAy -> 0, EBx -> 1/2, EBy -> 0}}

If we don't specify the domain there will be more solutions than 6,

ct /. Solve[system, {ct, EAx, EAy, EBx, EBy}] // Quiet
{ 7, 8, 8, 8, 8, 9, 
  8 - I/Sqrt[3], 8 - I/Sqrt[3], 8 + I/Sqrt[3], 8 + I/Sqrt[3]}

To summarize Reduce is to reduce equations and logic statements yielding sometimes more than one expects, for a more detailed discussion see What is the difference between Reduce and Solve?.

$\endgroup$
  • 1
    $\begingroup$ "Basically one could belive there should be one to one correspondence between Solve and NSolve results" I would only believe this in the case where the solution set over the complexes is finite. $\endgroup$ – Daniel Lichtblau May 19 '17 at 21:11
  • $\begingroup$ @DanielLichtblau "One" is assumed to mean a newcomer, not an expert. $\endgroup$ – Artes May 20 '17 at 11:48
1
$\begingroup$

The infinite set of the solutions of the system under consideration can be found by Reduce[Rationalize[{Sqrt[EAx^2 + 0.0625 EAy^2] (EBx) + (EAx) Sqrt[ EBx^2 + 0.0625 EBy^2] == 0, 0.25 Sqrt[EAx^2 + 0.0625 EAy^2] EBy + 0.25 EAy Sqrt[EBx^2 + 0.0625 EBy^2] == 0, EAy - EBy == 0, -1 + 4 EAx^2 + EAy^2 == 0, -1 + 4 EBx^2 + EBy^2 == 0, -8 + ct + EAx - EBx == 0}], {ct, EAx, EAy, EBx, EBy}, Reals]

((ct==7&&EAx==1/2&&EAy==0)||(ct==9&&EAx==-(1/2)&&EAy==0))&&EBx==-8+ct+EAx&&EBy==EAy

$\endgroup$
  • $\begingroup$ Would you explain what you mean by "infinite set of the solutions of the system". There is only a finite set of solutions, unless you refer to an (incorrect) warning of the system. $\endgroup$ – Artes May 19 '17 at 15:36
  • $\begingroup$ @Artes One cannot solve for all variables; it is a parametrized solution set. $\endgroup$ – Daniel Lichtblau May 19 '17 at 21:02
  • $\begingroup$ @DanielLichtblau The system takes it as such but it's not, evaluate e.g. Reduce[Rationalize[system], {ct, EAx, EAy, EBx, EBy}, Reals,Backsubstitution -> True] or assume only ct to be real. Curiously, the system without specifying the domain does not resolve a simple equation 0==-(1/2) Sqrt[1+12 EAx^2] which seems to be a bug. $\endgroup$ – Artes May 20 '17 at 11:45
  • $\begingroup$ @Artes (1) The ideal in question has mixed dimension and most solver methods will find the highest dimensional component (Reduce will find all of them). The "generic" solution set is the highest dimensional component. $\endgroup$ – Daniel Lichtblau May 20 '17 at 15:43
  • $\begingroup$ @Artes (2) If there is are parametrized roots then in general one or another might lead to a parasite solution for different values of the parameter. In this example it might be the case that one branch always is a parasite but this is not so easy to assess in general (and in particular it is problematic for the verifier used in Solve to remove parasite solutions). $\endgroup$ – Daniel Lichtblau May 20 '17 at 15:45

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.