Actually, You have 4 options
- Finite Differences
- Symbolic Differentiation
- Automatic Derivatives
- Compute derivatives by hand
Look at the example using SymPy
In [1]: from sympy import *
In [2]: import numpy as np
In [3]: x = Symbol('x')
In [4]: y = x**2 + 1
In [5]: yprime = y.diff(x)
In [6]: yprime
Out[6]: 2⋅x
In [7]: f = lambdify(x, yprime, 'numpy')
In [8]: f(np.ones(5))
Out[8]: [ 2. 2. 2. 2. 2.]
Want to learn python to get expertise in the concepts of python? Join python certification course and get certified
To know more about this you can have a look at the following video tutorial:-