借助于sympy.factor_list()方法,我们可以以(因子,幂)元组的形式获取SymPy中数学表达式的因子列表。
用法: factor_list(expression)
参数:
expression–这是一个数学表达式。
返回值:以(因子,乘方)元组的形式返回给定数学表达式的因子列表。
示例1:
在此示例中,我们可以看到,通过使用sympy.factor_list()方法,可以获得给定数学表达式的因子列表。
# import sympy 
from sympy import * x = symbols('x') 
expr = x**2 * z + 4 * x*y * z + 4 * y**2 * z 
  
print("Mathematical expression : {}".format(expr)) 
    
# Use sympy.factor_list() method 
f = factor_list(expr)  
    
print("List of factors : {}".format(f)) 输出:
Mathematical expression : x**2*z + 4*x*y*z + 4*y**2*z List of factors : (1, [(z, 1), (x + 2*y, 2)])
示例2:
# import sympy 
from sympy import * x = symbols('x') 
expr = (x**2 - 2 * x + 1) 
  
print("Mathematical expression : {}".format(expr)) 
    
# Use sympy.factor_list() method 
f = factor_list(expr)  
    
print("List of factors : {}".format(f)) 输出:
Mathematical expression : x**2 - 2*x + 1 List of factors : (1, [(x - 1, 2)])
相关用法
- Python next()用法及代码示例
 - Python os.dup()用法及代码示例
 - Python set()用法及代码示例
 - Python os.abort()用法及代码示例
 - Python os.WEXITSTATUS()用法及代码示例
 - Python os.fchmod()用法及代码示例
 - Python PIL getpixel()用法及代码示例
 - Python PIL putpixel()用法及代码示例
 - Python os.sysconf()用法及代码示例
 - Python os.confstr()用法及代码示例
 - Python os._exit()用法及代码示例
 - Python cmath.log()用法及代码示例
 - Python Tensorflow cos()用法及代码示例
 - Python sympy.rf()用法及代码示例
 
注:本文由纯净天空筛选整理自rupesh_rao大神的英文原创作品 Python | sympy.factor_list() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
