Python | sympy.as_coeff_add() method

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.



filter_none

edit
close

play_arrow

link
brightness_4
code

# import sympy
from sympy import * 
  
x, y = symbols('x y')
  
# Using sympy.as_coeff_add() method
gfg = (x + 2 * y).as_coeff_add()
  
print(gfg)

chevron_right


Output :

(0, (x, 2*y))

Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

# import sympy
from sympy import * 
  
x, y = symbols('x y')
  
# Using sympy.as_coeff_add() method
gfg = (x**2 + 4 * x + 4).as_coeff_add()
  
print(gfg)

chevron_right


Output :

(4, (x**2, 4*x))



My Personal Notes arrow_drop_up

Recommended Posts:



    Article Tags :

    Be the First to upvote.


    Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.