function err=steady_state_function(H)

%parameters
            alpha = 1 - 0.623 ; %C&F
            n = 1.01^0.25 - 1 ; %F&T
            phiI = 132 ; %F&T
            kappa = 12 ; %C&F
            phiK = 1 ;
            delta = 0.025 ; %C&F
            omega = 1.023^(-0.25) ; %F&T
            gamma = 1.1^(-0.25) ; %F&T
            upsilon = 0.4 ; %F&T
            rho = -3 ; %F&T
            beta = 1.0001 ;
            xi = 0.6 ; %F&T
            g = 0.17 ; %C&F
            b = 4 ; %C&F
            varrho = 0.4 ; %C&F
            phiPI = 2 ; %C&F
            phiR = 0.5 ; %C&F
            Rbar = (1/beta) - 1 ;
            phiNX = 1 ; %Aoki et al.
            ystar = 1 ;
            Rstar = (1/0.99 - 1) ;
            phiS = 0.000742 ; %S&U
            fstarbar = -0.5 ; %S&U
            
            F=H.^2;

Y = F(1) ;
K = F(2) ;
L = F(3) ;
VARPHI = F(4) ;
W = F(5) ;
RK = F(6) ;
PI = F(7) ; 
PINT = F(8) ; 
PK = F(9) ; 
DI = F(10) ;
DK = F(11) ;
I = F(12) ;
Q = F(13) ; 
R = F(14) ;
PSI = F(15) ;
VO = F(16) ;
EPSILON = F(17) ;
THETA = F(18) ;
CO = F(19) ;
AO = F(20) ;
HO = F(21) ;
SO = F(22) ;
EO = F(23) ;
LO = F(24) ;
TO = F(25) ;
PTO = F(26) ;
VY = F(27) ;
CY = F(28) ;
AY = F(29) ;
HY = F(30) ; 
SY = F(31) ;
OMEGA = F(32) ;
LY = F(33) ;
TY = F(34) ;
PTY = F(35) ;
C = F(36) ;
A = F(37) ;
LAMBDA = F(38) ;
V = F(39) ;
B = F(30) ;
G = F(41) ;
E = F(42) ; 
T = F(43) ;
S = F(44) ;
NX = F(45) ; 
PHI = F(46) ;
FSTAR = F(47) ;
            
%equations
err = zeros(47,1) ;

err(1)=K^(alpha)*L^(1-alpha) - Y ; %production function: Y

err(2)=(W/(1-alpha))^(1-alpha)*(RK/alpha)^alpha - VARPHI ; %real marginal cost: VARPHI
     
err(3)=(1-alpha)*VARPHI*Y/L - W ; %real wages: W

err(4)=alpha*VARPHI*Y/K - RK ; %return on capital: RK

err(5)=(1-VARPHI-(phiI/2)*(PI-1)^2)*Y - DI ; %profits from intermediate goods: DI 

err(6)=kappa*(VARPHI-1)*Y + (1+n)*(PI/RK)*phiI*(PI-1)*PI*Y - phiI*(PI-1)*PI*Y ; %NK Phillips Curve: PI
     
err(7)=Q*I - (1-phiK*((I/I)-1)^2)*I - DK ; %Capital producers profit: DK
     
err(8)=((1-delta)*K+(1-(phiK*(I/I)-1)^2)*I) - K ; %Law of motion of capital: K 
     
err(9)=(PI/R)*(Q*(1-delta)+RK) - Q ; %Tobin's Q: Q
     
err(10)=(1-omega)+gamma*PSI - (1+n)*PSI ; %dependency ratio: PSI
     
err(11)=(EPSILON*THETA)^(-1/rho)*CO*(((1-upsilon)/upsilon)*(1/(xi*W)))^(1-upsilon) - VO ; %old welfare: VO
     
err(12)=(EPSILON*THETA)*(((R*AO)/PI)+HO+SO-xi*TO) - CO ; %Consumption of old: CO
     
err(13)=EO + ((gamma*PI)/R)*SO - SO ; %old social security: SO
     
err(14)=varrho*(W - TY) - EO ; %old pensions: EO
     
err(15)=PSI - ((1-upsilon)/upsilon)*(1/(xi*W))*CO - LO ; %old labour: LO
     
err(16)=xi*W*LO + ((gamma*PI)/R)*HO - HO ; %old human capital: HO
     
err(17)=xi*TO + ((gamma*PI)/R)*PTO - PTO ; %old present lump sum taxes: PTO
     
err(18)=((R*AO)/PI) - CO + (1+omega)*(((R*AY)/PI)+ W - CY) - AO ; %old financial assets: AO
     
err(19)=1 - ((EPSILON*THETA)/(EPSILON*THETA))*gamma*R^(rho/(1-rho))*beta^(rho/(1-rho))*(1/PI)^((upsilon*rho)/(1-rho))*(W/W)^(((1-upsilon)*rho)/(1-rho)) - (EPSILON*THETA) ; %old MPC: EPSILON
     
err(20)=(THETA)^(-1/rho)*CY*(((1-upsilon)/upsilon)*(1/W))^(1-upsilon) - VY ; %young welfare: VY 
     
err(21)=THETA*(((R*AY)/PI)+ HY + SY - TY) - CY ; %young consumption: CY
     
err(22)=((PI*(OMEGA-omega))/(OMEGA*R))*SO + ((PI*omega)/(OMEGA*R))*SY - SY ; %young discounted social security: SY 
     
err(23)=1 - ((1-upsilon)/upsilon)*(1/W)*CY - LY ; %young labour: LY 
     
err(24)=W*LY + omega*((HY*PI)/(OMEGA*R)) + (1-omega)*(EPSILON)^((rho-1)/rho)*(1/xi)^(1-upsilon)*((HO*PI)/(OMEGA*R)) - HY ; %young human wealth: HY
     
err(25)=TY + omega*((PTY*PI)/(OMEGA*R)) + (1-omega)*(EPSILON)^((rho-1)/rho)*(1/xi)^(1-upsilon)*((PTO*PI)/(OMEGA*R)) - PTY ; %young presented lump sum taxes: PTY
     
err(26)=omega*((R*AY)/PI + W*LY - CY) - AY ; %young total financial assets: AY
     
err(27)=1 - beta^(1/(1-rho))*(1/PI)^((rho*upsilon)/(1-rho))*R^(rho/(1-rho))*OMEGA^(rho/(1-rho))*(W/W)^(((upsilon-1)*rho)/(1-rho)) - THETA ; %young MPC: THETA
     
err(28)=omega + (1-omega)*EPSILON^(-(1-rho)/rho)*(1/xi)^(1-upsilon) - OMEGA ; %young-old adjustment factor: OMEGA 
     
err(29)=CO + CY - C ; %total consumption
     
err(30)=AO/A - LAMBDA ; %old share of assets: A
     
err(31)=omega*(1 - EPSILON*THETA)*LAMBDA*((R*A)/PI) - (1+n)*(LAMBDA - (1-omega))*A ; %law of motion of financial asset share: LAMBDA
     
err(32)=VO + VY - V ; %total welfare: V
     
err(33)=(R/PI)*B + G + E - T - (1-n)*B ; %government budget constraint: T
     
err(34)=TY + xi*TO - T ; %lump sum taxes: TY
     
err(35)=g - G ; %government expenditure: G
     
err(36)=b - (1+n)*B ; %government debt: B
     
err(37)=varrho*PSI*((1-alpha)*VARPHI*Y - T) - E ; %total pension payments: E
     
err(38)=phiR*Rbar + (1-phiR)*R + phiPI*PI - R ; %interest rate rule

err(39)=(1+n)*(PK+DK)/PK - R/PI ; %capital market clearing condition: PK
     
err(40)=(1+n)*(PINT+DI)/PINT - R/PI ; %intermediate market clearing condition: PINT
     
err(41)=LY + xi*LO - L ; %labour market clearing condition: L
     
err(42)=C + I + G + NX - Y*(1 - (phiI/2)*(PI-1)^2 - phiK*((I/I)-1)^2) ; %goods market clearing condition: I
     
err(43)=S^(phiNX)*ystar - NX ; %net exports: NX
     
err(44)=K + B + PINT + S*FSTAR - A ; %total assets: A 
     
err(45)=(1 + Rstar + PHI)*(S/S) - 1 - R ; %UIP condition: S
     
err(46)=(1 + Rstar + PHI)*S*FSTAR + NX - S*FSTAR ; %law of motion of financial assets: FSTAR 
     
err(47)=phiS*(exp(FSTAR-fstarbar)-1) - PHI; %risk premium: PHI
end