System of 4 Non Linear equations

1 view (last 30 days)
So, I have this system of Non Linear equations which I have already wasted 10 hrs trying to solve using Fsolve, equations are
X + L2 cos(t2) - 5cos (t1) = 0
L2 sin(t2) - 5sin(t1) = 0
X + 8 cos(t1) =0
8sin(t1) -h =0
(L2 is an input)
I tried it many ways, some came up with "solver stopped" error others came up with (No solution)
  2 Comments
Walter Roberson
Walter Roberson on 31 Dec 2020
Did you try complex initial values?
Bassem Essam
Bassem Essam on 31 Dec 2020
the 4 equations are a result of 2 other complex equation separated into imagnary and real, I already know the results I need (its a project) and it can't include imaginary numbers.
thetas are to be measured from (+ve) X- axis , X is suposed to be legnth varies from 4.667, 7.98, h vary fromm 0.5 to 6.5 due to change in input of L2 from 3.01 to 4.42
thanks for your time

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 31 Dec 2020
Edited: John D'Errico on 31 Dec 2020
It looks like there are multiple unknowns. I see X, L2, t2, t1, h.
And you tell us that L2 is a known value. So 4 unknowns, and 4 equations. Wow! For once, someone has a problem that is solvable, at least in theory.
You say you have already wasted 10 hours, but there is no reason to know a solution exists. Just because you can write down some equations does not make them solvable.
First, let me write them in a form that is closer to MATLAB. Learn to use MATLAB syntax for these things, as it will make it easier to then write MATLAB code.
  1. X + L2*cos(t2) - 5*cos (t1) = 0
  2. L2*sin(t2) - 5*sin(t1) = 0
  3. X + 8*cos(t1) = 0
  4. 8*sin(t1) - h = 0
I see next that we can reduce the problem, eliminating X from the problem completely. Subtract (3) from (1). We can always recover X at the end anyway.
As well, h appears noplace but in the final equation. So if we know all t1 and t2, then both h and X can be found from these TWO, simpler equations.
  1. L2*cos(t2) - 13*cos (t1) = 0
  2. L2*sin(t2) - 5*sin(t1) = 0
Again, once we know t1 and t2, then we have
X = -8*cos(t1)
h = 8*sin(t1)
So let me now look at the simpler problem. Does a solution exist for the 2 variable problem in general?
syms L2 t1 t2
solve(L2*cos(t2) - 13*cos(t1) == 0,L2*sin(t2) - 5*sin(t1) == 0,t1,t2)
tsol = solve(L2*cos(t2) - 13*cos(t1) == 0,L2*sin(t2) - 5*sin(t1) == 0,t1,t2)
tsol =
struct with fields:
t1: [4×1 sym]
t2: [4×1 sym]
So it appears even if we do not fix a value for L2, an analytical solution exists, as a function of L2.
tsol.t1
ans =
-2*atan((5*(L2 - 13)*((25*L2*((389376*(L2 - 5)*(L2 + 5))/625)^(1/2) - 626*L2^2 + 8450)/(50*(L2^2 - 169)))^(3/2))/(26*L2) + ((651*L2^2 + 650*L2 - 4225)*((25*L2*((389376*(L2 - 5)*(L2 + 5))/625)^(1/2) - 626*L2^2 + 8450)/(50*(L2^2 - 169)))^(1/2))/(130*L2*(L2 + 13)))
2*atan((5*(L2 - 13)*((25*L2*((389376*(L2 - 5)*(L2 + 5))/625)^(1/2) - 626*L2^2 + 8450)/(50*(L2^2 - 169)))^(3/2))/(26*L2) + ((651*L2^2 + 650*L2 - 4225)*((25*L2*((389376*(L2 - 5)*(L2 + 5))/625)^(1/2) - 626*L2^2 + 8450)/(50*(L2^2 - 169)))^(1/2))/(130*L2*(L2 + 13)))
-2*atan((5*(L2 - 13)*(-(626*L2^2 + 25*L2*((389376*(L2 - 5)*(L2 + 5))/625)^(1/2) - 8450)/(50*(L2^2 - 169)))^(3/2))/(26*L2) + ((651*L2^2 + 650*L2 - 4225)*(-(626*L2^2 + 25*L2*((389376*(L2 - 5)*(L2 + 5))/625)^(1/2) - 8450)/(50*(L2^2 - 169)))^(1/2))/(130*L2*(L2 + 13)))
2*atan((5*(L2 - 13)*(-(626*L2^2 + 25*L2*((389376*(L2 - 5)*(L2 + 5))/625)^(1/2) - 8450)/(50*(L2^2 - 169)))^(3/2))/(26*L2) + ((651*L2^2 + 650*L2 - 4225)*(-(626*L2^2 + 25*L2*((389376*(L2 - 5)*(L2 + 5))/625)^(1/2) - 8450)/(50*(L2^2 - 169)))^(1/2))/(130*L2*(L2 + 13)))
tsol.t2
ans =
-2*atan(((25*L2*((389376*(L2 - 5)*(L2 + 5))/625)^(1/2) - 626*L2^2 + 8450)/(50*(L2^2 - 169)))^(1/2))
2*atan(((25*L2*((389376*(L2 - 5)*(L2 + 5))/625)^(1/2) - 626*L2^2 + 8450)/(50*(L2^2 - 169)))^(1/2))
-2*atan((-(626*L2^2 + 25*L2*((389376*(L2 - 5)*(L2 + 5))/625)^(1/2) - 8450)/(50*(L2^2 - 169)))^(1/2))
2*atan((-(626*L2^2 + 25*L2*((389376*(L2 - 5)*(L2 + 5))/625)^(1/2) - 8450)/(50*(L2^2 - 169)))^(1/2))
I fail to see the problem. In fact, there will probably be infinitely many such solutions, because we can trivially add any integer multiple of 2*pi to either/both of t1 and t2 to gain another solution. Why you failed to get a solution I have no idea. But a little mathematical common sense often goes a long way on these problems.
It may well be that for SOME values of L2, no real values of t1 and t2 will come out of those expressions. But that is not something I can explore, since we have not been told the value of L2.
For example, if I try the ttoally arbitrary value of L2==3 in there, I see:
vpa(subs(tsol,L2,3).t1)
ans =
- 1.5707963267948966192313216916398 + 0.32745015023725844332253525998826i
1.5707963267948966192313216916398 - 0.32745015023725844332253525998826i
- 1.5707963267948966192313216916398 - 0.32745015023725844332253525998826i
1.5707963267948966192313216916398 + 0.32745015023725844332253525998826i
vpa(subs(tsol,L2,3).t2)
ans =
- 1.5707963267948966192313216916398 + 1.1635461587575499368386284435842i
1.5707963267948966192313216916398 - 1.1635461587575499368386284435842i
- 1.5707963267948966192313216916398 - 1.1635461587575499368386284435842i
1.5707963267948966192313216916398 + 1.1635461587575499368386284435842i
So no real solution exists. In fact, all values I tried for L2 yield complex solutions ONLY. And that MAY suggest why it is that you were unable to find a solution using fsolve. What a surprise! I did say in the very beginning that there is no reason to believe a solution always exists for every problem you will write down on paper.
That it came out of some project you are doing only means that either you made a mistake, or well, you made a mistake. There may be a third option. but I'm leaning towards options 1 or 2 unless you have a value for L2 which does not produce only complex results. The lack of a solution from fsolve tends to imply I may be correct though.

More Answers (0)

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!