Python | sympy.lambdify() method Last Updated : 25 Jun, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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) Parameters: 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. Example #1: In this example we can see that by using sympy.lambdify() method, we can get a lambda function from a mathematical expression. Python3 1== # import sympy from sympy import * x = symbols('x') expr = sin(x) # Use sympy.lambdify() method f = lambdify(x, expr, "math") print("Using lambda function in SymPy to evaluate sin(90) : {}".format(f(90))) Output: Using lambda function in SymPy to evaluate sin(90) : 0.893996663601 Example #2: We can pass a dictionary of sympy_name:numerical_function pair to use lambdify with numerical libraries that it does not know about. Python3 1== # import sympy from sympy import * def squared(n) : return n**2 x = symbols('x') expr = x**2 # Use sympy.lambdify() method f = lambdify(x, expr, {"**" : squared}) print("Using lambda function in SymPy to evaluate squared function : {}".format(f(10))) Output: Using lambda function in SymPy to evaluate squared function : 100 Comment More infoAdvertise with us Next Article Python | sympy.Add() method R rupesh_rao Follow Improve Article Tags : Python SymPy Practice Tags : python Similar Reads 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 1 min read Python | sympy.lcm() method With the help of sympy.lcm() method, we can find the least common multiple of two numbers that is passed as a parameter in the sympy.lcm() method. Syntax : sympy.lcm(var1, var2) Return : Return value of least common multiple. Example #1 : In this example we can see that by using sympy.lcm() method, 1 min read Python | sympy.lcm() method The function lcm() provides the direct way to compute Least Common Multiple for polynomials.That is, for polynomials f and g, it computes LCM. Syntax: sympy.lcm(f, g) Return: LCM of given polynomials Example #1: Python3 1== # import sympy from sympy import * f = x * y**2 + x**2 * y g = x**2 * y**2 # 1 min read Python | sympy.Add() method With the help of sympy.Add() method, we can add two variables and can form a mathematical expression by using sympy.Add() method. Syntax : sympy.Add() Return : Return the addition of two variables. Example #1 : In this example we can see that by using sympy.Add() method, we are able to add the two v 1 min read Python | sympy.Add() method With the help of sympy.Add() method, we can add the two variables and can form a mathematical expression by using sympy.Add() method. Syntax : sympy.Add() Return : Return the addition of two variables. Example #1 : In this example we can see that by using sympy.Add() method, we are able to add the n 1 min read Python | sympy.evalf() method With the help of sympy.evalf() method, we are able to evaluate the mathematical expressions. Syntax : sympy.evalf() Return : Return the evaluated mathematical expression. Example #1 : In this example we can see that by using sympy.evalf() method, we are able to evaluate the mathematical expressions. 1 min read Like