我试图使变量test
等于变量test2
我从test2
得到的打印输出只是(1-g1 g1*)
所需要的
但是test
吐出(g1-1)(g1*-1)(x)(x*)
,其中x
是sqrt{(1- g1 g1*)/[(g1-1)(g1*-1)]}
从视觉上看问题,我知道表达式应该取消,但我无法用test
来简化共轭表达式
试过把sp.simplify,sp.together
import sympy as sp
def Lambdaj(gammaj):
step1 = sp.together(1 - sp.conjugate(gammaj)) * sp.sqrt((1 - gammaj * sp.conjugate(gammaj)) / ((1-gammaj) * (1 - sp.conjugate(gammaj))))
return step1
g1 = sp.symbols('g1')
test = sp.together(Lambdaj(g1) * sp.conjugate(Lambdaj(g1)))
print(test)
test2 = 1 - g1 * sp.conjugate(g1)
print(test2)
print(sp.together((1-g1)*(1-sp.conjugate(g1))))
假设
g1**2 < 1
公平吗?如果是这样,我们可以用只接受这些值的表达式替换g1
,简化结果,并重新替换原始的g1
:相关问题 更多 >
编程相关推荐