Wednesday, July 3, 2024
HomeLanguagesPythonPython | sympy.atoms() method

Python | sympy.atoms() method

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.




# 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 :




# 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}

Calisto Chipfumbu
Calisto Chipfumbuhttp://cchipfumbu@gmail.com
I have 5 years' worth of experience in the IT industry, primarily focused on Linux and Database administration. In those years, apart from learning significant technical knowledge, I also became comfortable working in a professional team and adapting to my environment, as I switched through 3 roles in that time.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments