How to solve a system of nonlinear equations with three unknowns & three equations?
Show older comments
I tried to solve the system of nonlinear equations with fsolve function but the answers for unknowns are not true,I think there is a problem with number of iterations or the reasonable error.
How can I set these parameters?
Here are the equations:
311*cos(0.5236-x(3))+x(1)*cos(x(2)+x(3))-311=0
311*sin(.5236-x(3))-(x(1)*sin(x(2)+x(3)))=0
(x(1)^2)*(tan(.5236)*cos(x(2))*cos(x(2)-.7526)-(1/tan(.5236))*(sin(x(2))*sin(x(2)-.7526)))-7036.18=0
x(1) is a positive and x(2) and x(3) are angles then it is reasonable to be between 0 and 2pi
5 Comments
Azzi Abdelmalek
on 3 Nov 2013
Show your equations
Farid
on 3 Nov 2013
sixwwwwww
on 3 Nov 2013
What are the conditions for your equations? are these equations equal to each other?
Walter Roberson
on 3 Nov 2013
Probably that all of them should equal 0.
Farid
on 4 Nov 2013
Answers (2)
Seems a matter of making a lucky initial guess. Here's one solution
x =
146.6872 3.9507 0.9997
Here's another
x =
592.2262 2.9287 9.3271
And another
x =
592.2262 2.9287 3.0439
7 Comments
Farid
on 4 Nov 2013
Matt J
on 4 Nov 2013
All I did was experiment with different initial points
x0=[311,2,2];
x0=[650 3 5];
Farid
on 4 Nov 2013
Matt J
on 4 Nov 2013
Both with fsolve and lsqnonlin. Note that lsqnonlin allows you to apply bounds which is good for x(2) and x(3). The function is 2*pi periodic in x(2) and x(3), so bounds allows the solver to ignore periodic repetitions.
Farid
on 5 Nov 2013
Matt J
on 5 Nov 2013
That, I do not know.
Farid
on 5 Nov 2013
Walter Roberson
on 6 Nov 2013
Edited: Walter Roberson
on 6 Nov 2013
x = [146.6871682461996007408428, 3.950714907905676528151964, 0.9997481449580266590840019]
To the accuracy used, this is the only solution with x(1) positive and the other two in [0, 2*Pi]
The x(1) in the 592 range (given by Matt J) appear to be false solutions.
Method of solution:
The third equation can be solved for x1 to give x1 in terms of x2.
The second equation can be solved for x3 to give x3 in terms of x2.
Substituting the x1 and x3 terms into the first equation gives an equation in terms of x2 only. This equation goes imaginary for some values of x2 in [0, 2*Pi] . By examining the plot, you can see that there is a single 0 crossing, somewhere near x2 = 5*Pi/4. You can use fzero() or equivalent to find the x2 for which the equation becomes 0.
Then, with the numeric x2 in hand, you can substitute into the two previous forms to get x1 and x3. Although there is an arctan() involved, there is only one solution that works.
4 Comments
The second equation can be solved for x3 to give x3 in terms of x2.
Can't immediately see how you did this. The second equation involves all 3 variables, right? When substituting x1 as a function of x2 into the 2nd equation, you end up with something pretty hideous. You say it can be solved for x3 regardless?
In any case, here's the solution with x1 near 592 to more precision. You can substitute into the equations directly to verify that it is a solution.
x =
592.226174086239
2.92865236277986
3.04387323520966
Walter Roberson
on 6 Nov 2013
Ummm... now I'm scratching my head about how I got those results. Maybe when I wake up in the morning.
Farid
on 7 Nov 2013
Walter Roberson
on 8 Nov 2013
Your equations involve the values 0.5236 and 0.7526 . Is there a formula that relates those two values? If I replace 0.5236 with the symbol alpha, then can 0.7526 be expressed in terms of alpha, or is it an independent variable?
Categories
Find more on Systems of Nonlinear Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!