function [equs]=baseline_steadystate_find_AL_delta_varphi(xxx,pibar,mupsi,tauk,muzplus,R,alphaa,Rf,epsilon,lambdad,...
    etag,Rx,etax,omegax,etaf,omegai,etai,Upsilon,zetac,betaa,b,tauc,zetah,sigmaL,omegac,...
    etac,Rnustar,tauw,tauy,etaa,taud,s,phalo,pitildew,lambdamc,mc,piw,phalomi,phalomc,...
    phalomx,Rstar,lambdami,lambdamx,phalox,lambdax,taumx,taumc,taumi,mcmi,mcmx,mcmc,taux,mcx,...
    intensity_target,iy_target,xy_target,Rk,xiw,lambdaw)


%back out parameter values
AL=xxx(1)*10;
delta=xxx(2);
varphi=xxx(3);


%what follows is part of the code in baseline_steadystate

%Relative import prices
pmx=taumx*Rnustar*varphi/mcmx;
pmc=taumc*Rnustar*varphi/mcmc;
pmi=taumi*Rnustar*varphi/mcmi;

%Relative consumption price
pc=(1-omegac+omegac*pmc^(1-etac))^(1/(1-etac));

%Relative investment price
pinvest=(1-omegai+omegai*pmi^(1-etai))^(1/(1-etai));

%Relative export price
px=(taux*Rx/(mcx*varphi))*(omegax*pmx^(1-etax)+1-omegax)^(1/(1-etax));

%Relative price of capital
pkprime=pinvest/Upsilon;

%Rental rate on capital
rkbar=(Rk*mupsi*pkprime/pibar-(1-delta)*pkprime-tauk*delta*mupsi*pkprime/pibar)/(1-tauk);

%Real Wage
wbar=(mc/(taud*(1/(1-alphaa))^(1-alphaa)*(1/alphaa)^alphaa*rkbar^alphaa*Rf^(1-alphaa)/epsilon))^(1/(1-alphaa));

% Capital labor ratio
kh=muzplus*((taud*mupsi^alphaa*wbar*Rf)/((1-alphaa)*mc))^(1/alphaa);

%Abbreviation ThetacH
ThetacH=1/(zetah*AL)*((1-xiw*(pitildew/piw)^(1/(1-lambdaw)))/(1-xiw))^(1-lambdaw*(1+sigmaL))...
    *(wbar*(1-tauy)/(lambdaw*(1+tauw)))*(1-betaa*xiw*(pitildew/piw)^(lambdaw*(1+sigmaL)/(1-lambdaw)))...
    *(zetac/(muzplus-b)*(muzplus-betaa*b)/(pc*(1+tauc)))/(1-betaa*xiw*(pitildew/piw)^(1/(1-lambdaw)));

%Abbreviation Thetay
Thetay=phalo^(lambdad/(lambdad-1))*epsilon*(kh/(mupsi*muzplus))^alphaa...
    /(1+phalo^(lambdad/(lambdad-1))*(1/mc-phalo^(lambdad/(1-lambdad))));

%alphaa abbreviations
alpha1=omegac*(pc/pmc)^etac*ThetacH*phalomc^(lambdamc/(1-lambdamc));

alpha2=(1-Rstar*s/(pibar*muzplus))*etaa*Thetay/varphi...
    +omegai*(pinvest/pmi)^etai*kh*(1-(1-delta)/(muzplus*mupsi))/Upsilon*phalomi^(lambdami/(1-lambdami));

alpha3=px^(1-etaf)/Rnustar-omegax*((omegax*pmx^(1-etax)+1-omegax)^(1/(1-etax))/pmx)^etax...
    *phalox^(lambdax/(1-lambdax))*px^(-etaf)*phalomx^(lambdamx/(1-lambdamx));

alpha4=(1-etag)*Thetay-pinvest^etai*kh*(1-(1-delta)/(muzplus*mupsi))/Upsilon*(1-omegai);

alpha5=(1-omegac)*pc^etac*ThetacH;

alpha6=(omegax*pmx^(1-etax)+1-omegax)^(etax/(1-etax))*(1-omegax)...
    *phalox^(lambdax/(1-lambdax))*px^(-etaf);

%Hours
H=((alpha5+alpha6*alpha1/alpha3)/(alpha4-alpha6*alpha2/alpha3))^(1/(1+sigmaL));
 

%Further steady states
kbar=kh*H;
ybar=Thetay*H;
i=kbar*(1-(1-delta)/(muzplus*mupsi))/Upsilon;
ystar=1/alpha3*(alpha1*H^(-sigmaL)+alpha2*H);
x=px^(-etaf)*ystar;
whalo=((1-xiw*(pitildew/piw)^(1/(1-lambdaw)))/(1-xiw))^(1-lambdaw)...
    /((1-xiw*(pitildew/piw)^(lambdaw/(1-lambdaw)))/(1-xiw))^((1-lambdaw)/lambdaw);
smallh=whalo^(lambdaw/(1-lambdaw))*H;


%construct equations to hold with approximate equality
%smallh target
equ1=smallh-intensity_target;
%iy target
equ2=i*pinvest/ybar-iy_target;
%xy target
% old incorrect version: equ3=x*px/ybar-xy_target;
equ3=px^(-etaf)*ystar*px*varphi/ybar-xy_target;


%create equation vector for fsolve
equs=[equ1
      equ2
      equ3];