function [res,V]=mod3test(X,param);

alph1   = X(1);
thet1   = X(2);
y       = param(1);
yn      = param(2);
c       = param(3);
xt      = param(4);
xn      = param(5);
g       = param(6);
kt      = param(7);
h       = param(8);
hn      = param(9);
NIPAbw  = param(10);
tauc    = param(11);
tauh    = param(12);
taub    = param(13);
taux    = param(14);
tauk    = param(15);
taup    = param(16);
tauu    = param(17);
taud    = param(18);
gn      = param(19);
gz      = param(20);
phi     = param(21);
q       = param(22);
chi     = param(23);
deli    = param(24);
beta    = param(25);
isymm   = param(26);
if (isymm==1)
  alph2 = alph1;
  thet2 = thet1;
else
  alph2 = param(27);
  thet2 = param(28);
end;

lshare1 = 1-alph1-thet1;
lshare2 = 1-alph2-thet2;
taxc    = 1+tauc;
taxh    = 1-tauh;
taxb    = 1-taub;
taxd    = 1-taud;
taxx    = 1+taux;
taxp    = 1-taup;
chifac  = (1.-chi)*taxb+chi*taxd*taxp;
grate   = (1+gz)*(1+gn);
delt    = xt/kt+1-grate;
rt      = tauk-((1-delt)*taxx+delt*taup+tauu-(taxx+tauu)*(1+gz)/beta)/taxp;
ri      = q*chifac*((1+gz)/beta-1+deli)/(taxd*taxp);
k1t     = thet1*y/rt;
xi      = (NIPAbw-lshare1*y)/(lshare2*q-(1-chi)*q);
ki      = xi/(grate-1+deli);
qxi     = q*xi;
tem     = lshare1*y/(lshare2*qxi);
h1      = tem/(1+tem)*(h-hn);
psi     = taxh*lshare1*(1-h)*y/(taxc*c*h1);
h2      = h-h1-hn;
k2t     = thet2*qxi/rt;
z1      = (y/(k1t^thet1*ki^alph1*h1^lshare1))^(1/lshare1);
z2      = (xi/(k2t^thet2*ki^alph2*h2^lshare2))^(1/lshare2);
w       = lshare1*y/h1;

res     = [kt-k1t-k2t;
           ri-(alph1*y+alph2*qxi)/ki];

V       = [k1t;k2t;h1;h2;qxi;xi;ki;z1;z2;delt;psi;alph2;thet2;w;rt;ri];
