solve command help needed.

9 Ansichten (letzte 30 Tage)
Divya Patel
Divya Patel am 13 Mär. 2021
Kommentiert: Walter Roberson am 13 Mär. 2021
here is my code,only 5 lines, and i m trying to solve for b,
syms b m theta
m = 5;
theta = 20;
eq = tand(theta)==(2*(1/tand(b)))*(((m*m*(sind(b)*sind(b))-1))/(m*m*(1.4+(cosd(b)*cosd(b)))+2)) ;
solve(eq,b)
the answer i get is this ==> -(log(root(z^6 - z^4*(1238888939898706904063102115185851/2095413426666905974699416890572625 + 2864291029470578218930659559211008i/2095413426666905974699416890572625) - z^2*(2168555873514773727160036100864837/2095413426666905974699416890572625 - 2244186785976947882873506458763264i/2095413426666905974699416890572625) + (78442739762537124403601334665223/83816537066676238987976675622905 + 29528773499696682669388242878464i/83816537066676238987976675622905), z, 1))*180i)/pi
now idk where z comes from since its not part of my code, but i also saw some imaginary parts so since i wanted a real number i tried this
syms b m theta
m = 5;
theta = 20;
eq = tand(theta)==(2*(1/tand(b)))*(((m*m*(sind(b)*sind(b))-1))/(m*m*(1.4+(cosd(b)*cosd(b)))+2)) ;
solve(eq,b,'real',true)
here i get the answer
ans = (180*(2*pi*k + atan2(x, 1) - atan2(-x, 1)))/pi
now its a smaller eq but idk what the k or x values to be,and where they come from
the ideal answer should be 29.8 for b.
so any one know whats happening and how to solve this.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 13 Mär. 2021
More solutions than you can shake a stick at.
syms b m theta
m = 5;
theta = 20;
eqn = tand(theta)==(2*(1/tand(b)))*(((m*m*(sind(b)*sind(b))-1))/(m*m*(1.4+(cosd(b)*cosd(b)))+2)) ;
sol = solve(eqn, b, 'returnconditions', true)
sol = struct with fields:
b: [1×1 sym] parameters: [1×2 sym] conditions: [1×1 sym]
sol.b
ans = 
sol.parameters
ans = 
sol.conditions
ans = 
k = 0;
z1 = solve(subs(sol.conditions, sol.parameters(1), k));
sol6_0 = simplify(subs(subs(sol.b, sol.parameters(1), k), sol.parameters(2), z1))
sol6_0 = 
vpa(sol6_0)
ans = 
k = 1;
z1 = solve(subs(sol.conditions, sol.parameters(1), k));
sol6_1 = simplify(subs(subs(sol.b, sol.parameters(1), k), sol.parameters(2), z1))
sol6_1 = 
vpa(sol6_1)
ans = 
k = -1;
z1 = solve(subs(sol.conditions, sol.parameters(1), k));
sol6_m1 = simplify(subs(subs(sol.b, sol.parameters(1), k), sol.parameters(2), z1))
sol6_m1 = 
vpa(sol6_m1)
ans = 
  2 Kommentare
Divya Patel
Divya Patel am 13 Mär. 2021
hello sir the "vpa(sol6_0)"
does give the right answer, well out of the 6 values it outputs one of the value is the usefull needed one, but if possible can you explain how the code exicuted to get me this, as i want to stich this value into a bigger recurring code.
Thank You
Walter Roberson
Walter Roberson am 13 Mär. 2021
You probably don't really care. What you probably want is more like
syms m theta
syms b
assume(b >= -90 & b <= 90)
m = 5;
theta = 20;
eq = tand(theta)==(2*(1/tand(b)))*(((m*m*(sind(b)*sind(b))-1))/(m*m*(1.4+(cosd(b)*cosd(b)))+2)) ;
vpasolve(eq, b)
ans = 
33.175834649454488192870542271753
all of the values in sol6_0, sol6_1, sol6_m1, and many others, are valid solutions for your equation, and you should be using them all -- unless you have physical reason to constrain the angles.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by