Writing the Derivative Function