Is there any function other than Fsolve to solve systems of nonlinear equations ????
Show older comments
I am trying to solve the following system of 3 nonlinear equations:
XYZ(1)-A*(B*XYZ(2)^P1-C*XYZ(2)^P2)^(1/2)=0
XYZ(1)*F+G-XYZ(1)*XYZ(3)*H-I*XYZ(3)=0
XYZ(1)+E-D*XYZ(2)*XYZ(3)^(-1/2)=0
Where A,B,C,D,E,F,G,H,I,P1 and P2 are variables and X,Y and Z are the 3 unknowns to find.
I have tried using the function Fsolve with an m-file but the results were not good enough.
Is there any other function to solve this system ?????
3 Comments
Friedrich
on 3 May 2012
What do you mean with the result is not good enough? Does the result found by fsolve solve the above equations?
kamal kiki
on 4 May 2012
Walter Roberson
on 6 May 2012
Do not post duplicate questions: doing so leads to duplicated efforts, and to confusion and resentment in the volunteers who answer questions, and leads to extra work for the editors who have to merge the copies of the questions together.
Answers (3)
Taniadi
on 3 May 2012
0 votes
I agree with Friedrich, to test, you can see the value of your equations using: [yout, fval ] = fsolve('function',guess). where fval is the value of your function. If it is small enough near zero, fsolve is good.
another way maybe is to write another M-file using another numerical method. I don't know if there is another function in MATLAB for solving system of nonlinear eqs other than fsolve.
2 Comments
kamal kiki
on 4 May 2012
Walter Roberson
on 6 May 2012
So add a couple of lines to the Function block to cross-check the accuracy of the result. Display the results to the command window if you need to.
Sargondjani
on 7 May 2012
0 votes
the problem certainly has not converged as y is still jumping up and down, so there is some problem...
for a start, you should supply the Jacobian, because that will help the problem to converge
second: are you sure that there is only one unique solution to the problem??
Walter Roberson
on 7 May 2012
0 votes
Maple believes there is no solution to those equations. If you could supply specific test values for each of the variables, I could try again.
6 Comments
Walter Roberson
on 7 May 2012
By the way, do you care about the complex roots?
Walter Roberson
on 7 May 2012
The most crucial part for analytic solution is to know P1 and P2 (the exponents.)
If either of P1 or P2 are non-rational, then the signs of complicated expressions become important, as analytically raising a negative number to a non-rational value is usually defined in terms of complex logs, rather than giving a real value. For example, (-8)^(0.3333333) will be complex, compared to (-8)^(1/3) can be -2 .
If P1 or P2 can be 4, then the analytic solution will exist but will be so messy as to be nearly meaningless. If P1 or P2 can be above 4 then you might not get an analytic solution.
kamal kiki
on 8 May 2012
Sargondjani
on 8 May 2012
given your values for p1 and p2, i would not be surprised if matlab has problems determining the gradient with finite differences...
you should include the analytical gradient (jacobian). this should be easy but should improve the convergence...
To do so, in options put 'Jacobian', 'on' and supply the jacobian matrix as the second output argument of your function, as in:
[F,J]=function()
Walter Roberson
on 9 May 2012
Simulation 1: you run into round-off problems that prevent you from finding an exact solution. To 10 digits, the solution is
X = 35.44161536, Y = 68798.38215, Z = 622.0811574
Simulation 2: you run into much worse round-off problems. To 10 digits the solution is
X = 49.36060688, Y = 1.359808683*10^5, Z = 1182.292856
I think about the most efficient way to handle this is to solve the last two equations for X and Y (yielding X and Y expressed entirely in terms of Z), and substituting those in to the first equation, yielding an expression in Z that must be equal to 0. You can then do a one-dimensional solver. You do need to be careful, though, as the expression goes imaginary below around 570, and again above around 5E8. The upper bound is easy to find, but the lower bound is tricky to establish; there is a first-order lower bound around 270 that is much easier to establish (values below the first-order lower-bound are certain to be imaginary; the actual lower bound depends on the fine balancing of exponentials.)
The expression to solve one-dimensionally in Z comes out as
(-A*(F-Z*H)*(B*(((I-E*H)*Z-G+E*F)*Z^(1/2)/(D*(F-Z*H)))^P1-C*(((I-E*H)*Z-G+E*F)*Z^(1/2)/(D*(F-Z*H)))^P2)^(1/2)-G+I*Z)/(F-Z*H)
Do be careful in the use of "I" as symbolic packages tend to treat "I" as the imaginary constant.
kamal kiki
on 9 May 2012
Categories
Find more on Systems of Nonlinear Equations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!