add derivative function