Debian Codegraph @

tests/solver-test-functions/powell2.m

raw
1 function [fval, fjac] = powell2(x)
2
3 % Copyright © 2021 Dynare Team
4 %
5 % This file is part of Dynare.
6 %
7 % Dynare is free software: you can redistribute it and/or modify
8 % it under the terms of the GNU General Public License as published by
9 % the Free Software Foundation, either version 3 of the License, or
10 % (at your option) any later version.
11 %
12 % Dynare is distributed in the hope that it will be useful,
13 % but WITHOUT ANY WARRANTY; without even the implied warranty of
14 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 % GNU General Public License for more details.
16 %
17 % You should have received a copy of the GNU General Public License
18 % along with Dynare. If not, see <https://www.gnu.org/licenses/>.
19
20 if nargin==1
21 fval = zeros(2, 1);
22 fval(1) = 10000*x(1)*x(2)-1;
23 fval(2) = exp(-x(1))+exp(-x(2))-1.0001;
24 if nargout>1
25 fjac = zeros(2);
26 fjac(1,1) = 10000*x(2);
27 fjac(1,2) = 10000*x(1);
28 fjac(2,1) = -exp(x(1));
29 fjac(2,2) = -exp(x(2));
30 end
31 elseif ~nargin
32 if nargout==1
33 fval = [0; 1];
34 else
35 error('One output is required for initialization mode.')
36 end
37 else
38 error('Wrong number of input arguments.')
39 end