Python | sympy.find() method

Using the find() method in simpy module, we can find the subexpression (if exists) in the mathematical function. find() method returns the subexpression in the mathematical function.

Syntax : sympy.find(x)

Return : returns subexpression 

Code #1:

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

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

set([log(3*x)])

 
Code #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

set([log(a), log(1/b), log(b)])


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.