With the help of sympy.as_ordered_terms()
method, we can get the terms ordered by variables by using sympy.as_ordered_terms()
method.
Syntax :
sympy.as_ordered_terms()
Return : Return ordered terms in mathematical expression.
Example #1 :
In this example we can see that by using sympy.as_ordered_terms()
method, we are able to get the terms of mathematical expression.
# import sympy from sympy import * x, y = symbols( 'x y' ) # Use sympy.as_ordered_terms() method gfg = (x * * 2 + 2 * x * y + y * * 2 ).as_ordered_terms() print (gfg) |
Output :
[x**2, 2*x*y, y**2]
Example #2 :
# import sympy from sympy import * x, y = symbols( 'x y' ) # Use sympy.as_ordered_terms() method gfg = (y + x).as_ordered_terms() print (gfg) |
Output :
[x, y]