Friday, January 10, 2025
Google search engine
HomeLanguagesPython | sympy.find() method

Python | sympy.find() method

Using the find() method in sympy module, we can find the mathematical function’s subexpression (if it exists). find() method returns the subexpression in the mathematical function.

Syntax : sympy.find(x)

Return : returns subexpression 

Code #1: With the help of the below examples, we can clearly understand that using sympy.find() method we can count the subexpression from the given expression. 

Python3




# importing sympy library
from sympy import *
 
# taking symbols
x, y, z = symbols('x y z')
 
# calling find() method on expression
geek = (3 * x + log(3 * x) + sqrt((x + 1)**2 + x)).find(log)
print(geek)


Output: 

{log(3*x)}

  Code #2: 

Python3




# importing sympy library
from sympy import *
 
# taking symbols
a, b = symbols('a b')
 
# calling find() method on expression
geek = (3 * a + b * log(a) + log(b) + log(a)*log(1 / b)).find(log)
print(geek)


Output: 

{log(a), log(1/b), log(b)}

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