Solving Trigonometric Equations with More Than One Variables

28 ビュー (過去 30 日間)
Yagmur Savkay Öztok
Yagmur Savkay Öztok 2022 年 8 月 4 日
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.

採用された回答

John D'Errico
John D'Errico 2022 年 8 月 4 日
編集済み: John D'Errico 2022 年 8 月 4 日
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 件のコメント
Yagmur Savkay Öztok
Yagmur Savkay Öztok 2022 年 8 月 8 日
Thanks for your huge effort, this is so helpful!
Wish you a nice day, John.

サインインしてコメントする。

その他の回答 (1 件)

Alan Stevens
Alan Stevens 2022 年 8 月 4 日
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 件のコメント
Sam Chak
Sam Chak 2022 年 8 月 4 日
If no restriction on , then there are complex-valued solutions on Wolfram.
Yagmur Savkay Öztok
Yagmur Savkay Öztok 2022 年 8 月 8 日
Thanks!
Have a nice day.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by