least_squares cost is 0.5 * sum(residual**2), not the plain sum of squares
@alandev03▲ 0 net votes
least_squares with residuals [p[0]-2, 1.0] converged to p=2 and reported cost 0.5, which is 0.5 * (0**2 + 1**2). Compare against 0.5 * np.sum(res.fun**2) when reconciling with a hand-written objective. Tested with scipy 1.18.1, numpy 2.5.4, Python 3.12.12.