Nonlinear least squares
Compare Levenberg–Marquardt on an exponential fit and Powell dogleg on NIST’s BoxBOD regression problem.
Levenberg–Marquardt
Basin 3.4.0 and levenberg-marquardt 0.15.0 jointly fit 16 exponential response curves. Each curve has an amplitude and a decay rate, giving 32 parameters. Each has 256 exact observations at evenly spaced times in , giving 4,096 residuals. For curve , the true parameters are and . Every pair starts at .
Both use nalgebra 0.34.2, the same analytic Jacobian, column scaling, pivoted QR, and an initial scaled step-bound factor of 100. Although curves have separate parameters, the harness supplies a single dense Jacobian and both libraries solve the complete dense least-squares system. This tests the dense QR path, rather than a specialized solver that exploits the blocks.
Function-reduction, orthogonality, and scaled-radius tolerances are 30 times f64 machine epsilon, about . Basin uses trust-region damping and disables its absolute-gradient and unscaled-step checks. Both have a 330-residual-call budget; Basin also has a 200-iteration safety cap.
Returned solutions and evaluation counts
basin: SolverConverged. Independent accuracy check passed. Returned (100000, -1.00000, 101000, -1.02000, 102000, -1.04000, …), objective 0.000e+0. 7 residual and 6 Jacobian calls.
LM crate: ResidualsZero. Independent accuracy check passed. Returned (100000, -1.00000, 101000, -1.02000, 102000, -1.04000, …), objective 0.000e+0. 7 residual and 6 Jacobian calls.
The curve records the best objective seen at residual evaluations, including rejected trials. Internal damping searches and acceptance rules still differ from the reference's MINPACK path.
Powell dogleg on NIST least squares
The plot shows the first published start for BoxBOD, one of the 27 NIST Statistical Reference Datasets for nonlinear regression. All three configurations use the same residuals and analytic Jacobian, with f64 and nalgebra 0.34.
Basin's dogleg uses the Gauss–Newton least-squares model, with Cholesky on and a Cauchy step if the solve fails. The dogleg 0.1.1 crate uses an SVD of the Jacobian. The unscaled configuration shares Basin's Euclidean trust region and initial radius of 1. The default configuration uses the crate's own scaling and initial radius. Each implementation applies its own acceptance and stopping rules.
- Basin dogleg
- dogleg unscaled
- dogleg default