3
$\begingroup$

I'm trying to run this relatively simple code. I have five polynomial equations (I read that NSolve should work fine with these) and five variables. I need to find all real solutions to these equations

vars1cut = {A, δ, c1, c2, c3};
eqs1cut = {
   16 A^3 - 48 A^2 c1 + 2 (-8 c3 - 4 c1 g + 16 c1^3 h - 16 c1 c2 h) + 
     4 A (2 g - 8 c1^2 h + c2 (12 + 8 h)) + 24 A δ - 
     24 c1 δ == 0,
   12 A^2 δ - 24 A c1 δ + (2 g - 8 c1^2 h + c2 (12 + 8 h)) δ + 
     3 δ^2 == 2,
   c1 == 1/16 (96 A^3 δ - 192 A^2 c1 δ + 
       8 A (2 g - 8 c1^2 h + c2 (12 + 8 h)) δ + 
       48 A δ^2 - 24 c1 δ^2),
   c2 == 1/8 (48 A^4 δ - 96 A^3 c1 δ + 
       4 A^2 (2 g - 8 c1^2 h + c2 (12 + 8 h)) δ + 
       48 A^2 δ^2 - 
       48 A c1 δ^2 + (2 g - 8 c1^2 h + c2 (12 + 8 h)) δ^2 + 4 δ^3),
   c3 == 1/32 (192 A^5 δ - 384 A^4 c1 δ + 
       16 A^3 (2 g - 8 c1^2 h + c2 (12 + 8 h)) δ + 
       336 A^3 δ^2 - 432 A^2 c1 δ^2 + 
       12 A (2 g - 8 c1^2 h + c2 (12 + 8 h)) δ^2 + 
       72 A δ^3 - 24 c1 δ^3)
   };

equations = eqs1cut /. {g -> 10, h -> 10};
NSolve[equations, vars1cut, Reals]
FindRoot[equations, {{A, 1}, {δ, 0.1}, {c1, 1}, {c2, 0}, {c3, 1}}]

However when I run this code, NSolve returns

{}

but there have to be some solutions since FindRoot found at least one

{A -> 0.999999, δ -> 0.0895403, c1 -> 0.999999, c2 -> 1.02247, c3 -> 1.06742}

So what might be the problem? What should I fix so that NSolve returns all real solutions?

$\endgroup$
1
  • $\begingroup$ Doesn't Solve[equations, vars1cut, Reals] do what you want here? There are two solution branches, and each one has c1 as a free variable so there are infinite solutions. $\endgroup$ Commented 2 days ago

3 Answers 3

4
$\begingroup$

Don't use machine precision

(sol = NSolve[equations, vars1cut, Reals, WorkingPrecision -> 15])//N

(* NSolve::infsolns: Infinite solution set has dimension at least 1. Returning intersection of solutions with (104356 A)/150069+(61196 c1)/50023-(136940 c2)/150069-(121297 c3)/150069-(54409 \[Delta])/50023 == 1.

(* {{A -> -2.35668, \[Delta] -> 0.0895403, c1 -> -2.35668, c2 -> 5.5764, 
  c3 -> -13.2477}, {A -> -2.40157, \[Delta] -> -0.715077, 
  c1 -> -2.40157, c2 -> 5.54307, 
  c3 -> -12.2339}, {A -> 0.0070787, \[Delta] -> -0.715077, 
  c1 -> 0.0070787, c2 -> -0.224425, 
  c3 -> -0.00476661}, {A -> 1.26553, \[Delta] -> -0.715077, 
  c1 -> 1.26553, c2 -> 1.37709, c3 -> 1.17459}} *)

Verifying the solutions,

equations /. sol

(* {{True, True, True, True, True}, {True, True, True, True, True}, {True, True, 
  True, True, True}, {True, True, True, True, True}} *)

Solve will give the general solution in terms of c1 (i.e., c1 can take arbitrary real values).

sol2 = Solve[equations, vars1cut, Reals]

(* Solve::svars: Equations may not give solutions for all "solve" variables.

{{A -> c1, \[Delta] -> -(2/
      3) (5 - 23 c1^2 + 
       23 Root[-27 - 860 c1^2 + 13712 c1^4 - 63480 c1^6 + 
           97336 c1^8 + (860 - 27424 c1^2 + 190440 c1^4 - 
              389344 c1^6) #1 + (13712 - 190440 c1^2 + 
              584016 c1^4) #1^2 + (63480 - 389344 c1^2) #1^3 + 97336 #1^4 &, 
         1]) - 1/3 Sqrt[
     2] \[Sqrt](53 - 460 c1^2 + 1058 c1^4 + 
        460 Root[-27 - 860 c1^2 + 13712 c1^4 - 63480 c1^6 + 
            97336 c1^8 + (860 - 27424 c1^2 + 190440 c1^4 - 
               389344 c1^6) #1 + (13712 - 190440 c1^2 + 
               584016 c1^4) #1^2 + (63480 - 389344 c1^2) #1^3 + 97336 #1^4 &, 
          1] - 2116 c1^2 Root[-27 - 860 c1^2 + 13712 c1^4 - 63480 c1^6 + 
            97336 c1^8 + (860 - 27424 c1^2 + 190440 c1^4 - 
               389344 c1^6) #1 + (13712 - 190440 c1^2 + 
               584016 c1^4) #1^2 + (63480 - 389344 c1^2) #1^3 + 97336 #1^4 &, 
          1] + 1058 Root[-27 - 860 c1^2 + 13712 c1^4 - 63480 c1^6 + 
            97336 c1^8 + (860 - 27424 c1^2 + 190440 c1^4 - 
               389344 c1^6) #1 + (13712 - 190440 c1^2 + 
               584016 c1^4) #1^2 + (63480 - 389344 c1^2) #1^3 + 97336 #1^4 &, 
          1]^2), c2 -> 
   Root[-27 - 860 c1^2 + 13712 c1^4 - 63480 c1^6 + 
      97336 c1^8 + (860 - 27424 c1^2 + 190440 c1^4 - 
         389344 c1^6) #1 + (13712 - 190440 c1^2 + 
         584016 c1^4) #1^2 + (63480 - 389344 c1^2) #1^3 + 97336 #1^4 &, 1], 
  c3 -> 1/2 (-4 c1^3 + 
      6 c1 Root[-27 - 860 c1^2 + 13712 c1^4 - 63480 c1^6 + 
          97336 c1^8 + (860 - 27424 c1^2 + 190440 c1^4 - 
             389344 c1^6) #1 + (13712 - 190440 c1^2 + 
             584016 c1^4) #1^2 + (63480 - 389344 c1^2) #1^3 + 97336 #1^4 &, 
        1])}, {A -> 
   c1, \[Delta] -> -(2/
      3) (5 - 23 c1^2 + 
       23 Root[-27 - 860 c1^2 + 13712 c1^4 - 63480 c1^6 + 
           97336 c1^8 + (860 - 27424 c1^2 + 190440 c1^4 - 
              389344 c1^6) #1 + (13712 - 190440 c1^2 + 
              584016 c1^4) #1^2 + (63480 - 389344 c1^2) #1^3 + 97336 #1^4 &, 
         2]) + 1/3 Sqrt[
     2] \[Sqrt](53 - 460 c1^2 + 1058 c1^4 + 
        460 Root[-27 - 860 c1^2 + 13712 c1^4 - 63480 c1^6 + 
            97336 c1^8 + (860 - 27424 c1^2 + 190440 c1^4 - 
               389344 c1^6) #1 + (13712 - 190440 c1^2 + 
               584016 c1^4) #1^2 + (63480 - 389344 c1^2) #1^3 + 97336 #1^4 &, 
          2] - 2116 c1^2 Root[-27 - 860 c1^2 + 13712 c1^4 - 63480 c1^6 + 
            97336 c1^8 + (860 - 27424 c1^2 + 190440 c1^4 - 
               389344 c1^6) #1 + (13712 - 190440 c1^2 + 
               584016 c1^4) #1^2 + (63480 - 389344 c1^2) #1^3 + 97336 #1^4 &, 
          2] + 1058 Root[-27 - 860 c1^2 + 13712 c1^4 - 63480 c1^6 + 
            97336 c1^8 + (860 - 27424 c1^2 + 190440 c1^4 - 
               389344 c1^6) #1 + (13712 - 190440 c1^2 + 
               584016 c1^4) #1^2 + (63480 - 389344 c1^2) #1^3 + 97336 #1^4 &, 
          2]^2), c2 -> 
   Root[-27 - 860 c1^2 + 13712 c1^4 - 63480 c1^6 + 
      97336 c1^8 + (860 - 27424 c1^2 + 190440 c1^4 - 
         389344 c1^6) #1 + (13712 - 190440 c1^2 + 
         584016 c1^4) #1^2 + (63480 - 389344 c1^2) #1^3 + 97336 #1^4 &, 2], 
  c3 -> 1/2 (-4 c1^3 + 
      6 c1 Root[-27 - 860 c1^2 + 13712 c1^4 - 63480 c1^6 + 
          97336 c1^8 + (860 - 27424 c1^2 + 190440 c1^4 - 
             389344 c1^6) #1 + (13712 - 190440 c1^2 + 
             584016 c1^4) #1^2 + (63480 - 389344 c1^2) #1^3 + 97336 #1^4 &, 2])}} *)

For c1 == 1.

sol2 /. c1 -> 1.

(* {{A -> 1., \[Delta] -> -0.715077, c2 -> 0.775525, 
  c3 -> 0.326576}, {A -> 1., \[Delta] -> 0.0895403, c2 -> 1.02247, 
  c3 -> 1.06742}} *)
$\endgroup$
3
$\begingroup$
  • Use some Method.
NSolve[equations, vars1cut, Reals, Method -> "EndomorphismMatrix"]

enter image description here

$\endgroup$
3
$\begingroup$

Use MaxRoots to make it easier on NSolve, here is an example

sol = NSolve[equations, vars1cut, Reals, MaxRoots -> 3]

enter image description here

V 14.3 on windows 10

Update for comment

It seems by trial and error, 4 is max solutions it can find is 4 using this method.

 sol = NSolve[equations, vars1cut, Reals, MaxRoots -> 6]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thank you so much for your answer. However i still need all solutions. And this method, even though it returned some solutions, as you can see, the solution that FindRoot found is not between them. Do you know why this might be? $\endgroup$ Commented 2 days ago
  • $\begingroup$ @CaptainParsifal I just used 3 as example. It seems max it can find is 4. will update answer. I do not know why it can't find the one you found using FindRoot. It seems just limitation of NSolve. Or look at other solution given. $\endgroup$ Commented yesterday

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.