function y = findvh(vh,LAMBDA,G,Z,MU,P0) %y = findvh(vh,LAMBDA,G,Z,MU,P0) evaluates the first-order conditions of the Ramsey problem w.r.t. v and h. These focs are solved with fsolved in the program simu.m %Inputs: vh (a 2-element vector containing values for v and h), LAMBDA (the multiplier in the implementability constraint of the Ramsey problem), G and Z, the values taken by the exogenous gov't purchases and techno shocks, and P0, an indicator variable taken the value 1 if the period is 0 and zero otherwise. %Output: y (a 2-element vector showing how far from zero the focs are, zero being the solution) %(c) Stephanie Schmitt-Grohe and Martin Uribe [BETA,THETA,D,ETA,B,A,gl,gh,phig,zl,zh,phiz,ALFA]=param(MU); Vs = sqrt(B/A); %satiation velocity Vmax = sqrt((1+B)/A); V = Vs + (Vmax-Vs) * abs(vh(1)) / (1+abs(vh(1))); %Vs + abs(vh(1)-Vs); H = abs(vh(2)) / (1+abs(vh(2))); S=A*V+B/V-2*sqrt(A*B); C = (Z*H - G) / (1+ALFA*S); %consmption SP=A-B/V^2; GAMA=1+S+V*SP; SPP=2*B/V^3; GAMAP=2*A; R=1/(1-V^2*SP); RP=2*A*V*R^2; PHI = (1+(1-1/R)/V)/GAMA + ALFA*S/GAMA; PHIP = (-SP*GAMA + 2*SP*S + V*SPP*S)/(GAMA^2) + ALFA*(SP*GAMA-S*GAMAP)/GAMA^2 ; UC=1/C; UCC=-1/C^2; UH=-THETA/(1-H); UHH=-THETA/(1-H)^2; UCH=0; UHC=UCH; MU = (UC *(1+LAMBDA * PHI) + LAMBDA * (UCC*C*PHI+UHC*H+UCC*Z*H/GAMA/ETA - UCC/GAMA * P0 * D)) / (1+ALFA*S); y(1) = LAMBDA * UC *C * PHIP - LAMBDA * UC * GAMAP / GAMA^2 * (Z * H / ETA - P0 * D) - MU * C * ALFA * SP; y(2) = UH + LAMBDA * ( UCH*C * PHI + UH + H * UHH + UCH * Z *H/ GAMA / ETA + UC * Z / GAMA / ETA - UCH/GAMA *P0 * D) + Z * MU;