Python sympy.expand_func()方法
在sympy.expand_func()方法的帮助下,我们可以根据一些数学特性来展开特殊函数。
语法: expand_func(expression)
参数 :
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))
输出:
Expression = gamma(x + 3)
Expanded Expression : x*(x + 1)*(x + 2)*gamma(x)
示例 #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))
输出:
Expression = binomial(x, 3)
Expanded Expression : x*(x - 2)*(x - 1)/6