# Calculate Derivative Functions in Python

In this tutorial, we will learn about Derivative function, the rate of change of a quantity y with respect to another quantity x is called the derivative or differential coefficient of y with respect to x. Also, we will see how to calculate derivative functions in Python.

The process of finding a derivative of a function is Known as differentiation. The fundamental theorem states that anti-discrimination is similar to integration. Differentiation is also known as the process to find the rate of change. After that, the Derivative tells us the slope of the function at any point.

Note: we know that f ‘(x) said that “f is prime of x”

### Important notes:

A function is different if it is derived everywhere in its domain. It should be continuous and smooth. Functions on closed intervals must have one-sided derivatives defined at the endpoints.

‘dx’ does not mean that d times x  and  ‘dy’ does not mean that d times y.

dy/dx does not mean dy/ dx.

### The average rate of change:

The Average Rate of Change Formula calculates the slope of a line or a curve on a given range.

A(x) = f(b)-f(a) /(b-a)

### Rules of Derivatives:

1- If f(x)=c, where c is constant,then f ‘(x)=0

2-If f(x)=x^n,where n is real number, then f ‘(x) =n x^n-1

3- So the Product rule is: Suppose  the function  u=f(x) and v=g(x) Then, d(uv)/dx =udv/dx+vdu/dx

## Application of partial derivative:

Derivatives in chemistry: One use of derivatives in chemistry is when we want to Solve that the concentration of an element in a product.

So the Syntax:

Derivative(expression, reference variable)

Command install:

pip install sympy

```# import sympy
from sympy import *

x, y = symbols('x y')
expr = x**2 + 10 * y + y**3
print("Expression : {} ".format(expr))

# Use sympy.Derivative() method
expr_diff = Derivative(expr, x)

Print ("Etymology of expression with respect to x: {}". Format. (Expr_diff)
print("Value of the derivative : {} ".format(expr_diff.doit()))
```

Result:

```Expression : x**2 + y**3 + 10*y
Derivative of expression with respect to x : Derivative(x**2 + y**3 + 10*y, x)
Value of the derivative : 2*x
Derivative of expression with respect to y : Derivative(x**2 + y**3 + 10*y, y)
Value of the derivative : 3y^2+10

```
```# 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 ("Etymology 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**13+x**12*y**2+2*x*y,x,y) Value of the derivative : 9*x**2*y**2+4*x*y+2                                           ** denotes power function`

### Find the n-th derivative of a function at a given point

The formula for the nth derivative of the function would be f (x) = \ frac {1} {x}:

f ^ n (x) = (- 1) ^ n \ frac {n!} {x ^ {n + 1}}

```SYNTAX:
scipy.misc.derivative(func,x2,dx1=1.0,n=1,args=(),order=3)

Parameters
func: function input function.
n: int, alternate order of derivation.Its default Value is 1.
Args: tuple, alternative logic
The command: int, to use optional digits, must be odd.```

```from sympy import Symbol, Derivative

x= Symbol('x')

function= x**4 + 7*x**3 + 8

deriv= Derivative(function, x)
deriv.doit()

```

Output:

`4*x**3 + 21*x**2`
```from sympy import Symbol, Derivative

x= Symbol('x')

function= x**4 + 7*x**3 + 8

deriv= Derivative(function, x)
deriv.doit().subs({x:4})

```
`Output:  592`