![]() |
VOOZH | about |
In this article, we will learn how to compute derivatives using NumPy. Generally, NumPy does not provide any robust function to compute the derivatives of different polynomials. However, NumPy can compute the special cases of one-dimensional polynomials using the functions numpy.poly1d() and deriv().
Below are some examples where we compute the derivative of some expressions using NumPy. Here we are taking the expression in variable 'var' and differentiating it with respect to 'x'.
Example 1:
Output:
👁 ImageExample 2:
Output:
👁 ImageExample 3:
Output:
👁 ImageTo calculate double derivative we can simply use the deriv() function twice.
Example 4: