Implemented first_order_difference function