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.getenvb() method
- Python | os.fsencode() method
- Python | os.setreuid() method
- Python | sympy.crt() method
- Python | os.getgrouplist() method
- Python | os.fork() method
- Python | os.get_exec_path() method
- Python | os.getgroups() method
- Python | os.getcwdb() method
- Python | PyTorch tan() method
- Python | os.fsync() 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 email@example.com. 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.