MATLAB Answers

Can MATLAB solve systems of nonlinear equations?

21 views (last 30 days)
During investigation of one problem, I find out a system of seven nonlinear algebraic equations, which analytic solution is need. Can MATLAB give me the analytic solution of that system?

Accepted Answer

Walter Roberson
Walter Roberson on 14 Jul 2011
If MATLAB can do it at all, it would have to be by way of the Symbolic Toolbox.
A lot of the time, simultaneous nonlinear equations have no known analytic solution method.
If you could give us examples, we might be able to estimate the possibility of success.
  2 Comments
Asatur Khurshudyan
Asatur Khurshudyan on 15 Jul 2011
Unfortunately, I haven`t a computer of fair bit of memory, that`s why I couldn`t solve it yet.
No there are not any restrictions, but unknowns must be real-valued and they necessarily must be unique.

Sign in to comment.

More Answers (3)

Walter Roberson
Walter Roberson on 15 Jul 2011
If you subs() in the definitions for A, B, C, D_ in to the other 7 equations, and simplify() that, and solve, you end up with 18 solutions of various complexities, with up to 4 free variables. The least complex single solution is:
[x1 = 0, x2 = x2, x3 = 0, x4 = x4, x5 = 0, x6 = (1-x2*c2-x4*c4)/c6, x7 = x7]
where x2 = x2 means that x2 is allowed to assume any value.
Here are the 18 solutions, in Maple notation. Be sure to read the comments following them:
[x1 = RootOf(_Z^2+x3^2+x5^2), x2 = (-RootOf(_Z^2+x3^2+x5^2)*c1-x3*c3-x4*c4-x5*c5-x6*c6+1)/c2, x3 = x3, x4 = x4, x5 = x5, x6 = x6, x7 = x7]
[x1 = RootOf(_Z^2+x3^2+x5^2), x2 = x2, x3 = x3, x4 = (-x5*(x5*c5+x2*c2+x3*c3-1)*RootOf(_Z^2+x3^2+x5^2)+(x3^2+x5^2)*(x5*c1-c6*x2))/RootOf(_Z^2+x3^2+x5
^2)/(c4*x5-x3*c6), x5 = x5, x6 = (x3*(x5*c5+x2*c2+x3*c3-1)*RootOf(_Z^2+x3^2+x5^2)-(x3^2+x5^2)*(x3*c1-c4*x2))/RootOf(_Z^2+x3^2+x5^2)/(c4*x5-x3*c6), x7
= x7]
[x1 = RootOf(_Z^2+c6^2+c4^2)*x3/c4, x2 = ((-x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17 can only have imaginary roots when the constants are real-valued and non-zero, and in each case at least one of the xi values has that imaginary root multiplied by a real value; other variables might have the imaginary number in a ratio combination where potentially the imaginary portions cancel out, but we do not need to work those out because at least one of the terms is provably imaginary in those cases.
Solution #9, the "least complex solution" noted above, is always real-valued provided that c6 is non-zero, and is thus a primary solution.
Solution #18 involves RootOf((-8*c6*c4*c3*c5+4*c4^2*c5^2+4*c6^2*c3^2+4*c2^2*c5^2+4*c6^2*c1^2+4*c1^2*c4^2+4*c2^2*c3^2-8*c1*c4*c2*c3-8*c2*c1*c6*c5)*_Z^2+c6^2+c4^2+(4*c4*c2*c3-4*c1*c4^2-4*c6^2*c1+4*c6*c2*c5)*_Z)
It is not immediately obvious whether this is real-valued or not. As it is a quadratic one can easily express the two roots directly. If one then factors those roots fully, it turns out that both of the roots have the term (-(-c5*c4+c6*c3)^2*(c2^2+c4^2+c6^2))^(1/2) . A small bit of examination shows that unless at least 2 of the constants involved are 0, that the expression will result in an imaginary number.
This leaves us with the primary solution being Solution #9, the one with several explicit 0s.
Is this the only solution? No.
If you examine the RootOf() expressions in solutions 1, 2, 4, 6, 8, 11, 13, 15, and 16, you will see RootOf() involving two xi values (per solution); that RootOf can escape having an imaginary root if the xi are both set to 0. In each of these cases, setting those xi to 0 reduces the solution to one similar to the easy solution. One could, if one so desired, term these to be primary solutions as well, as the fact that the RootOf() is generated instead of the xi values being deemed to be 0 is really just a weakness of the solver in finding real-only solutions.
If you examine the RootOf() expressions in solutions 3, 5, 7, 10, 12, 14, and 17, you will see RootOf() involving 2 constants (per solution); that RootOf() can escape having an imaginary root if the constants are both 0. However, in each case, the solutions are such that if those constants are 0, the solutions involve 0/0, suggesting that no real roots exist for those solutions. However, if one sets those constants to be 0 back in the original equations and re-solve, in each case 4 potential solutions will be generated. Three of those potential solutions will involve sqrt(-1), but in each of those situations, there is an associated xi value that can be set to 0 to remove the effect of the imaginary constant, leaving a solution of mostly 0's. The 4th of the potential solutions will involve a RootOf() that, similar to the above, can be made non-imaginary if two of the xi values are set to 0. None of these possibilities can rightfully be deemed primary solutions because they all involve the happenstance that two of the constants are 0.
The 18th solution, with the longer RootOf(), is a bit less tractable. I think I have shown that each possible zeroing of constants that directly removes the imaginary root results in a 0/0 in the solution, but if 0s are substituted for those constants back in the original expressions then the situation becomes akin to the above, where real roots are possible if particular xi values are 0; again these would not be primary roots in that they rely on the happenstance of some constants being 0.
So... there are 10 primary solutions, some of which might perhaps be duplicates (I haven't worked it out); all of them are relatively simple in form... once you have found them.
  13 Comments

Sign in to comment.


Asatur Khurshudyan
Asatur Khurshudyan on 14 Jul 2011
In this pdf file is mentioned system of nonlinear algebraic equations. And what about the phrase analytic solution, I meant no numerical one.
Thank you, for your attention!
  2 Comments

Sign in to comment.


Eirini Gk
Eirini Gk on 25 Mar 2016
Is there something that we can use -without MathToolbox-? for exaple is needed a function with a numerical method or something?
  1 Comment
Walter Roberson
Walter Roberson on 25 Mar 2016
If you do not have a Symbolic Toolbox or equivalent, then one might be restricted to finding one solution, such as by using fsolve() (which requires the Optimization Toolbox).

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!