Open In App

Python | sympy.atoms() method

Last Updated : 19 Jul, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
With the help of sympy.atoms() method, we can extract the atomic values of the mathematical function like any numbers, symbols, iota and etc, by using sympy.atoms().
Syntax : sympy.atoms() Return : Return the atomic values from mathematical expression.
Example #1 : In this example we can see that we are able to get the atomic values any mathematical operation by using sympy.atoms() method. Python3 1=1
# import sympy
from sympy import *

# Use sympy.atoms() method
x = symbols('x')
gfg = (2 + x + 7 * tan(x + I * pi)).atoms(Number)

print(gfg)
Output :
{2, 7}
Example #2 : Python3 1=1
# import sympy
from sympy import *

# Use sympy.atoms() method
x = symbols('x')
gfg = (2 + x + 7 * log(x + I * pi)).atoms(Number, Symbol, NumberSymbol)

print(gfg)
Output :
{pi, 2, x, 7}

Article Tags :
Practice Tags :

Similar Reads