# 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``*``*``3` `print``(``"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``*``*``3` `print``(``"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
```

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

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.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.