You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
error message in solving symbolic equation???
11 views (last 30 days)
Show older comments
syms m_c0 j_L0 theta1 M m_c_gama j_L_gama j_L_theta1 m_c_theta2 _L_theta2
syms m_c_theta1 gama l theta2 k1
eqn1=m_c_theta1==(m_c0-1/M+1)*cos(theta1)+j_L0*sin(theta1)+1/M-1;
eqn2=j_L_theta1==(-m_c0+1/M-1)*sin(theta1)+j_L0*cos(theta1);
%eqn3=m_m_theta1==1;
%eqn3=j_Lm_theta1==j_Lm0+l*theta1;
eqn4=m_c_theta2==j_L_theta1*sin(theta2-theta1)+(m_c_theta1+1)*cos(theta2-theta1)-1;
eqn5=j_L_theta2==j_L_theta1*cos(theta2-theta1)-(m_c_theta1+1)*sin(theta2-theta1);
%m_m_theta2=1;
%qn6=j_Lm_theta2==j_Lm0+l*theta2;
eqn7=m_c_gama==(1/k1)*j_L_theta2*sin(k1*(gama-theta2))+m_c_theta2*cos(k1*(gama-theta2));
eqn8=j_L_gama==j_L_theta2*cos(k1*(gama-theta2))-k1*m_c_theta2*sin(k1*(gama-theta2));
%eqn9=j_Lm_gama==j_L_gama;
%m_m_gama=(-m_c_theta2*cos(k1*(gama-theta2))-(1/k1)*j_L_theta2*sin(k1*(gama-theta2)))/(1+l)
m_c_gama=-m_c0;
j_L_gama=-j_L0;
j_L_theta2=(theta2*l)/2;
j_L_gama=j_L_theta2-l*(gama-theta2);
%j_L_theta2=j_Lm_theta2;
%j_Lm0=-j_Lm_gama;
%j_L_gama=j_Lm_gama;
eqns = subs([eqn1, eqn2, eqn4, eqn5, eqn7, eqn8]);
sol = solve(eqns, m_c0, j_L0, m_c_theta1,j_L_theta1,m_c_theta2,j_L_theta2)
this is showing some errors like this:
Error using sym.getEqnsVars>checkVariables (line 92)
The second argument must be a vector of symbolic variables.
Error in sym.getEqnsVars (line 62)
checkVariables(vars);
Error in solve>getEqns (line 450)
[eqns, vars] = sym.getEqnsVars(argv{:});
Error in solve (line 225)
[eqns,vars,options] = getEqns(varargin{:});
Error in eqnsolve_highvolfullload (line 28)
sol = solve(eqns, m_c0, j_L0, m_c_theta1,j_L_theta1,m_c_theta2,j_L_theta2,theta1, theta2)
what should be done?
4 Comments
Walter Roberson
on 24 Apr 2017
User removed original code. It looked like,
syms m_c0 j_L0 theta1 M m_c_gama j_L_gama j_L_theta1 m_c_theta2 j_L_theta2
syms m_c_theta1 gama l theta2 k1
eqn1=m_c_theta1==(m_c0-1/M+1)*cos(theta1)+j_L0*sin(theta1)+1/M-1;
eqn2=j_L_theta1==(-m_c0+1/M-1)*sin(theta1)+j_L0*cos(theta1);
eqn4=m_c_theta2==j_L_theta1*sin(theta2-theta1)+(m_c_theta1+1)*cos(theta2-theta1)-1;
eqn5=j_L_theta2==j_L_theta1*cos(theta2-theta1)-(m_c_theta1+1)*sin(theta2-theta1);
eqn7=m_c_gama==(1/k1)*j_L_theta2*sin(k1*(gama-theta2))+m_c_theta2*cos(k1*(gama-theta2));
eqn8=j_L_gama==j_L_theta2*cos(k1*(gama-theta2))-k1*m_c_theta2*sin(k1*(gama-theta2));
m_c_gama=-m_c0;
j_L_gama=-j_L0;
j_L_theta2=(gama*l)/2;
eqns = subs([eqn1, eqn2, eqn4, eqn5, eqn7, eqn8]);
sol = solve(eqns, m_c0, j_L0, m_c_theta1,j_L_theta1,m_c_theta2,j_L_theta2)
Manuela Gräfe
on 25 Apr 2017
Hello, umme mumtahina.
I wrote comments under many of your question. Please provide the final solutions! Don't just write "got it!!!". This is a public community and some other people are also interested in the final solutions!
Please contact me via personal message! Click my profile and then send me a message please.
Rena Berman
on 28 Apr 2017
(Answers Dev) Restored edit
Accepted Answer
Walter Roberson
on 17 Feb 2017
You defined a value
j_L_theta2=(gama*l)/2;
That makes j_L_theta2 no longer a simple variable. You cannot solve for it in
sol = solve(eqns, m_c0, j_L0, m_c_theta1,j_L_theta1,m_c_theta2,j_L_theta2)
and you need to remove it from the end of the parameter list.
That would leave you with 6 equations and with you requesting to solve only 5 unknowns. There will be no solution to that.
The variables you are not solving for are M, gama, k1, l, theta1, and theta2 . You should add one of those to the solve() parameter list to solve for it. If you add M or l or theta1 to the parameter list then you will get a solution. However if you add gama or k1 or theta2 then no solution will be found.
22 Comments
Walter Roberson
on 20 Feb 2017
Isolating out the first five variables is quick. Isolating out the theta2 from the remaining (substituted) equation is somewhere between "quite time consuming" and "not possible"; I am not sure yet which. It is too complex for MATLAB to do directly.
Walter Roberson
on 20 Feb 2017
If I drop in a small number of random constants, theta2 comes out as arctan() of expressions that depend upon the roots of a 12th degree polynomial. As trig equations are involved, it is possible that a completely different equation would fall out for different constants; I am continuing to look.
safi58
on 14 Mar 2017
I also could not find the solution for theta2. I have found the solution for m_c0, j_L0, m_c_theta1,j_L_theta1,m_c_theta2,theta1. But the issue is I am getting square root for some of these values which will give imaginary values at some point. Is there any way to resolve this issue?
Walter Roberson
on 14 Mar 2017
Could you remind me whether all of the symbols are intended to be real-valued? Or which ones might be complex?
Walter Roberson
on 14 Mar 2017
"But the issue is I am getting square root for some of these values which will give imaginary values at some point. Is there any way to resolve this issue?"
You can isolate the first 5 variables without ^2 or sqrt() by making use of the trig identity sin^2 + cos^2 = 1.
But it does not look promising so far for isolating theta1 without sqrt()... I am testing further.
Walter Roberson
on 14 Mar 2017
I killed the calculation after several hours... It was using all of my memory.
Walter Roberson
on 15 Mar 2017
About the best I can reduce theta1 down to is a pair of solutions,
arctan( (signum(cos(k1 * (gama - theta2)) + cos(theta2)) * (sin(k1 * (gama - theta2)) * k1 - sin(theta2)) * (( - ((gama^2 * l^2 - 4) * k1^4 + (6 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 * cos(theta2)^2 - 4 * M * (M * l * gama * (k1^2 + 3) * sin(theta2) + 2 * k1^2 * (M - 1)) * k1^2 * cos(theta2) + 4 * M * l * k1^2 * gama * (k1^2 + 1) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (2 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^4 + 4 * k1^2) * cos(k1 * (gama - theta2))^2 + 4 * (( - 3 * (k1^2 + 1/3) * gama * M * l * cos(theta2)^2 + (M * ((gama^2 * l^2 - 2) * k1^2 + gama^2 * l^2) * sin(theta2) + 2 * l * k1^2 * gama * (M - 1)) * cos(theta2) + 2 * k1^2 * (M - 1) * sin(theta2) + M * gama * l * (k1^2 + 1)) * M * sin(k1 * (gama - theta2)) - 2 * (( - M^2 + M) * cos(theta2)^2 + (M * l * gama * (M - 1) * sin(theta2) + M^2 * l^2 * gama^2 - 1) * cos(theta2) + M * (M * gama * l * sin(theta2) + M - 1)) * k1) * k1 * cos(k1 * (gama - theta2)) + 4 * ( - l * gama * (k1^2 + 1) * (M - 1) * cos(theta2)^2 - 2 * ((M - 1) * sin(theta2) + M * l * gama) * k1^2 * cos(theta2) + (((gama^2 * l^2 + 2) * k1^2 + gama^2 * l^2) * M - 4 * k1^2) * sin(theta2) + 3 * (k1^2 + 1/3) * gama * (M - 1) * l) * M * k1 * sin(k1 * (gama - theta2)) + (((gama^2 * l^2 - 4) * k1^4 + (2 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^2 + 4 * k1^2) * cos(theta2)^2 + 4 * M * k1^2 * (M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * cos(theta2) - (4 * l * k1^2 * gama * (k1^2 + 3) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (6 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M - 8 * k1^4 - 8 * k1^2) * M)^(1/2) + (cos(k1 * (gama - theta2)) + cos(theta2)) * ( - 2 * M * k1 * (l * gama * cos(theta2) + sin(theta2)) * cos(k1 * (gama - theta2)) + ( - 2 * M * cos(theta2) * k1^2 + M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * sin(k1 * (gama - theta2)) - 2 * ((M - 1) * sin(theta2) + M * l * gama) * k1)) / (((k1^2 - 1) * cos(k1 * (gama - theta2))^2 - 2 * cos(k1 * (gama - theta2)) * cos(theta2) + 2 * sin(k1 * (gama - theta2)) * sin(theta2) * k1 - k1^2 - 1) * k1), ( - signum(cos(k1 * (gama - theta2)) + cos(theta2)) * (cos(k1 * (gama - theta2)) + cos(theta2)) * (( - ((gama^2 * l^2 - 4) * k1^4 + (6 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 * cos(theta2)^2 - 4 * M * (M * l * gama * (k1^2 + 3) * sin(theta2) + 2 * k1^2 * (M - 1)) * k1^2 * cos(theta2) + 4 * M * l * k1^2 * gama * (k1^2 + 1) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (2 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^4 + 4 * k1^2) * cos(k1 * (gama - theta2))^2 + 4 * (( - 3 * (k1^2 + 1/3) * gama * M * l * cos(theta2)^2 + (M * ((gama^2 * l^2 - 2) * k1^2 + gama^2 * l^2) * sin(theta2) + 2 * l * k1^2 * gama * (M - 1)) * cos(theta2) + 2 * k1^2 * (M - 1) * sin(theta2) + M * gama * l * (k1^2 + 1)) * M * sin(k1 * (gama - theta2)) - 2 * (( - M^2 + M) * cos(theta2)^2 + (M * l * gama * (M - 1) * sin(theta2) + M^2 * l^2 * gama^2 - 1) * cos(theta2) + M * (M * gama * l * sin(theta2) + M - 1)) * k1) * k1 * cos(k1 * (gama - theta2)) + 4 * ( - l * gama * (k1^2 + 1) * (M - 1) * cos(theta2)^2 - 2 * ((M - 1) * sin(theta2) + M * l * gama) * k1^2 * cos(theta2) + (((gama^2 * l^2 + 2) * k1^2 + gama^2 * l^2) * M - 4 * k1^2) * sin(theta2) + 3 * (k1^2 + 1/3) * gama * (M - 1) * l) * M * k1 * sin(k1 * (gama - theta2)) + (((gama^2 * l^2 - 4) * k1^4 + (2 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^2 + 4 * k1^2) * cos(theta2)^2 + 4 * M * k1^2 * (M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * cos(theta2) - (4 * l * k1^2 * gama * (k1^2 + 3) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (6 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M - 8 * k1^4 - 8 * k1^2) * M)^(1/2) - ( - 2 * M * cos(theta2) * k1^2 + M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * k1 * cos(k1 * (gama - theta2))^2 - 2 * M * (k1 * (l * gama * cos(theta2) + sin(theta2)) * sin(k1 * (gama - theta2)) - l * gama * cos(theta2) * sin(theta2) + cos(theta2)^2 - 1) * k1 * cos(k1 * (gama - theta2)) + (M * l * gama * (k1^2 + 1) * cos(theta2)^2 + 2 * M * cos(theta2) * k1^2 * sin(theta2) - 4 * k1^2 * (M - 1) * sin(theta2) - 3 * (k1^2 + 1/3) * gama * M * l) * sin(k1 * (gama - theta2)) + (( - 2 * M + 2) * cos(theta2)^2 - 2 * M * cos(theta2) * k1^2 + M * l * gama * (k1^2 + 3) * sin(theta2) + 2 * (k1^2 + 1) * (M - 1)) * k1) / (((k1^2 - 1) * cos(k1 * (gama - theta2))^2 - 2 * cos(k1 * (gama - theta2)) * cos(theta2) + 2 * sin(k1 * (gama - theta2)) * sin(theta2) * k1 - k1^2 - 1) * k1))
and
arctan(( - signum(cos(k1 * (gama - theta2)) + cos(theta2)) * (sin(k1 * (gama - theta2)) * k1 - sin(theta2)) * (( - ((gama^2 * l^2 - 4) * k1^4 + (6 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 * cos(theta2)^2 - 4 * M * (M * l * gama * (k1^2 + 3) * sin(theta2) + 2 * k1^2 * (M - 1)) * k1^2 * cos(theta2) + 4 * M * l * k1^2 * gama * (k1^2 + 1) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (2 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^4 + 4 * k1^2) * cos(k1 * (gama - theta2))^2 + 4 * (( - 3 * (k1^2 + 1/3) * gama * M * l * cos(theta2)^2 + (M * ((gama^2 * l^2 - 2) * k1^2 + gama^2 * l^2) * sin(theta2) + 2 * l * k1^2 * gama * (M - 1)) * cos(theta2) + 2 * k1^2 * (M - 1) * sin(theta2) + M * gama * l * (k1^2 + 1)) * M * sin(k1 * (gama - theta2)) - 2 * (( - M^2 + M) * cos(theta2)^2 + (M * l * gama * (M - 1) * sin(theta2) + M^2 * l^2 * gama^2 - 1) * cos(theta2) + M * (M * gama * l * sin(theta2) + M - 1)) * k1) * k1 * cos(k1 * (gama - theta2)) + 4 * ( - l * gama * (k1^2 + 1) * (M - 1) * cos(theta2)^2 - 2 * ((M - 1) * sin(theta2) + M * l * gama) * k1^2 * cos(theta2) + (((gama^2 * l^2 + 2) * k1^2 + gama^2 * l^2) * M - 4 * k1^2) * sin(theta2) + 3 * (k1^2 + 1/3) * gama * (M - 1) * l) * M * k1 * sin(k1 * (gama - theta2)) + (((gama^2 * l^2 - 4) * k1^4 + (2 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^2 + 4 * k1^2) * cos(theta2)^2 + 4 * M * k1^2 * (M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * cos(theta2) - (4 * l * k1^2 * gama * (k1^2 + 3) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (6 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M - 8 * k1^4 - 8 * k1^2) * M)^(1/2) + (cos(k1 * (gama - theta2)) + cos(theta2)) * ( - 2 * M * k1 * (l * gama * cos(theta2) + sin(theta2)) * cos(k1 * (gama - theta2)) + ( - 2 * M * cos(theta2) * k1^2 + M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * sin(k1 * (gama - theta2)) - 2 * ((M - 1) * sin(theta2) + M * l * gama) * k1)) / (((k1^2 - 1) * cos(k1 * (gama - theta2))^2 - 2 * cos(k1 * (gama - theta2)) * cos(theta2) + 2 * sin(k1 * (gama - theta2)) * sin(theta2) * k1 - k1^2 - 1) * k1), (signum(cos(k1 * (gama - theta2)) + cos(theta2)) * (cos(k1 * (gama - theta2)) + cos(theta2)) * (( - ((gama^2 * l^2 - 4) * k1^4 + (6 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 * cos(theta2)^2 - 4 * M * (M * l * gama * (k1^2 + 3) * sin(theta2) + 2 * k1^2 * (M - 1)) * k1^2 * cos(theta2) + 4 * M * l * k1^2 * gama * (k1^2 + 1) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (2 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^4 + 4 * k1^2) * cos(k1 * (gama - theta2))^2 + 4 * (( - 3 * (k1^2 + 1/3) * gama * M * l * cos(theta2)^2 + (M * ((gama^2 * l^2 - 2) * k1^2 + gama^2 * l^2) * sin(theta2) + 2 * l * k1^2 * gama * (M - 1)) * cos(theta2) + 2 * k1^2 * (M - 1) * sin(theta2) + M * gama * l * (k1^2 + 1)) * M * sin(k1 * (gama - theta2)) - 2 * (( - M^2 + M) * cos(theta2)^2 + (M * l * gama * (M - 1) * sin(theta2) + M^2 * l^2 * gama^2 - 1) * cos(theta2) + M * (M * gama * l * sin(theta2) + M - 1)) * k1) * k1 * cos(k1 * (gama - theta2)) + 4 * ( - l * gama * (k1^2 + 1) * (M - 1) * cos(theta2)^2 - 2 * ((M - 1) * sin(theta2) + M * l * gama) * k1^2 * cos(theta2) + (((gama^2 * l^2 + 2) * k1^2 + gama^2 * l^2) * M - 4 * k1^2) * sin(theta2) + 3 * (k1^2 + 1/3) * gama * (M - 1) * l) * M * k1 * sin(k1 * (gama - theta2)) + (((gama^2 * l^2 - 4) * k1^4 + (2 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^2 + 4 * k1^2) * cos(theta2)^2 + 4 * M * k1^2 * (M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * cos(theta2) - (4 * l * k1^2 * gama * (k1^2 + 3) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (6 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M - 8 * k1^4 - 8 * k1^2) * M)^(1/2) - ( - 2 * M * cos(theta2) * k1^2 + M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * k1 * cos(k1 * (gama - theta2))^2 - 2 * M * (k1 * (l * gama * cos(theta2) + sin(theta2)) * sin(k1 * (gama - theta2)) - l * gama * cos(theta2) * sin(theta2) + cos(theta2)^2 - 1) * k1 * cos(k1 * (gama - theta2)) + (M * l * gama * (k1^2 + 1) * cos(theta2)^2 + 2 * M * cos(theta2) * k1^2 * sin(theta2) - 4 * k1^2 * (M - 1) * sin(theta2) - 3 * (k1^2 + 1/3) * gama * M * l) * sin(k1 * (gama - theta2)) + (( - 2 * M + 2) * cos(theta2)^2 - 2 * M * cos(theta2) * k1^2 + M * l * gama * (k1^2 + 3) * sin(theta2) + 2 * (k1^2 + 1) * (M - 1)) * k1) / (((k1^2 - 1) * cos(k1 * (gama - theta2))^2 - 2 * cos(k1 * (gama - theta2)) * cos(theta2) + 2 * sin(k1 * (gama - theta2)) * sin(theta2) * k1 - k1^2 - 1) * k1))
This does include square roots. There are four places (total) that they occur, and all of them are the same expression,
(( - ((gama^2 * l^2 - 4) * k1^4 + (6 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 * cos(theta2)^2 - 4 * M * (M * l * gama * (k1^2 + 3) * sin(theta2) + 2 * k1^2 * (M - 1)) * k1^2 * cos(theta2) + 4 * M * l * k1^2 * gama * (k1^2 + 1) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (2 * gama^2 * l^2 - 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^4 + 4 * k1^2) * cos(k1 * (gama - theta2))^2 + 4 * (( - 3 * (k1^2 + 1/3) * gama * M * l * cos(theta2)^2 + (M * ((gama^2 * l^2 - 2) * k1^2 + gama^2 * l^2) * sin(theta2) + 2 * l * k1^2 * gama * (M - 1)) * cos(theta2) + 2 * k1^2 * (M - 1) * sin(theta2) + M * gama * l * (k1^2 + 1)) * M * sin(k1 * (gama - theta2)) - 2 * (( - M^2 + M) * cos(theta2)^2 + (M * l * gama * (M - 1) * sin(theta2) + M^2 * l^2 * gama^2 - 1) * cos(theta2) + M * (M * gama * l * sin(theta2) + M - 1)) * k1) * k1 * cos(k1 * (gama - theta2)) + 4 * ( - l * gama * (k1^2 + 1) * (M - 1) * cos(theta2)^2 - 2 * ((M - 1) * sin(theta2) + M * l * gama) * k1^2 * cos(theta2) + (((gama^2 * l^2 + 2) * k1^2 + gama^2 * l^2) * M - 4 * k1^2) * sin(theta2) + 3 * (k1^2 + 1/3) * gama * (M - 1) * l) * M * k1 * sin(k1 * (gama - theta2)) + (((gama^2 * l^2 - 4) * k1^4 + (2 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M^2 - 8 * M * k1^2 + 4 * k1^2) * cos(theta2)^2 + 4 * M * k1^2 * (M * l * gama * (k1^2 + 1) * sin(theta2) + 2 * k1^2 * (M - 1)) * cos(theta2) - (4 * l * k1^2 * gama * (k1^2 + 3) * (M - 1) * sin(theta2) + ((gama^2 * l^2 + 4) * k1^4 + (6 * gama^2 * l^2 + 4) * k1^2 + gama^2 * l^2) * M - 8 * k1^4 - 8 * k1^2) * M)^(1/2)
It is not obvious what the sign of this is.
Walter Roberson
on 15 Mar 2017
What are the constraints on those variables, other than being real-valued? You mentioned capacitor voltage: does that imply they could be both positive and negative?
Walter Roberson
on 19 Mar 2017
My tests suggest that there are an infinite number of solutions, including ones in which several of the variables are 0.
Walter Roberson
on 21 Mar 2017
I turned the calculation into a sum of squares of residues, and then ran a minimizer over it, testing a number of values. I noticed that along with the other solutions, that there were two clear intersecting lines along which the residues were 0, and those lines corresponded to a couple of the variables being 0.
Walter Roberson
on 21 Mar 2017
The minimizer I used is not available as I am still developing it. However I should be able to provide the code for the function that would do the residue calculation. I do not have that handy at the moment as I am using a different device, but I will post it later.
The basic calculation in such a situation is to take each of the simultaneous equations, and subtract the right hand side from the left side to get an expression which would be be true if the result of the subtraction were 0. Do the same thing for each equation, getting an equation from each. Now, create a new expression which is the total of the squares of the other expressions. If all of the original equations were to balance then the contribution from each of the component expressions would be 0^2 = 0, and since the total of any number of 0 is 0, this new sum of squares would evaluate to 0 if all of individual equations balance.
This sum of squares formula has many local minima so you cannot simply use fmincon with it: you need some kind of global minimizer.
Walter Roberson
on 22 Mar 2017
syms m_c0 j_L0 theta1 M m_c_gama j_L_gama j_L_theta1 m_c_theta2 j_L_theta2
syms m_c_theta1 gama l theta2 k1
eqn1L = m_c_theta1;
eqn1R = (m_c0-1/M+1)*cos(theta1)+j_L0*sin(theta1)+1/M-1;
eqn1 = eqn1L - eqn1R;
eqn2L = j_L_theta1;
eqn2R = (-m_c0+1/M-1)*sin(theta1)+j_L0*cos(theta1);
eqn2 = eqn2L - eqn2R;
eqn4L = m_c_theta2;
eqn4R = j_L_theta1*sin(theta2-theta1)+(m_c_theta1+1)*cos(theta2-theta1)-1;
eqn4 = eqn4L - eqn4L;
eqn5L = j_L_theta2;
eqn5R = j_L_theta1*cos(theta2-theta1)-(m_c_theta1+1)*sin(theta2-theta1);
eqn5 = eqn5L - eqn5R;
eqn7L = m_c_gama;
eqn7R = (1/k1)*j_L_theta2*sin(k1*(gama-theta2))+m_c_theta2*cos(k1*(gama-theta2));
eqn7 = eqn7L - eqn7R;
eqn8L = j_L_gama;
eqn8R = j_L_theta2*cos(k1*(gama-theta2))-k1*m_c_theta2*sin(k1*(gama-theta2));
eqn8 = eqn8L - eqn8R;
m_c_gama = -m_c0;
j_L_gama = -j_L0;
j_L_theta2 = (gama*l)/2;
residue = eqn1.^2 + eqn2.^2 + eqn4.^2 + eqn5.^2 + eqn7.^2 + eqn8.^2;
eqn = simplify( subs(residue) );
vars = [M, gama, j_L0, j_L_theta1, k1, l, m_c0, m_c_theta1, m_c_theta2, theta1, theta2];
Fvec = matlabFunction(eqn, 'vars', {vars});
Farray = matlabFunction(eqn, 'vars', vars);
Now you can use Fvec or Farray with a minimizer, looking for values near 0 (which indicate that all of the individual equations are balanced.)
The best I have found so far is
[ M, gama, j_L0, j_L_theta1, k1, l, m_c0, m_c_theta1, m_c_theta2, theta1, theta2] =
[0.264651987992054916, 2.2050144528762562e-17, 2.27231700419163755e-17, 1.74881407157095661e-17, -2.60182412177158895, 1.46780465953763239, 2.99999999999965894, 2.99999999999965894, -2.99999999999965894, 2.36395222838333151e-17, 2.39658891354045945e-17]
with a residue of 7.20318529637006345e-46 -- which is well into numeric noise level.
The search range I used for the above best value was
lowerbound [-1 -eps -eps -eps -3 -3 -3 -3 -3 0 0]
upperbound [ 1 eps eps eps 3 3 3 3 3 2*pi 2*pi]
The -1 to +1, and -3 to +3 were arbitrary restrictions because I could see from my graphics that there was a wide range of values for which they generated very low residues, indicating that the exact range of those values barely mattered. The 0 to +2*pi are for theta1 and theta2, known to be angles. The -eps to +eps were effective 0s for variables that I could see from my graphics had very low residues at values arbitrarily close to 0 -- though it turns out that m_c0 being just a little less than 3.0 is important for the very low residue with the other combination of values.
M of exactly 0 leads to NaN, as does k1 of exactly 0.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)