implemented 2nd order differentiation