Python | sympy.apart() method
With the help of sympy.apart() method, we are able to do a partial fraction decomposition of a rational function and put it into a standard canonical form i.e p/q.
Syntax :
sympy.apart()
Return : Return the partial fraction decomposition of rational function.
Example #1 :
In the given example, we can see that by using sympy.apart() method, we can do the partial fraction of rational function.
# import sympy from sympy import * x, y, z = symbols('x y z') gfg_exp = (x**2 + 2 * x + 1)/(x**2 + x) # Using sympy.apart() method gfg_exp = apart(gfg_exp) print(gfg_exp) |
Output :
1 + 1/x
Example #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.apart() method gfg_exp = apart(gfg_exp) print(gfg_exp) |
Output :
3/2 + 4/(x – 4) + 1/x
Recommended Posts:
- class method vs static method in Python
- Python | os.dup() method
- Python | next() method
- Python | set() method
- Python | sympy RGS method
- Python PIL | UnsahrpMask() method
- Python | sys.getswitchinterval() method
- Python | sys.setswitchinterval() method
- Python | os.symlink() method
- Python | os.link() method
- Python | os.mkfifo() method
- Python | hasattr() method
- Python | os.fsync() method
- Python | os.times() method
- Python PIL | Image.new() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



