Say, I'm trying to solve the system of equations:
for θ, λ and ɸ , where a
, b
, c
and d
are complex numbers and the matrix on the LHS is a unitary matrix.
The SymPy code I have at hand does successfully do the job but there are a few edge cases it misses.
from sympy import *
def get_angles(a, b, c, d):
theta, phi, lamb = symbols('\\theta \\phi \\lambda', real=True)
a_eq = Eq(cos(theta / 2), a)
b_eq = Eq(exp(I * phi) * sin(theta / 2), b)
c_eq = Eq(-exp(I * lamb) * sin(theta / 2), c)
d_eq = Eq(exp(I * (phi + lamb)) * cos(theta / 2), d)
res = solve([a_eq, b_eq, c_eq, d_eq],
theta,
phi,
lamb,
check=False,
set=True)
return res
For instance, it doesn't restrict the range of the solutions. I did notice this answer but it only works for single variable cases. So any idea how to add the domain restrictions for the solution set, when dealing with multiple variables?