How to find derivative function in Python? Which library has the necessary functions for this?

2 answers 2

SymPy (from the words Symbolic math and Python):

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

    Using the scipy.misc.derivative function, scipy.misc.derivative can find the derivative of the Nth power 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 there an array of values ​​is taken as input and another array is given as output. Useful for plotting graphs.