如何使用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
答案 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
也(在这种情况下)执行相同操作
Reference至powsimp
Reference至powdenest
答案 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))