从SymPy中的表达式删除exp(I * pi)

问题描述 投票:0回答:1

使用sympy集成表达式时,结果中通常会存在exp(I * pi):

from sympy.functions import *
from sympy import *
init_printing(use_latex=False, use_unicode=False)
shift = Symbol('shift', real=True, positive=True)
x = Symbol('x', real=True, positive=True)
p = Symbol('p', real=True)

expr = integrate(exp(-p)/(p+shift), (p, x, oo))
expr
/            /   /             I*pi\     /             I*pi\             \    
|            |log\(shift + x)*e    / - Ei\(shift + x)*e    /   EulerGamma|    
|(shift + x)*|---------------------------------------------- + ----------| - l
\            \                  shift + x                      shift + x /    

                          \       
                          |  shift
og(shift + x) - EulerGamma|*e     
                          /      

但是已知exp(I*pi) == -1。并且在表达式中具有意图真实的复数是不方便的。是否可以用表达式中的-1替换exp(I*pi)?我已经尝试过simplify()subs(exp(I*pi), -1)。第一个和第二个都没有帮助。

python sympy symbolic-math
1个回答
0
投票

特殊的打印指令隐藏了您真正拥有的东西。不是exp(I*pi),而是polar_exp(I*pi)。如果您print(expr),您将看到以下内容:

© www.soinside.com 2019 - 2024. All rights reserved.