function [residual, g1, g2, g3] = Multibis_static(y, x, params)
%
% Status : Computes static model for Dynare
%
% Inputs : 
%   y         [M_.endo_nbr by 1] double    vector of endogenous variables in declaration order
%   x         [M_.exo_nbr by 1] double     vector of exogenous variables in declaration order
%   params    [M_.param_nbr by 1] double   vector of parameter values in declaration order
%
% Outputs:
%   residual  [M_.endo_nbr by 1] double    vector of residuals of the static model equations 
%                                          in order of declaration of the equations.
%                                          Dynare may prepend or append auxiliary equations, see M_.aux_vars
%   g1        [M_.endo_nbr by M_.endo_nbr] double    Jacobian matrix of the static model equations;
%                                                       columns: variables in declaration order
%                                                       rows: equations in order of declaration
%   g2        [M_.endo_nbr by (M_.endo_nbr)^2] double   Hessian matrix of the static model equations;
%                                                       columns: variables in declaration order
%                                                       rows: equations in order of declaration
%   g3        [M_.endo_nbr by (M_.endo_nbr)^3] double   Third derivatives matrix of the static model equations;
%                                                       columns: variables in declaration order
%                                                       rows: equations in order of declaration
%
%
% Warning : this file is generated automatically by Dynare
%           from model file (.mod)

residual = zeros( 20, 1);

%
% Model equations
%

T19 = params(1)*y(7)^(1-params(12))+params(2)*y(8)^(1-params(12));
T21 = T19^(1/(1-params(12)));
T25 = params(1)*(y(7)/T21)^(-params(12));
T27 = params(1)^(1/params(12));
T29 = (params(12)-1)/params(12);
T32 = params(2)^(1/params(12));
T36 = T27*y(13)^T29+T32*y(14)^T29;
T38 = T36^(params(12)/(params(12)-1));
T43 = params(2)*(y(8)/T21)^(-params(12));
T50 = (1+params(11))/params(11);
T54 = y(5)^T50+y(6)^T50;
T56 = T54^(params(11)/(1+params(11)));
T58 = 1/params(11);
T59 = (y(5)/T56)^T58;
T63 = y(1)^(1+params(11))+y(2)^(1+params(11));
T65 = T63^(1/(1+params(11)));
T69 = (y(6)/T56)^T58;
T143 = y(11)^params(7);
T144 = y(9)*T143;
T145 = y(1)^params(9);
T147 = y(17)^params(3);
T149 = y(19)^params(5);
T153 = y(12)^params(8);
T154 = y(10)*T153;
T155 = y(2)^params(10);
T157 = y(18)^params(4);
T159 = y(20)^params(6);
lhs =y(13);
rhs =T25*T38;
residual(1)= lhs-rhs;
lhs =y(14);
rhs =T38*T43;
residual(2)= lhs-rhs;
lhs =y(1);
rhs =T59*T65;
residual(3)= lhs-rhs;
lhs =y(2);
rhs =T65*T69;
residual(4)= lhs-rhs;
lhs =y(1);
rhs =params(9)*y(7)/y(5)*y(3);
residual(5)= lhs-rhs;
lhs =y(2);
rhs =params(10)*y(8)/y(6)*y(4);
residual(6)= lhs-rhs;
lhs =y(17);
rhs =y(3)*params(3);
residual(7)= lhs-rhs;
lhs =y(19);
rhs =y(3)*params(5)*y(7)/y(8);
residual(8)= lhs-rhs;
lhs =y(20);
rhs =y(4)*params(6)*y(8)/y(7);
residual(9)= lhs-rhs;
lhs =y(18);
rhs =y(4)*params(4);
residual(10)= lhs-rhs;
lhs =y(11);
rhs =y(3)*y(7)*params(16)*params(7)/(y(7)-y(7)*params(16)*(1-params(17)));
residual(11)= lhs-rhs;
lhs =y(12);
rhs =y(4)*y(8)*params(16)*params(8)/(y(8)-y(8)*params(16)*(1-params(17)));
residual(12)= lhs-rhs;
lhs =y(11);
rhs =y(15)+y(11)*(1-params(17));
residual(13)= lhs-rhs;
lhs =y(12);
rhs =y(16)+(1-params(17))*y(12);
residual(14)= lhs-rhs;
lhs =y(3);
rhs =y(20)+y(17)+y(13)+y(15);
residual(15)= lhs-rhs;
lhs =y(4);
rhs =y(19)+y(18)+y(14)+y(16);
residual(16)= lhs-rhs;
lhs =y(3);
rhs =T144*T145*T147*T149;
residual(17)= lhs-rhs;
lhs =y(4);
rhs =T154*T155*T157*T159;
residual(18)= lhs-rhs;
lhs =log(y(9));
rhs =log(y(9))*params(15)+x(1);
residual(19)= lhs-rhs;
lhs =log(y(10));
rhs =params(15)*log(y(10))+x(2);
residual(20)= lhs-rhs;
if ~isreal(residual)
  residual = real(residual)+imag(residual).^2;
end
if nargout >= 2,
  g1 = zeros(20, 20);

  %
  % Jacobian matrix
  %

T174 = getPowerDeriv(T63,1/(1+params(11)),1);
T175 = getPowerDeriv(y(1),1+params(11),1)*T174;
T186 = T174*getPowerDeriv(y(2),1+params(11),1);
T207 = getPowerDeriv(T54,params(11)/(1+params(11)),1);
T208 = getPowerDeriv(y(5),T50,1)*T207;
T213 = getPowerDeriv(y(5)/T56,T58,1);
T220 = getPowerDeriv(y(6)/T56,T58,1);
T231 = T207*getPowerDeriv(y(6),T50,1);
T252 = getPowerDeriv(T19,1/(1-params(12)),1);
T253 = params(1)*getPowerDeriv(y(7),1-params(12),1)*T252;
T258 = getPowerDeriv(y(7)/T21,(-params(12)),1);
T266 = getPowerDeriv(y(8)/T21,(-params(12)),1);
T294 = T252*params(2)*getPowerDeriv(y(8),1-params(12),1);
T358 = getPowerDeriv(T36,params(12)/(params(12)-1),1);
T359 = T27*getPowerDeriv(y(13),T29,1)*T358;
T366 = T358*T32*getPowerDeriv(y(14),T29,1);
  g1(1,7)=(-(T38*params(1)*(T21-y(7)*T253)/(T21*T21)*T258));
  g1(1,8)=(-(T38*params(1)*T258*(-(y(7)*T294))/(T21*T21)));
  g1(1,13)=1-T25*T359;
  g1(1,14)=(-(T25*T366));
  g1(2,7)=(-(T38*params(2)*(-(y(8)*T253))/(T21*T21)*T266));
  g1(2,8)=(-(T38*params(2)*T266*(T21-y(8)*T294)/(T21*T21)));
  g1(2,13)=(-(T43*T359));
  g1(2,14)=1-T43*T366;
  g1(3,1)=1-T59*T175;
  g1(3,2)=(-(T59*T186));
  g1(3,5)=(-(T65*(T56-y(5)*T208)/(T56*T56)*T213));
  g1(3,6)=(-(T65*T213*(-(y(5)*T231))/(T56*T56)));
  g1(4,1)=(-(T69*T175));
  g1(4,2)=1-T69*T186;
  g1(4,5)=(-(T65*(-(y(6)*T208))/(T56*T56)*T220));
  g1(4,6)=(-(T65*T220*(T56-y(6)*T231)/(T56*T56)));
  g1(5,1)=1;
  g1(5,3)=(-(params(9)*y(7)/y(5)));
  g1(5,5)=(-(y(3)*params(9)*(-y(7))/(y(5)*y(5))));
  g1(5,7)=(-(y(3)*params(9)*1/y(5)));
  g1(6,2)=1;
  g1(6,4)=(-(params(10)*y(8)/y(6)));
  g1(6,6)=(-(y(4)*params(10)*(-y(8))/(y(6)*y(6))));
  g1(6,8)=(-(y(4)*params(10)*1/y(6)));
  g1(7,3)=(-params(3));
  g1(7,17)=1;
  g1(8,3)=(-(params(5)*y(7)/y(8)));
  g1(8,7)=(-(y(3)*params(5)*1/y(8)));
  g1(8,8)=(-(y(3)*params(5)*(-y(7))/(y(8)*y(8))));
  g1(8,19)=1;
  g1(9,4)=(-(params(6)*y(8)/y(7)));
  g1(9,7)=(-(y(4)*params(6)*(-y(8))/(y(7)*y(7))));
  g1(9,8)=(-(y(4)*params(6)*1/y(7)));
  g1(9,20)=1;
  g1(10,4)=(-params(4));
  g1(10,18)=1;
  g1(11,3)=(-(y(7)*params(16)*params(7)/(y(7)-y(7)*params(16)*(1-params(17)))));
  g1(11,7)=(-(((y(7)-y(7)*params(16)*(1-params(17)))*y(3)*params(16)*params(7)-y(3)*y(7)*params(16)*params(7)*(1-params(16)*(1-params(17))))/((y(7)-y(7)*params(16)*(1-params(17)))*(y(7)-y(7)*params(16)*(1-params(17))))));
  g1(11,11)=1;
  g1(12,4)=(-(y(8)*params(16)*params(8)/(y(8)-y(8)*params(16)*(1-params(17)))));
  g1(12,8)=(-(((y(8)-y(8)*params(16)*(1-params(17)))*y(4)*params(16)*params(8)-y(4)*y(8)*params(16)*params(8)*(1-params(16)*(1-params(17))))/((y(8)-y(8)*params(16)*(1-params(17)))*(y(8)-y(8)*params(16)*(1-params(17))))));
  g1(12,12)=1;
  g1(13,11)=1-(1-params(17));
  g1(13,15)=(-1);
  g1(14,12)=1-(1-params(17));
  g1(14,16)=(-1);
  g1(15,3)=1;
  g1(15,13)=(-1);
  g1(15,15)=(-1);
  g1(15,17)=(-1);
  g1(15,20)=(-1);
  g1(16,4)=1;
  g1(16,14)=(-1);
  g1(16,16)=(-1);
  g1(16,18)=(-1);
  g1(16,19)=(-1);
  g1(17,1)=(-(T149*T147*T144*getPowerDeriv(y(1),params(9),1)));
  g1(17,3)=1;
  g1(17,9)=(-(T149*T147*T143*T145));
  g1(17,11)=(-(T149*T147*T145*y(9)*getPowerDeriv(y(11),params(7),1)));
  g1(17,17)=(-(T149*T144*T145*getPowerDeriv(y(17),params(3),1)));
  g1(17,19)=(-(T144*T145*T147*getPowerDeriv(y(19),params(5),1)));
  g1(18,2)=(-(T159*T157*T154*getPowerDeriv(y(2),params(10),1)));
  g1(18,4)=1;
  g1(18,10)=(-(T159*T157*T153*T155));
  g1(18,12)=(-(T159*T157*T155*y(10)*getPowerDeriv(y(12),params(8),1)));
  g1(18,18)=(-(T159*T154*T155*getPowerDeriv(y(18),params(4),1)));
  g1(18,20)=(-(T154*T155*T157*getPowerDeriv(y(20),params(6),1)));
  g1(19,9)=1/y(9)-params(15)*1/y(9);
  g1(20,10)=1/y(10)-params(15)*1/y(10);
  if ~isreal(g1)
    g1 = real(g1)+2*imag(g1);
  end
if nargout >= 3,
  %
  % Hessian matrix
  %

  g2 = sparse([],[],[],20,400);
if nargout >= 4,
  %
  % Third order derivatives
  %

  g3 = sparse([],[],[],20,8000);
end
end
end
end
