diff --git a/matlab/trust_region.m b/matlab/trust_region.m index 804ba7ce097d13f0fac4c806bb9b67817c1f7bac..1edb87732c000b535ed78715082555aba0d73640 100644 --- a/matlab/trust_region.m +++ b/matlab/trust_region.m @@ -181,6 +181,7 @@ while (niter < maxiter && ~info) % FIXME -- why tolf*n*xn? If abs (e) ~ abs(x) * eps is a vector % of perturbations of x, then norm (fjac*e) <= eps*n*xn, i.e. by % tolf ~ eps we demand as much accuracy as we can expect. + disp([niter fn ratio]) if (fn <= tolf*n*xn) info = 1; % The following tests done only after successful step. @@ -228,7 +229,7 @@ if (xn > delta) bn = norm (b); dxn = delta/xn; snmd = snm/delta; t = (bn/sn) * (bn/xn) * snmd; - t = t - dxn * snmd^2 - sqrt ((t-dxn)^2 + (1-dxn^2)*(1-snmd^2)); + t = t - dxn * snmd^2 + sqrt ((t-dxn)^2 + (1-dxn^2)*(1-snmd^2)); alpha = dxn*(1-snmd^2) / t; else alpha = 0;