# Solving a system of nonlinear equations

The bellow set of equations has two answer sets for (α1, α2, α3, β1, β2, β3) respectively as following:

(3, 1, 3, 1, 1, 1)  &  (3, 0.75, 3, 0.5, -1, 0.5)


However, I want to solve it with Mathematica. It would be very kind of you if have a look on the following code and let me know why it doesn't work properly.

M = {{α1, β3, β2}, {β3, α2, β1}, {β2, β1, α3}}
L = Eigenvalues[M]
V = 4/3*Pi/Root[L[]*L[]*L[], 2]
NSolve[{
β1 - (β2 β3 )/α1 == 2/3,
α2 - (β3 β3)/α1 == 2/3,
α3 - (β2 β2)/α1 == 8/3,
α1 - (β2 β2)/α3 == 8/3,
α2 - (β1 β1)/α3 == 2/3,
β3 - (β1 β2)/α3 == 2/3,
V == 2.094}, {α1, α2, α3, β1, β2, β3}]

• Where you have Root[...,2] you probably want Sqrt. – Daniel Lichtblau Sep 28 '14 at 21:36
• What are you trying to do in the line where you define V? Root[L[]*L[]*L[], 2] does not mean much to me. If you are trying to multiply the roots together or take a square root so that you have V = 4/3*Pi/Sqrt[(L[] L[] L[])] then you get an answer. – Hugh Sep 28 '14 at 21:46
• @DanielLichtblau Thank you for your helpful answer. From the Help documents, I couldn't clearly understand what is the role of x here that you've mentioned /.x -> 0 Would you please describe it? Thanks again. – Nick Sep 28 '14 at 23:44
• (1) I created the characteristic polynomial using x as the variable. To get the constant term I simply substitute 0 for x. In Mathematica that is done as whatever /. x->0. There are of course other ways to get that constant term. (2) It is generally good practice to comment on a response under that response rather than under the original note. As it was, I nearly missed this question. – Daniel Lichtblau Sep 29 '14 at 15:04
• @DanielLichtblau Thanks again for your previous reply. I have asked another question related to this topic here mathematica.stackexchange.com/questions/63447/… Would you please have a look on it and let me know your opinion? Thanks again – Nick Oct 18 '14 at 2:05

In addition to what I wrote in the comment, you can get a result much faster if you avoid using the explicit eigenvalues. Their product is the constant term of the characteristic polynomial so use that instead and rearrange the last equation as needed.

M = {{α1, β3, β2}, {β3, α2, β1}, {β2, β1, α3}};

Timing[
sol2 = NSolve[{
β1 - (β2 β3 )/α1 == 2/3,
α2 - (β3 β3)/α1 == 2/3,
α3 - (β2 β2)/α1 == 8/3,
α1 - (β2 β2)/α3 == 8/3,
α2 - (β1 β1)/α3 == 2/3,
β3 - (β1 β2)/α3 == 2/3,
(4/3*Pi)^2 == 2.094^2*(CharacteristicPolynomial[M, x] /. x -> 0)},
{α1, α2, α3, β1, β2, β3}]]

(* {0.028000,
{{α1 -> 3.00113220535, α2 -> 1.00037725962,
α3 -> 3.00113220535, β1 -> 1.00075451924,
β2 -> 1.00188587161, β3 -> 1.00075451924},
{α1 -> 3.00113220535, α2 -> 0.749905791718,
α3 -> 3.00113220535, β1 -> 0.499811583436,
β2 -> -1.00188587161, β3 -> 0.499811583436}}
} *)

• Thanks again for your previous answer. If I omit the last equation from the above system (4/3*Pi)^2 == 2.094^2*(CharacteristicPolynomial[M, x] /. x -> 0) ans solve it again, Mathematica gives me only two imaginary answers, while the real answers you have written above, are still the answers of this equation set. Would you please clarify for me that why Mathematica doesn't give me all the existing correct answers? (that I am anticipating) – Nick Oct 8 '14 at 17:01
• I think NSolve gets confused because it has a 1-dimensional component of solutions, but not from a complete intersection. So numeric error perhaps is making it appear to be zero dimensional, and the individual solutions are not near the solutions to the full system. Upshot: You cannot remove that last equation. – Daniel Lichtblau Oct 8 '14 at 18:22
• Thanks again. Just for my information, please let me know whether Nsolve gives "all" the existing answers of a system of equations? I mean if it gives me 2 answers for a case, can I say that these two are the only possible answers for thet system? (because I have already solved such a system with "solve" in Matlab, but sometimes it gives me only some of the answers) – Nick Oct 8 '14 at 18:32
• NSolve gives all solutions for polynomial systems where the number is finite and the system is not in any sense ill conditioned. Systems that require more equations than variables are of necessity ill conditioned (a small perturbation makes the system inconsistent). In the example of this thread, NSolve is finding everything (can test it against SOlve, for example). – Daniel Lichtblau Oct 8 '14 at 18:36
• It's not in general straightforward with nonlinear systems. But yours has to be because it requires more equations than unknowns. A consequence of having a system that is consistent but overdetermined is that a perturbation makes it inconsistent. Hence it has to be ill conditioned. – Daniel Lichtblau Oct 8 '14 at 19:02