Python | sympy.Derivative() method
With the help of sympy.Derivative() method, we can create an unevaluated derivative of a SymPy expression. It has the same syntax as diff() method. To evaluate an unevaluated derivative, use the doit() method.
Syntax: Derivative(expression, reference variable)
Parameters:
expression – A SymPy expression whose unevaluated derivative is found.
reference variable – Variable with respect to which derivative is found.
Returns: Returns an unevaluated derivative of the given expression.
Example #1:
# import sympy from sympy import * x, y = symbols('x y') expr = x**2 + 2 * y + y**3print("Expression : {} ".format(expr)) # Use sympy.Derivative() method expr_diff = Derivative(expr, x) print("Derivative of expression with respect to x : {}".format(expr_diff)) print("Value of the derivative : {} ".format(expr_diff.doit())) |
Output:
Expression : x**2 + y**3 + 2*y Derivative of expression with respect to x : Derivative(x**2 + y**3 + 2*y, x) Value of the derivative : 2*x
Example #2:
# import sympy from sympy import * x, y = symbols('x y') expr = y**2 * x**2 + 2 * y*x + x**3 * y**3print("Expression : {} ".format(expr)) # Use sympy.Derivative() method expr_diff = Derivative(expr, x, y) print("Derivative of expression with respect to x : {}".format(expr_diff)) print("Value of the derivative : {} ".format(expr_diff.doit())) |
Output:
Expression : x**3*y**3 + x**2*y**2 + 2*x*y Derivative of expression with respect to x : Derivative(x**3*y**3 + x**2*y**2 + 2*x*y, x, y) Value of the derivative : 9*x**2*y**2 + 4*x*y + 2
Recommended Posts:
- class method vs static method in Python
- Python | next() method
- Python | set() method
- Python | os.dup() method
- Python | os.getenv() method
- Python | Tensorflow log() method
- Python | os.readv() method
- Python | os.writev() method
- Python | os.readlink() method
- Python | os.getlogin() method
- Python | sys.getrecursionlimit() method
- Python | sys.getdefaultencoding() method
- Python | os.read() method
- Python | sys.setrecursionlimit() method
- Python | sympy.det() 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 contribute@geeksforgeeks.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.



