added a function to calculate the derivatives of the outputs with respect to the inputs