Saturday, October 5, 2024
Google search engine
HomeLanguagesPython | 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}

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments