Python | sympy.as_coeff_add() method
Last Updated :
26 Jul, 2019
With the help of sympy.as_coeff_add()
method, we can separate the mathematical expression by + sign and return a tuple by using sympy.as_coeff_add()
method.
Syntax : sympy.as_coeff_add()
Return : Return the tuple of elements separated by + sign.
Example #1 :
In this example we can see that by using sympy.as_coeff_add()
method, we are able to get the tuple of elements separated by + sign.
from sympy import *
x, y = symbols( 'x y' )
gfg = (x + 2 * y).as_coeff_add()
print (gfg)
|
Output :
(0, (x, 2*y))
Example #2 :
from sympy import *
x, y = symbols( 'x y' )
gfg = (x * * 2 + 4 * x + 4 ).as_coeff_add()
print (gfg)
|
Output :
(4, (x**2, 4*x))
Share your thoughts in the comments
Please Login to comment...