29 views (last 30 days)

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 ?????

Taniadi
on 3 May 2012

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.

Walter Roberson
on 6 May 2012

Sargondjani
on 7 May 2012

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

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.

Opportunities for recent engineering grads.

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

Start Hunting!
## 3 Comments

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/37287-is-there-any-function-other-than-fsolve-to-solve-systems-of-nonlinear-equations#comment_77187

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/37287-is-there-any-function-other-than-fsolve-to-solve-systems-of-nonlinear-equations#comment_77187

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/37287-is-there-any-function-other-than-fsolve-to-solve-systems-of-nonlinear-equations#comment_77439

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/37287-is-there-any-function-other-than-fsolve-to-solve-systems-of-nonlinear-equations#comment_77439

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/37287-is-there-any-function-other-than-fsolve-to-solve-systems-of-nonlinear-equations#comment_77825

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/37287-is-there-any-function-other-than-fsolve-to-solve-systems-of-nonlinear-equations#comment_77825

Sign in to comment.