Added derivative function.