# Solving system of 7 nonlinear algebraic equations symbolically

I have a system of seven nonlinear equations that I want to find their symbolic solutions. The solution will depend on the parameter K, and I should have different solutions by varying the parameter. I want the program to give the ranges of K and the solution associated with each value. I tried to solve the system using matlab symbolic toolkit. The code I used is:

syms K x  y  z  u  v  w  p;

eq1 =  -2*x - 4*u*v + 4*y*p == 0;

eq2 =  -9*y +3*x*p == 0;

eq3 =  -4*z - 4*sqrt(2)*u*w + 4*sqrt(2)*w*p  + 4*K == 0;

eq4 =  -5*u + x*v + 3*sqrt(2)*z*w == 0;

eq5 =  -v + 3*x*u - sqrt(5)*x*w == 0;

eq6 =  -w + sqrt(5)*x*v + sqrt(2)*z*u - sqrt(2)*z*p == 0;

eq7 =  -5*p - 7*x*y - 3*sqrt(2)*z*w == 0;

[x y z u v w p] = solve(eq1, eq2, eq3, eq4,eq5, eq6, eq7)


I run the code using matlab R2015b, and after running for abut 6 hours it either give an empty solution or stops working. Any advice?

• You are trying to find an analytic solution to an equation that may not have one that can be expressed in terms of formulas. Why not solve it numerically (i.e., without syms)? – Wolfgang Bangerth Dec 29 '15 at 17:16
• Although you are using Matlab code in your Question, note that SciComp.SE also supports mathematical expressions by MathJax and $\LaTeX$ syntax. – hardmath Dec 29 '15 at 17:17
• Maple finds a symbolic solution, but in terms of roots of high degree (10th degree) polynomials. – Brian Borchers Dec 30 '15 at 0:32
• @choward That -- depending on the conditioning of the nonlinear system -- a small residual (say 1e-12) doesn't necessarily correspond to a small error (distance of approximation to a true root, which could even be O(1) if the system is ill-conditioned enough). – Christian Clason Jan 1 '16 at 11:05
• In these cases, the usual choice is comparing the numerical solution with a numerical one computed with a higher precision. An "analytical solution" does not necessarily give the correct answer: every formula needs to be evaluated numerically. Even for a second-degree equations, computing the "analytical solution" with the textbook formula $\frac{b\pm \sqrt{b^2-4ac}}{2a}$ can be significantly less accurate than a numerical solution computed with Newton's method. Take a case in which $b \gg 4ac$, for instance. – Federico Poloni Jan 1 '16 at 17:37

If you just want to plot the solution(s) as a function of the parameter, that can usually be done within the package (not sure about Magma, though). If you want to use the results in further (numerical) computation, you can use Maple's CodeGeneration module to generate a Matlab function that evaluates the solution for a given parameter. You could also implement everything within the general purpose Sage framework, which bundles (among many others) Singular together with NumPy, SciPy and Matplotlib (which together provide similar features to Matlab).