Solving Trigonometric Equations with More Than One Variables

1 view (last 30 days)
Hi.
My problem is that I have a 3x1 matrix with trigonometric expressions such that:
x = [cos(theta)*sin(phi)*sin(psi) + cos(phi)*sin(theta); -cos(psi)*sin(theta); cos(phi)*sin(psi)*cos(theta) - sin(phi)*cos(psi)*sin(theta)]
And it should be equal to another matrix
with real numbers like:
y = [0.6,-0.76,0]
My code is:
syms theta phi psi
eqn_1 = cos(theta)*sin(phi)*sin(psi) + cos(phi)*sin(theta) == 0.6;
eqn_2 = -cos(psi)*sin(theta) == -0.76 ;
eqn_3 = cos(phi)*sin(psi)*cos(theta) - sin(phi)*cos(psi)*sin(theta) == 0 ;
eqn_4 = theta == -30 * pi / 180 ;
s = solve(eqn_1,eqn_2,eqn_3,eqn_4,theta,phi,psi,'ReturnConditions',true) ;
s.theta
ans = Empty sym: 0-by-1
s.phi
ans = Empty sym: 0-by-1
s.psi
ans = Empty sym: 0-by-1
But as you can see, it does not work. Can you help me,please?
Thanks.

Accepted Answer

John D'Errico
John D'Errico on 4 Aug 2022
Edited: John D'Errico on 4 Aug 2022
You need to understand that first, the use of solve like this will probably fail. You have 4 equations, but only 3 unknowns. Solve will try to find an exact solution, but the problem is over-determined, so there will be no exact solution.
As bad is the problem that this is equivalent to a polynomial problem in the unknowns, where the degree of the polynomial may be too high for an algebraic solution to be found.
syms theta phi psi
eqn_1 = cos(theta)*sin(phi)*sin(psi) + cos(phi)*sin(theta) == 0.6;
eqn_2 = -cos(psi)*sin(theta) == -0.76 ;
eqn_3 = cos(phi)*sin(psi)*cos(theta) - sin(phi)*cos(psi)*sin(theta) == 0 ;
First, ignore the constraint on theta. We will now get two primary solutions, although infinitely many solutions will exist.
sol = solve(eqn_1,eqn_2,eqn_3)
sol = struct with fields:
phi: [2×1 sym] psi: [2×1 sym] theta: [2×1 sym]
vpa(sol.phi)
ans = 
vpa(sol.theta)
ans = 
vpa(sol.psi)
ans = 
eqn_4 = theta == -30 * pi / 180 ;
Note that it gets nastier looking if I use 'returnconditions' on the call. But do either of the solutions yield theta = pi/6? It is close, but not going to happen. Just for kicks though, lets try it.
sol = solve(eqn_1,eqn_2,eqn_3,'returnconditions',true); % nasty looking, so leave it hidden
Next, do any of those solutions ever yield theta = pi/6?
solve(sol.theta == pi/6)
ans = struct with fields:
m: -1/3 z1: 3^(1/2) + 2
So we learn that m must be -1/3. But I thought m had to be an integer.
sol.conditions(1)
ans = 
So no solutions exist.
  1 Comment
Yagmur Savkay Öztok
Yagmur Savkay Öztok on 8 Aug 2022
Thanks for your huge effort, this is so helpful!
Wish you a nice day, John.

Sign in to comment.

More Answers (1)

Alan Stevens
Alan Stevens on 4 Aug 2022
You have theta = 30degrees, so sin(theta) is 1/2.
Therefore, in equation 2, you have cos(psi)/2 = 0.76, so cos(psi) > 1. If you are dealing with real numbers this is invalid!
  3 Comments

Sign in to comment.

Tags

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!