| 1 |
function [fval, fjac] = wood(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 |
C3 = 200; |
| 21 |
C4 = 20.2; |
| 22 |
C5 = 19.8; |
| 23 |
C6 = 180.0; |
| 24 |
|
| 25 |
if nargin==1 |
| 26 |
fval = zeros(4, 1); |
| 27 |
tmp1 = x(2)-x(1)*x(1); |
| 28 |
tmp2 = x(4)-x(3)*x(3); |
| 29 |
fval(1) = -C3*x(1)*tmp1-(1-x(1)); |
| 30 |
fval(2) = C3*tmp1+C4*(x(2)-1.0)+C5*(x(4)-1); |
| 31 |
fval(3) = -C6*x(3)*tmp2-(1-x(3)); |
| 32 |
fval(4) = C6*tmp2+C4*(x(4)-1)+C5*(x(2)-1); |
| 33 |
if nargout>1 |
| 34 |
fjac = zeros(4); |
| 35 |
tmp1 = x(2)-3*x(1)*x(1); |
| 36 |
tmp2 = x(4)-3*x(3)*x(3); |
| 37 |
fjac(1,1) = -C3*tmp1+1; |
| 38 |
fjac(1,2) = -C3*x(1); |
| 39 |
fjac(2,1) = -2*C3*x(1); |
| 40 |
fjac(2,2) = C3+C4; |
| 41 |
fjac(2,4) = C5; |
| 42 |
fjac(3,3) = -C6*tmp2+1; |
| 43 |
fjac(3,4) = -C6*x(3); |
| 44 |
fjac(4,2) = C5; |
| 45 |
fjac(4,3) = -2*C6*x(3); |
| 46 |
fjac(4,4) = C6+C4; |
| 47 |
end |
| 48 |
elseif ~nargin |
| 49 |
if nargout==1 |
| 50 |
fval = [-3; -1; -3; -1]; |
| 51 |
else |
| 52 |
error('One output is required for initialization mode.') |
| 53 |
end |
| 54 |
else |
| 55 |
error('Wrong number of input arguments.') |
| 56 |
end |