借助sympy.cancel()
方法,我们能够执行任何有理函数并将其放入标准规范形式,即p/q
。
用法:sympy.cancel()
返回:Return the canonical expression of any rational function.
范例1:
在给定的示例中,我们可以通过使用sympy.cancel()
方法,我们可以找到任何有理数即(p /q)的规范形式。
# import sympy
from sympy import * x, y, z = symbols('x y z')
gfg_exp = (x**2 + 2 * x + 1)/(x**2 + x)
# Using sympy.collect() method
gfg_exp = cancel(gfg_exp)
print(gfg_exp)
输出:
(x + 1)/x
范例2:
# import sympy
from sympy import * x, y, z = symbols('x y z')
gfg_exp = 1 / x + (3 * x / 2 - 2)/(x - 4)
# Using sympy.collect() method
gfg_exp = cancel(gfg_exp)
print(gfg_exp)
输出:
(3*x**2 - 2*x - 8)/(2*x**2 - 8*x)
相关用法
- Python set()用法及代码示例
- Python os.dup()用法及代码示例
- Python next()用法及代码示例
- Python os.set_blocking()用法及代码示例
- Python os.get_blocking()用法及代码示例
- Python PIL blend()用法及代码示例
- Python Tensorflow sin()用法及代码示例
- Python PIL ImageChops.add()用法及代码示例
- Python PIL composite()用法及代码示例
- Python Tensorflow tan()用法及代码示例
- Python PIL copy()用法及代码示例
- Python os.open()用法及代码示例
- Python hasattr()用法及代码示例
- Python os.setreuid()用法及代码示例
注:本文由纯净天空筛选整理自Jitender_1998大神的英文原创作品 Python | sympy.cancel() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。