在使用 Sympy 进行符号数学运算时,我遇到了以下问题:
from sympy import *
txx, tyx, txy, tyy, tp, tn = symbols('t_xx t_yx t_xy t_yy t_p t_n', complex=True)
#define a complex symbol
tp = txx-I*tyx
Abs(tp), arg(tp)
#will just return |txx-i*tyx|, arg(txx-i*tyx)
但是,返回的绝对值和参数的形式并不sqrt(txx**2+tyx**2), atan(tyx/txx)
像您对复数所期望的那样。
我也试过
simplify(Abs(tp).expand(complex=True))
#returns |Retxx-i*Retyx+i*Imtxx+Imtxy|, but no further simplification
它再次适用于复数,但不适用于此处定义的复数符号。这还没有实施还是我做得不对?