我试图在 SymPy 中简化矩阵与其共轭的乘法,但简化并未按预期进行。这是我的代码:
import sympy as sp
# Define symbols
e = sp.Symbol('epsilon', real=True, domain=sp.Interval(0, 1, right_open=True))
i = sp.I
p = sp.Symbol('psi', real=True)
# Define the Jones matrix with additional assumption
J = sp.Matrix([
[sp.sqrt(1 - e), -sp.sqrt(e) * sp.exp(i*p)],
[sp.sqrt(e) * sp.exp(-i*p), sp.sqrt(1 - e)]
])
# Create the conjugate matrix
J_conj = sp.conjugate(J)
# Compute the Kronecker product
J_prod = sp.kronecker_product(J, J_conj)
我尝试使用
sp.simplify(J_prod)
但 J_prod
仍然一样。
我想要
J_prod to
以这种形式呈现:
预计
J_prod
显然,SymPy 有时难以处理复数。
我认为这可能有帮助:
J_prod_simple = sp.re(J_prod) + i * sp.im(J_prod)