Thursday, July 4, 2024
HomeLanguagesPythonPython | sympy.Lambda() method

Python | sympy.Lambda() method

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

Calisto Chipfumbu
Calisto Chipfumbuhttp://cchipfumbu@gmail.com
I have 5 years' worth of experience in the IT industry, primarily focused on Linux and Database administration. In those years, apart from learning significant technical knowledge, I also became comfortable working in a professional team and adapting to my environment, as I switched through 3 roles in that time.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments