From fe7d05f46afe4d81e3c0da3908e66f878f0f89fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Ry=C3=BBk=29?= <stepan@adjemian.eu> Date: Mon, 4 Apr 2022 16:25:20 +0200 Subject: [PATCH] Remove unnecessary condition (Octave/fsolve). Since we already have checked that the initial guess is not a solution. --- matlab/dynare_solve.m | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/matlab/dynare_solve.m b/matlab/dynare_solve.m index 3fc01cc80c..ff2be72f97 100644 --- a/matlab/dynare_solve.m +++ b/matlab/dynare_solve.m @@ -181,7 +181,7 @@ if options.solve_algo == 0 error('You can''t use solve_algo=0 since you don''t have MATLAB''s Optimization Toolbox') end end - options4fsolve=optimset('fsolve'); + options4fsolve = optimset('fsolve'); options4fsolve.MaxFunEvals = 50000; options4fsolve.MaxIter = maxit; options4fsolve.TolFun = tolf; @@ -205,13 +205,7 @@ if options.solve_algo == 0 f2 = f; end f = @(x) f2(x, arguments{:}); - % The Octave version of fsolve does not converge when it starts from the solution - fvec = feval(f, x); - if max(abs(fvec)) >= tolf - [x, ~, exitflag] = fsolve(f, x, options4fsolve); - else - exitflag = 3; - end + [x, ~, exitflag] = fsolve(f, x, options4fsolve); end if exitflag == 1 errorflag = false; -- GitLab