📜  Python| sympy.gammasimp() 方法

📅  最后修改于: 2022-05-13 01:54:58.565000             🧑  作者: Mango

Python| sympy.gammasimp() 方法

借助sympy.gammasimp()方法,我们可以使用 gamma 函数或具有非整数参数的组合函数来简化表达式

示例 #1:

# import sympy 
from sympy import * x = symbols('x')
expr = gamma(x)*gamma(1 - x)
print("Expression = {}".format(expr))
   
# Use sympy.gammasimp() method 
simple_expr = gammasimp(expr)  
      
print("Simplified Expression : {}".format(simple_expr))  

输出:

Expression = gamma(x)*gamma(1 - x)
Simplified Expression : pi/sin(pi*x)

示例 #2:

# import sympy 
from sympy import * x = symbols('x')
expr = gamma(x + 1)/gamma(x - 1)
print("Expression = {}".format(expr))
   
# Use sympy.gammasimp() method 
simple_expr = gammasimp(expr)  
      
print("Simplified Expression : {}".format(simple_expr))  

输出:

Expression = gamma(x + 1)/gamma(x - 1)
Simplified Expression : x*(x - 1)