Discrete derivative function implemented