updated fvar so if value is NaN, then derivative is set to NaN