Takes the derivative of a variety of functions - Java