# Solving for three parameters from a matrix equation and storing them in separate variables

Say I have a matrix

$$Z=\begin{pmatrix}-\frac{1}{\sqrt 2} & \frac{i}{\sqrt 2} \\ \frac{i}{\sqrt 2} & -\frac{1}{\sqrt 2} \end{pmatrix}$$

and another matrix

$$U(\theta, \phi, \lambda) = \begin{pmatrix} \cos\left(\frac{\theta}{2}\right) & -e^{i\lambda} \sin\left(\frac{\theta}{2}\right) \\ e^{i\phi} \sin\left(\frac{\theta}{2}\right) & e^{i(\lambda + \phi)} \cos\left(\frac{\theta}{2}\right) \end{pmatrix}$$

I now want to solve for $$\theta$$, $$\phi$$ and $$\lambda$$ such that $$Z=U$$ ($$0 \leq \phi <2\pi$$, $$0\leq \theta \leq \pi$$ and $$0\leq \lambda < 2\pi$$). Is there any way to do this directly using say Solve? From the documentation, it seems that it works only for single equations rather than matrix equations like these. Is there any workaround so that I can directly solve for the three parameters and store them in three different variables?

This

Z={{-1/Sqrt[2],I/Sqrt[2]},{I/Sqrt[2],-1/Sqrt[2]}};
U={{Cos[θ/2],-E^(I λ)Sin[θ/2]}, {E^(I φ)Sin[θ/2],E^(I(λ+φ))Cos[θ/2]}};
Reduce[Z==U,{θ,φ,λ}]


shows you the conditions for the multiple different solutions for your example problem.

In this particular example problem FullSimplify is able to eliminate all the inverse trig functions and radicals in the solution.

• Thanks. Could you please check this issue?
– user63834
May 26 '19 at 7:30

I've modified Bill's code a bit to include the domain restriction and return approximate numerical values rather than exact values using trigonometric functions like arcsin, arctan, arccos, etc.

Z = {{-1/Sqrt[2], I/Sqrt[2]}, {I/Sqrt[2], -1/Sqrt[2]}};
U = {{Cos[\[Theta]/
2], -E^(I \[Lambda]) Sin[\[Theta]/
2]}, {E^(I \[CurlyPhi]) Sin[\[Theta]/2],
E^(I (\[Lambda] + \[CurlyPhi])) Cos[\[Theta]/2]}};
N[Reduce[Z == U && 0 <= \[CurlyPhi] < 2 Pi && 0 <= \[Theta] < Pi &&
0 <= \[Lambda] < 2 Pi, {\[Theta], \[CurlyPhi], \[Lambda]}]]


This produces:

\[Theta] == 4.71239 && \[CurlyPhi] == 1.5708 + 0. I && \[Lambda] == 4.71239 + 0. I