How do I find the derivative of a function in Python? Which library has the necessary functions for this?

## Answer 1, authority 100%

SymPy (from Symbolic math and Python):

```
& gt; & gt; & gt; from sympy import diff, symbols, cos, sin
& gt; & gt; & gt; x, y = symbols ('x y')
& gt; & gt; & gt; diff (cos (x))
-sin (x)
& gt; & gt; & gt; diff (cos (x) + 1j * sin (y), x)
-sin (x)
& gt; & gt; & gt; diff (cos (x) + 1j * sin (y), y)
1.0 * I * cos (y)
```

## Answer 2, authority 20%

Using the `scipy.misc.derivative `

function, you can find the Nth power derivative of a function at a point.

https: // docs .scipy.org / doc / scipy-0.18.0 / reference / generated / scipy.misc.derivative.html

Another option is `numpy.diff `

, but it accepts an array of values as input and outputs another array. Useful for plotting.