From the definition of the derivative we can generalize rules for different kinds of functions. You may look these derivatives up in a table or, as shown here, use a symbolic computing library. I demonstrate this with Python and the wonderful SymPy library.