Open In App

Python | sympy.Function() method

With the help of sympy.Function() method, we can find the various functions in the whole mathematical expression like f(x), sin(x), log(x), etc by using sympy.Function() method.

Syntax : sympy.Function()
Return : Return the list of functions in mathematical operation.



Example #1 :
In this example we can see that by using sympy.Function() method, we are able to find the function in the mathematical operation.




# import sympy
from sympy import * 
  
x, y = symbols('x y')
f = Function('f')
  
# Use sympy.Function() method
gfg = (f(x) + 2 * tan(y + I * pi) + log(2 * x)).atoms(Function)
    
print(gfg)

Output :

{f(x), tan(y + I*pi), log(2*x)}



Example #2 :




# import sympy
from sympy import * 
  
x, y = symbols('x y')
f = Function('f')
  
# Use sympy.Function() method
gfg = (2 + 3 * cos(y) + 5 * log(2 * x)).atoms(Function)
    
print(gfg)

Output :

{cos(y), log(2*x)}

Article Tags :