Fix derivative floating point bug