The Wayback Machine - https://web.archive.org/web/20220905082334/https://www.geeksforgeeks.org/python-sympy-lambda-method/
Skip to content
Related Articles

Related Articles

Python | sympy.Lambda() method

View Discussion
Improve Article
Save Article
  • Last Updated : 17 Jul, 2019
View Discussion
Improve Article
Save Article

With the help of sympy.Lambda() method, we can perform any mathematical operation by just defining the formula and then pass the parameters with reference variable by using sympy.Lambda().

Syntax : sympy.Lambda()
Return : Return the result of mathematical formula.

Example #1 :
In this example we can see that we are able to perform any mathematical operation by using sympy.Lambda() method.




# import sympy
from sympy import *
  
# Use sympy.Lambda() method
x = symbols('x')
gfg = Lambda(x, x + 1)
  
print(gfg(9))

Output :

10

Example #2 :




# import sympy
from sympy import *
  
# Use sympy.Lambda() method
x, y = symbols('x y')
gfg = Lambda((x, y), x * y)
  
print(gfg(9, 5))

Output :

45

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!