With the help of sympy.lambdify() method, we can convert a SymPy expression to an expression that can be numerically evaluated. lambdify acts like a lambda function, except it, converts the SymPy names to the names of the given numerical library, usually NumPy or math.
Syntax: lambdify(variable, expression, library)
variable – It is the variable in the mathematical expression.
expression – It is the mathematical expression which is converted into its respective name in the given library.
library – It is the Python library to which expression is to be converted into.
Returns: Returns a lambda function which can evaluate a mathematical expression.
In this example we can see that by using sympy.lambdify() method, we can get a lambda function from a mathematical expression.
Using lambda function in SymPy to evaluate sin(90) : 0.893996663601
We can pass a dictionary of sympy_name:numerical_function pair to use lambdify with numerical libraries that it does not know about.
Using lambda function in SymPy to evaluate squared function : 100
- class method vs static method in Python
- Python | os.dup() method
- Python | set() method
- Python | next() method
- Python | os.nice() method
- Python | os.pipe() method
- Python | os.fork() method
- Python | os.getgrouplist() method
- Python | os.getsid() method
- Python | os.WIFCONTINUED() method
- Python | os.WIFSTOPPED() method
- Python | os.WTERMSIG() method
- Python | os.WCOREDUMP() method
- Python | os.getpgrp() method
- Python | os.pwrite() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.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.