Rewrite and fix previous_residual_norm calculations in Newton.