借助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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。