0
$\begingroup$

I have a system of 9 coupled trigonometric equations (a 3X3 Matrix). I am trying to find four unknown angles $\theta_1, \theta_2, \phi_1, \phi_2$ by solving any 4 out of 9 such equations. $\text{M}=\left( \begin{array}{ccc} \text{s1xs2x} \cos (\text{$\theta $1}) \cos (\text{$\theta $2}) \cos (\text{$\phi $1}) \cos (\text{$\phi $2})+\text{s1ys2y} \cos (\text{$\theta $1}) \cos (\text{$\theta $2}) \sin (\text{$\phi $1}) \sin (\text{$\phi $2})+\text{s1zs2z} \sin (\text{$\theta $1}) \sin (\text{$\theta $2}) & \text{s1ys2y} \cos (\text{$\theta $1}) \sin (\text{$\phi $1}) \cos (\text{$\phi $2})-\text{s1xs2x} \cos (\text{$\theta $1}) \cos (\text{$\phi $1}) \sin (\text{$\phi $2}) & \text{s1xs2x} \cos (\text{$\theta $1}) \sin (\text{$\theta $2}) \cos (\text{$\phi $1}) \cos (\text{$\phi $2})+\text{s1ys2y} \cos (\text{$\theta $1}) \sin (\text{$\theta $2}) \sin (\text{$\phi $1}) \sin (\text{$\phi $2})-\text{s1zs2z} \sin (\text{$\theta $1}) \cos (\text{$\theta $2}) \\ \text{s1ys2y} \cos (\text{$\theta $2}) \cos (\text{$\phi $1}) \sin (\text{$\phi $2})-\text{s1xs2x} \cos (\text{$\theta $2}) \sin (\text{$\phi $1}) \cos (\text{$\phi $2}) & \text{s1xs2x} \sin (\text{$\phi $1}) \sin (\text{$\phi $2})+\text{s1ys2y} \cos (\text{$\phi $1}) \cos (\text{$\phi $2}) & \text{s1ys2y} \sin (\text{$\theta $2}) \cos (\text{$\phi $1}) \sin (\text{$\phi $2})-\text{s1xs2x} \sin (\text{$\theta $2}) \sin (\text{$\phi $1}) \cos (\text{$\phi $2}) \\ \text{s1xs2x} \sin (\text{$\theta $1}) \cos (\text{$\theta $2}) \cos (\text{$\phi $1}) \cos (\text{$\phi $2})+\text{s1ys2y} \sin (\text{$\theta $1}) \cos (\text{$\theta $2}) \sin (\text{$\phi $1}) \sin (\text{$\phi $2})-\text{s1zs2z} \cos (\text{$\theta $1}) \sin (\text{$\theta $2}) & \text{s1ys2y} \sin (\text{$\theta $1}) \sin (\text{$\phi $1}) \cos (\text{$\phi $2})-\text{s1xs2x} \sin (\text{$\theta $1}) \cos (\text{$\phi $1}) \sin (\text{$\phi $2}) & \text{s1xs2x} \sin (\text{$\theta $1}) \sin (\text{$\theta $2}) \cos (\text{$\phi $1}) \cos (\text{$\phi $2})+\text{s1ys2y} \sin (\text{$\theta $1}) \sin (\text{$\theta $2}) \sin (\text{$\phi $1}) \sin (\text{$\phi $2})+\text{s1zs2z} \cos (\text{$\theta $1}) \cos (\text{$\theta $2}) \\ \end{array} \right)$

I have the numerical value of the matrix elements $M=\left( \begin{array}{ccc} 144.57 & -2.21141 & 149.231 \\ -10.5118 & 8.78583 & 10.3137 \\ 28.3015 & 14.5596 & 16.4425 \\ \end{array} \right)$

Also, s1xs2x = 17.1482, s1ys2y = -17.1482, s1zs2z = 210.153

My code looks like this:

M = {{144.57, -2.21141, 149.231}, {-10.5118, 8.78583, 10.3137}, {28.3015, 14.5596, 16.4425}} s1xs2x = 17.1482, s1ys2y = -17.1482, s1zs2z = 210.153 Sol = N@Reduce[{s1xs2x*Cos[Theta1]*Cos[Theta2]*Cos[Phi1]*Cos[Phi2] + s1zs2z*Sin[Theta1]*Sin[Theta2] + s1ys2y*Cos[Theta1]*Cos[Theta2]*Sin[Phi1]*Sin[Phi2] == M[[1,1]], s1ys2y*Cos[Theta1]*Cos[Phi2]*Sin[Phi1] - s1xs2x*Cos[Theta1]*Cos[Phi1]*Sin[Phi2] == M[[1,2]], (-s1zs2z)*Cos[Theta2]*Sin[Theta1] + s1xs2x*Cos[Theta1]*Cos[Phi1]*Cos[Phi2]*Sin[Theta2] + s1ys2y*Cos[Theta1]*Sin[Theta2]*Sin[Phi1]*Sin[Phi2] == M[[1,3]], s1ys2y*Cos[Phi1]*Cos[Phi2] + s1xs2x*Sin[Phi1]*Sin[Phi2] == M[[2,2]], 0 < Theta1 < Pi, 0 <Theta2 < Pi, 0 < Phi2 < Pi, 0 < Phi2 < Pi},{Theta1, Theta2, Phi1, Phi2}] 

The set of values of the angles I should obtain are: Theta1 = 1.25869, Phi1 = 2.94731, Theta2 = 0.770075, Phi2 = 1.84307 However, it keeps on running forever. I am not sure where I'm going wrong. Any help shall be highly appreciated.

$\endgroup$
4
  • $\begingroup$ Enclose the code by ``` some code ``` $\endgroup$ Commented Dec 2, 2021 at 13:02
  • $\begingroup$ Please post your equation as text in Mathematica code. $\endgroup$ Commented Dec 2, 2021 at 13:05
  • $\begingroup$ Convert your cells/expressions to InputForm prior to copy and paste. $\endgroup$ Commented Dec 2, 2021 at 17:05
  • $\begingroup$ Hi, thanks for your replies. I have added the code. $\endgroup$ Commented Dec 2, 2021 at 17:47

1 Answer 1

2
$\begingroup$

FindInstance (nor NSolve) returns a solution in Reals. Changed one of "Phi2" to "Phi1" also in the inequalities. Also should not start user-defined variables with upper case letter as the name may conflict with built-in names but I left them below for now:

s1xs2x = 17.1482; s1ys2y = -17.1482; s1zs2z = 210.153; m11 = 144.57; m12 = -2.21141; m13 = 149.231; m22 = 8.78583; FindInstance[{s1xs2x*Cos[Theta1]*Cos[Theta2]*Cos[Phi1]*Cos[Phi2] + s1zs2z*Sin[Theta1]*Sin[Theta2] + s1ys2y*Cos[Theta1]*Cos[Theta2]*Sin[Phi1]*Sin[Phi2] == m11, s1ys2y*Cos[Theta1]*Cos[Phi2]*Sin[Phi1] - s1xs2x*Cos[Theta1]*Cos[Phi1]*Sin[Phi2] ==m12, (-s1zs2z)*Cos[Theta2]*Sin[Theta1] + s1xs2x*Cos[Theta1]*Cos[Phi1]*Cos[Phi2]*Sin[Theta2] + s1ys2y*Cos[Theta1]*Sin[Theta2]*Sin[Phi1]*Sin[Phi2] == m13, s1ys2y*Cos[Phi1]*Cos[Phi2] + s1xs2x*Sin[Phi1]*Sin[Phi2] == m22 && 0 < Theta1 < Pi && 0 < Theta2 < Pi && 0 < Phi1 < Pi && 0 < Phi2 < Pi}, {Theta1, Theta2, Phi1, Phi2}, Reals] {} 
$\endgroup$
2
  • $\begingroup$ Hi, thanks for your reply. I have updated the set of values I should get by solving the given set of equations. However, the output obtained from the snippet you posted is just null. $\endgroup$ Commented Dec 2, 2021 at 19:43
  • $\begingroup$ Ok. When I plug in your values for the variables in the first equation I get 139.553. However m11=144.57 $\endgroup$ Commented Dec 2, 2021 at 20:12

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.