sympy.expand_func(expression)方法
借助sympy.expand_func()方法,我们可以根据一些数学恒等式展开特殊函数。
语法:expand_func(expression)
参数:
expression – 是要展开的数学表达式。
返回值: 根据某些数学恒等式返回与输入对应的数学表达式。
sympy.expand_func(expression)方法 例# 1:
# import sympy
from sympy import *
x = symbols('x')
expr = gamma(x + 3)
print("Expression = {}".format(expr))
# Use sympy.expand_func() method
expand_expr = expand_func(expr)
print("Expanded Expression : {}".format(expand_expr))
Output:
Expression = gamma(x + 3)
Expanded Expression : x*(x + 1)*(x + 2)*gamma(x)
sympy.expand_func(expression)方法 例# 2:
# import sympy
from sympy import *
x = symbols('x')
expr = binomial(x, 3)
print("Expression = {}".format(expr))
# Use sympy.expand_func() method
expand_expr = expand_func(expr)
print("Expanded Expression : {}".format(expand_expr))
Output:
Expression = binomial(x, 3)
Expanded Expression : x*(x - 2)*(x - 1)/6