corrected deriv function (was correct at some time earlier; must have
forgotten to pull...)