sympy中指数与和的指数相乘

时间:2018-09-27 17:13:14

标签: python sympy

如何使用sympy将exp(a * x)* exp(b * x)形式的表达式转换为exp(a * x + b * x)?

起点类似于:

from sympy import symbols, exp
from sympy import exp
x, a, b = symbols('x, a, b', real=True)
f = exp(a*x)*exp(b*x)

逆变换已在[1]中进行了解释

[1] Sympy: Multiplications of exponential rather than exponential of sum

2 个答案:

答案 0 :(得分:3)

我发现powsimp可以满足您的要求

from sympy import symbols, exp
from sympy import exp, powsimp
x, a, b = symbols('x, a, b', real=True)
f = exp(a*x)*exp(b*x)
powsimp(f)

输出

exp(a*x + b*x)

powdenest也(在这种情况下)执行相同操作

Referencepowsimp

Referencepowdenest

答案 1 :(得分:2)

simplify命令完成工作

from sympy import symbols, simplify, exp
x, a, b = symbols('x, a, b', real=True)
f = exp(a*x)*exp(b*x)
fs = simplify(f)

输出

>>> f
exp(ax)exp(bx)
>>> fs
exp(x(a + b))