Functions for plotting both 2 and 3 factors

Suppress the convergence warning in FindRoot

Off[FindRoot::lstol]

1. Numerical test cases

labor=99.634*10^6;
(* Output*)
YCAL=2.788*(10^12);
(* Capital Stock as a function of output *)
Khat =4*YCAL;

2 factor quantities

cof[Kv_,L_,α_,γ_,ρ_]:={-(1/(-1-(((Kv^ρ) (L^(-ρ)) γ)/α))),(((Kv^ρ) (L^(-ρ)) γ)/(α (1+(((Kv^ρ) (L^(-ρ)) γ)/α))))}

cof[4 2.788 (10^12),99.634*10^6,1/3,2/3,-1]

a=1-0.00001786804514619618`

c=0.00001786804514619618`

AF=YCAL(a/Khat+c/labor)

D[(AF/(a/Kv+c/labor)),Kv]/.Kv-> Khat

CRcr21980=D[(AF/(a/Khat+c/L)),L]/.L->labor

18654.94376083131`/0.08333333333333334`

Thus CRcr for there to be exactly no robots for the test case values is independent of CRmx

Wages without robots

wK1f[K0_,L_,A_,a_,c_]:=((A a)/((K0^2) ((((a/K0)+(c/L)))^2)))

wL1f[K0_,L_,A_,a_,c_]:=((A c)/((L^2) ((((a/K0)+(c/L)))^2)))

Y1f[K0_,L_,A_,a_,c_]:=((A )/( ((a/K0)+(c/L))))

3 factor quantities

LAI=.1 labor

LBI=.9 labor

cof3[Kv_,LA_,LB_,α_,β_,γ_,ρ_]:={-(1/(-1-(((Kv^ρ) (LA^(-ρ)) β)/α)-(((Kv^ρ) (LB^(-ρ)) γ)/α))),(((Kv^ρ) (LA^(-ρ)) β)/(α (1+(((Kv^ρ) (LA^(-ρ)) β)/α)+(((Kv^ρ) (LB^(-ρ)) γ)/α)))),(((Kv^ρ) (LB^(-ρ)) γ)/(α (1+(((Kv^ρ) (LA^(-ρ)) β)/α)+(((Kv^ρ) (LB^(-ρ)) γ)/α))))}

cof3[Khat,LAI,LBI,1/3,2/9,4/9,-1]

a3=1-5.956054070514502`*^-7-0.000010720897326926106`

b3=5.956054070514502`*^-7

c3=0.000010720897326926106`

AF3=YCAL(a3/Khat+b3/LAI+c3/LBI)

D[(AF3/(a3/Kv+b3/LAI+c3/LBI)),Kv]/.Kv-> Khat

D[(AF/(a3/Khat+b3/LAI+c3/LB)),LB]/.LB->LBI

D[(AF/(a3/Khat+b3/LA+c3/LBI)),LA]/.LA-> LAI

CRcr19803=13818.386326513308`/0.08333333333333334`

2. 2 factor functions

Functions for either case

YH2f[KH_,L_,A_,a_,c_]:=(A/((a/KH)+(c/L)))

CRcr2f[K0_,L_,a_,c_,CR0_,CRmx_]:=(((Root[-((CRmx K0)/L)+#1+(-(Sqrt[(a/c)]) CR0+(Sqrt[(a/c)]) CRmx) #1+(-CR0+(K0/L)) ((#1)^2)+((#1)^4)&,2]))^2) (* initialization cell *)

CRcr2f[2 Khat,labor,a,c,223859.3251299757`,400000]

KH2f[CRcr_,L_,a_,c_]:=(((Sqrt[a]) (Sqrt[CRcr]) L)/(Sqrt[c]))

YH2crf[K0_,L_,A_,a_,c_,CR0_,CRmx_]:=Module[{CRcr},CRcr=CRcr2f[K0,L,a,c,CR0,CRmx];Return[((A (Sqrt[CRcr]) L)/((Sqrt[a]) (Sqrt[c])+c (Sqrt[CRcr])))];]

wL2crf[K0_,L_,A_,a_,c_,CR0_,CRmx_]:=Module[{CRcr},CRcr=CRcr2f[K0,L,a,c,CR0,CRmx];Return[((A CRcr)/((((Sqrt[a])+(Sqrt[c]) (Sqrt[CRcr])))^2))];]

wL2crf[Khat,labor,AF,a,c,223859.32510687847`,400000]

wK2crf[K0_,L_,A_,a_,c_,CR0_,CRmx_]:=Module[{CRcr},CRcr=CRcr2f[K0,L,a,c,CR0,CRmx];Return[(A/((((Sqrt[a])+(Sqrt[c]) (Sqrt[CRcr])))^2))];]

wK2crf[Khat,labor,AF,a,c,223859.32510687847`,400000]

value2f[K0_,L_,A_,a_,c_,CR0_,CRmx_]:=Module[{CRcr,Ytot}, CRcr=CRcr2f[K0,L,a,c,CR0,CRmx];Ytot=YH2f[KH2f[CRcr,L,a,c],L,A,a,c](CRmx-CR0)/(CRmx-CRcr);Return[Ytot];] (* initialization cell*)

welfaretot2f[K0_,L_,A_,a_,c_,CR0_,CRmx_]:=Log10[value2f[K0,L,A,a,c,CR0,CRmx]]

welfareB2f[K0_,L_,A_,a_,c_,CR0_,CRmx_]:=Log10[value2f[K0,L,A,a,c,CR0,CRmx]/wL2crf[K0,L,A,a,c,CR0,CRmx]]

fr2Rf[K0_,L_,A_,a_,c_,CR0_,CRmx_]:=(CRcr2f[K0,L,a,c,CR0,CRmx]-CR0)/CRmx

fr2Rf[K0_,L_,A_,a_,c_,CR0_,CRmx_]:=(CRcr2f[K0,L,a,c,CR0,CRmx]-CR0)/(CRmx-CR0)

fr2Rf[2Khat,labor,AF,a,c,23859.3251 ,700000]

fr2Rf[20Khat,labor,AF,a,c,23859.3251 ,700000]

In 1980 CRcr=223859.3251 if CR0

CRcr2f[Khat,labor,a,c,223859.3251,400000]

tres2f[K0_,L_,A_,a_,c_,CR0_,CRmx_]:=Module[{CRcr,wK,wL,piyi,res},CRcr=CRcr2f[K0,L,a,c,CR0,CRmx];wK=(A/((((Sqrt[a])+(Sqrt[c]) (Sqrt[CRcr])))^2));wL=((A CRcr)/((((Sqrt[a])+(Sqrt[c]) (Sqrt[CRcr])))^2));piyi= YH2f[KH2f[CRcr,L,a,c],L,A,a,c]/(CRmx-CRcr);res={CRcr,wK,wL,piyi};Return[res];]

Kshare2f[K0_,L_,A_,a_,c_,CR0_,CRmx_]:=Module[{CRcr,wK,wL,pY,tRes,res},tRes=tres2f[K0,L,A,a,c,CR0,CRmx];wK=tRes[[2]];wL=tRes[[3]];pY=wK K0+wL L;Return[wK K0/pY];]

Lsharef[K0_,L_,A_,a_,c_,CR0_,CRmx_]:=Module[{CRcr,wK,wL,pY,tRes,res},tRes=tres2f[K0,L,A,a,c,CR0,CRmx];wK=tRes[[2]];wL=tRes[[3]];pY=wK K0+wL L;Return[wL L/pY];]

kti is not a function of i and is the same in both robot and human sectors. Its value is given by
(( YHf[KHf[CRcr,L,a,c],L,A,a,c])/((CRmx-CRcr)wKf[KHf[CRcr,L,a,c],L,A,a,c]))
But this simplifies to

((((Sqrt[a])+(Sqrt[c]) (Sqrt[CRcr])) (Sqrt[CRcr]) L)/((Sqrt[c]) (CRmx-CRcr)))

This does not mean that the production is independent of i
yi =((A kti)/((((Sqrt[a])+(Sqrt[CRi]) (Sqrt[c])))^2))

Clear[a,c]

yi=FullSimplify[((A kti)/((((Sqrt[a])+(Sqrt[CRi]) (Sqrt[c])))^2))/. kti-> ((((Sqrt[a])+(Sqrt[c]) (Sqrt[CRcr])) (Sqrt[CRcr]) L)/((Sqrt[c]) (CRmx-CRcr)))//PowerExpand]

yi2f[CRi_,K0_,L_,A_,a_,c_,CR0_,CRmx_] :=((A ((Sqrt[a]) +(Sqrt[c])  CRcr2f[K0,L,a,c,CR0,CRmx])(Sqrt[ CRcr2f[K0,L,a,c,CR0,CRmx]]) L)/((Sqrt[c]) ((((Sqrt[a])+(Sqrt[c]) (Sqrt[CRi])))^2) ( CRmx-CRcr2f[K0,L,a,c,CR0,CRmx])))

3. 3 factor functions

YH3f[LAH_,KH_,LB_,A_,a_,b_,c_]:=(A/((a/KH)+(b/LAH)+(c/LB)))

wK3f[LAH_,KH_,LB_,A_,a_,b_,c_]:=((A a)/(((((a/KH)+(b/LAH)+(c/LB)))^2) (KH^2)))

wA3f[LAH_,KH_,LB_,A_,a_,b_,c_]:=((A b)/((LAH^2) ((((a/KH)+(b/LAH)+(c/LB)))^2)))

wB3f[LAH_,KH_,LB_,A_,a_,b_,c_]:=((A c)/((LB^2) ((((a/KH)+(b/LAH)+(c/LB)))^2)))

KH3crf[CRcr_,LB_,a_,c_]:=(((Sqrt[a]) (Sqrt[CRcr]) LB)/(Sqrt[c]))

yiH3crf[LAH_,KH_,CRcr_,LB_,A_,a_,b_,c_,CRmx_] := YH3f[LAH,KH3crf[CRcr,LB,a,c],LB,A,a,b,c] /(CRmx-CRcr)

yiH3crf[LAI,1.4119758989267504`*^13,265821.7224185005`,LBI,AF3,a3,b3,c3,400000]

LAR3crf[LAH_,LB_,CRcr_,A_,av_,bv_,cv_,CR0_,CRmx_]:=Module[{piyi,wA,wK,KH,res,},KH=KH3crf[CRcr,LB,av,cv];piyi=yiH3crf[LAH,KH,CRcr,LB,A,av,bv,cv,CRmx];wA=wA3f[LAH,KH,LB,A,av,bv,cv];wK=wK3f[LAH,KH,LB,A,av,bv,cv];(*Print[KH,piyi,wA,wK];*)res=((Sqrt[bv]) piyi (2 (Sqrt[CRcr]) (Sqrt[CRcr+(((Sqrt[av]) (Sqrt[CRcr]))/(Sqrt[cv]))]) (cv^(3/4)) (Sqrt[wK])-2 ((Sqrt[bv]) (Sqrt[CRcr+(((Sqrt[av]) (Sqrt[CRcr]))/(Sqrt[cv]))]) (cv^(1/4)) (Sqrt[wA])+(Sqrt[av]) (CRcr^(1/4)) (Sqrt[(Sqrt[av])+(Sqrt[CRcr]) (Sqrt[cv])]) (Sqrt[wK])) ArcTanh[((((Sqrt[av])+(Sqrt[CRcr]) (Sqrt[cv])) (Sqrt[wK]))/((Sqrt[bv]) (Sqrt[wA])))]-((Sqrt[bv]) (CRcr^(1/4)) (Sqrt[(Sqrt[av])+(Sqrt[CRcr]) (Sqrt[cv])]) (Sqrt[wA])+(Sqrt[av]) (Sqrt[CRcr+(((Sqrt[av]) (Sqrt[CRcr]))/(Sqrt[cv]))]) (cv^(1/4)) (Sqrt[wK])) Log[bv wA-((((Sqrt[av])+(Sqrt[CRcr]) (Sqrt[cv])))^2) wK]))/((CRcr^(1/4)) (Sqrt[(Sqrt[av])+(Sqrt[CRcr]) (Sqrt[cv])]) cv (Sqrt[wA]) wK)-((Sqrt[bv]) piyi (2 (Sqrt[CR0]) (Sqrt[CR0+(((Sqrt[av]) (Sqrt[CR0]))/(Sqrt[cv]))]) (cv^(3/4)) (Sqrt[wK])-2 ((Sqrt[bv]) (Sqrt[CR0+(((Sqrt[av]) (Sqrt[CR0]))/(Sqrt[cv]))]) (cv^(1/4)) (Sqrt[wA])+(Sqrt[av]) (CR0^(1/4)) (Sqrt[(Sqrt[av])+(Sqrt[CR0]) (Sqrt[cv])]) (Sqrt[wK])) ArcTanh[((((Sqrt[av])+(Sqrt[CR0]) (Sqrt[cv])) (Sqrt[wK]))/((Sqrt[bv]) (Sqrt[wA])))]-((Sqrt[bv]) (CR0^(1/4)) (Sqrt[(Sqrt[av])+(Sqrt[CR0]) (Sqrt[cv])]) (Sqrt[wA])+(Sqrt[av]) (Sqrt[CR0+(((Sqrt[av]) (Sqrt[CR0]))/(Sqrt[cv]))]) (cv^(1/4)) (Sqrt[wK])) Log[bv wA-((((Sqrt[av])+(Sqrt[CR0]) (Sqrt[cv])))^2) wK]))/((CR0^(1/4)) (Sqrt[(Sqrt[av])+(Sqrt[CR0]) (Sqrt[cv])]) cv (Sqrt[wA]) wK);If[Im[res]/Re[res]>(10^(-5)),Print[res]];Return[Re[res]];]

LAR3crf[LAI,LBI,265821.7224185005`,AF3,a3,b3,c3,165820.7224185005`,400000]

KtR3crf[LAH_,LB_,CRcr_,A_,av_,bv_,cv_,CR0_,CRmx_]:=Module[{piyi,wA,wK,KH,res},KH=KH3crf[CRcr,LB,av,cv];piyi=yiH3crf[LAH,KH,CRcr,LB,A,av,bv,cv,CRmx];wA=wA3f[LAH,KH,LB,A,av,bv,cv];wK=wK3f[LAH,KH,LB,A,av,bv,cv];(*Print[KH,piyi,wA,wK];*)res=(1/(cv (wK^2)))piyi (-2 (Sqrt[bv]) (Sqrt[CRcr]) (Sqrt[cv]) (Sqrt[wA]) (Sqrt[wK])+CRcr cv wK+2 (bv wA+(Sqrt[av]) (Sqrt[bv]) (Sqrt[wA]) (Sqrt[wK])) Log[(Sqrt[bv]) (Sqrt[wA])+((Sqrt[av])+(Sqrt[CRcr]) (Sqrt[cv])) (Sqrt[wK])])-(1/(cv (wK^2)))piyi (-2 (Sqrt[bv]) (Sqrt[CR0]) (Sqrt[cv]) (Sqrt[wA]) (Sqrt[wK])+CR0 cv wK+2 (bv wA+(Sqrt[av]) (Sqrt[bv]) (Sqrt[wA]) (Sqrt[wK])) Log[(Sqrt[bv]) (Sqrt[wA])+((Sqrt[av])+(Sqrt[CR0]) (Sqrt[cv])) (Sqrt[wK])]);Return[res];]

KtR3crf[LAI,LBI,165821.7223185005`,AF3,a3,b3,c3,165821.7124185005`,400000]

CRcr1980=((c3 (Khat^2))/(a3 (LBI^2)))

RK3f[LAH_,LB_,CRcr_,A_,av_,bv_,cv_,CR0_,CRmx_]:=Module[{piyi,wA,wK,KH,res,CRcr1980},KH=KH3crf[CRcr,LB,av,cv];piyi=yiH3crf[LAH,KH,CRcr,LB,A,av,bv,cv,CRmx];wA=wA3f[LAH,KH,LB,A,av,bv,cv];wK=wK3f[LAH,KH,LB,A,av,bv,cv];(*Print[KH,piyi,wA,wK];*)res=(1/(cv (wK^2)))piyi (-2 (Sqrt[bv]) (Sqrt[CRcr]) (Sqrt[cv]) (Sqrt[wA]) (Sqrt[wK])-2 (Sqrt[av]) (Sqrt[CRcr]) (Sqrt[cv]) wK+CRcr cv wK+2 ((((Sqrt[bv]) (Sqrt[wA])+(Sqrt[av]) (Sqrt[wK])))^2) Log[(Sqrt[bv]) (Sqrt[wA])+((Sqrt[av])+(Sqrt[CRcr]) (Sqrt[cv])) (Sqrt[wK])])-(1/(cv (wK^2)))piyi (-2 (Sqrt[bv]) (Sqrt[CR0]) (Sqrt[cv]) (Sqrt[wA]) (Sqrt[wK])-2 (Sqrt[av]) (Sqrt[CR0]) (Sqrt[cv]) wK+CR0 cv wK+2 ((((Sqrt[bv]) (Sqrt[wA])+(Sqrt[av]) (Sqrt[wK])))^2) Log[(Sqrt[bv]) (Sqrt[wA])+((Sqrt[av])+(Sqrt[CR0]) (Sqrt[cv])) (Sqrt[wK])]);Return[res];]

Ans3crf[Kt0_,LAI_,LBI_,A_,a_,b_,c_,CR0_,CRmx_]:=Module[{sol,res},sol=FindRoot[{LAR3crf[LAH,LBI,CRcr,A,a,b,c,CR0,CRmx]+LAH==LAI,KtR3crf[LAH,LBI,CRcr,A,a,b,c,CR0,CRmx]+KH3crf[CRcr,LBI,a,c]== Kt0},{{LAH,100000},{CRcr,CR0}}];res={LAH,CRcr}/.sol[[1;;2]];Return[res];]

Ans3crf[Khat,LAI,LBI,AF3,a3,b3,c3,165821.72231850054`,400000]

Ans3crf[3 Khat,LAI,LBI,AF3,a3,b3,c3,165821.72231850054`,700000]

wK3crff[Kt0_,LA_,LB_,A_,a_,b_,c_,CR0_,CRmx_]:=Module[{s,LAH,CRcr,KH,wK},s=Ans3crf[Kt0,LA,LB,A,a,b,c,CR0,CRmx];LAH=s[[1]];CRcr=s[[2]];KH= (((Sqrt[a]) (Sqrt[CRcr]) LB)/(Sqrt[c]));wK=wK3f[LAH,KH,LB,A,a,b,c];Return[wK];]

wK3crff[Khat,LAI,LBI,AF3,a3,b3,c3,165821.72231850054`,400000]

wA3crff[Kt0_,LA_,LB_,A_,a_,b_,c_,CR0_,CRmx_]:=Module[{s,LAH,CRcr,KH,wA},s=Ans3crf[Kt0,LA,LB,A,a,b,c,CR0,CRmx];LAH=s[[1]];CRcr=s[[2]];KH= (((Sqrt[a]) (Sqrt[CRcr]) LB)/(Sqrt[c]));wA=wA3f[LAH,KH,LB,A,a,b,c];Return[wA];]

wA3crff[Khat,LAI,LBI,AF3,a3,b3,c3,165821.72231850054`,400000]

wB3crff[Kt0_,LA_,LB_,A_,a_,b_,c_,CR0_,CRmx_]:=Module[{s,LAH,CRcr,KH,wB},s=Ans3crf[Kt0,LA,LB,A,a,b,c,CR0,CRmx];LAH=s[[1]];CRcr=s[[2]];KH= (((Sqrt[a]) (Sqrt[CRcr]) LB)/(Sqrt[c]));wB=wB3f[LAH,KH,LB,A,a,b,c];Return[wB];]

wB3crff[Khat,LAI,LBI,AF3,a3,b3,c3,165821.72231850054`,400000]

tRes3f[Kt0_,LAI_,LBI_,A_,a_,b_,c_,CR0_,CRmx_]:=Module[{ansv,CRcr,KtR,RK,KR,KH,LAH,λ2,λ3,λ4,piyi,res},ansv=Ans3crf[Kt0,LAI,LBI,A,a,b,c,CR0,CRmx];CRcr=ansv[[2]];LAH=ansv[[1]];KtR=KtR3crf[LAH,LBI,CRcr,A,a,b,c,CR0,CRmx];RK=RK3f[LAH,LBI,CRcr,A,a,b,c,CR0,CRmx];KR=KtR-RK;KH=Kt0-KtR;λ2=wK3f[LAH,KH,LBI,A,a,b,c];λ3=wA3f[LAH,KH,LBI,A,a,b,c];λ4=λ2 CRcr;piyi=yiH3crf[LAH,KH,CRcr,LBI,A,a,b,c,CRmx] ;res={CRcr,KtR,RK,KR,KH,LAH,λ2,λ3,λ4,piyi};Return[res];]

fr3R[Kt0_,LA_,LB_,A_,a_,b_,c_,CR0_,CRmx_]:=Module[{s,CRcr},s=Ans3crf[Kt0,LA,LB,A,a,b,c,CR0,CRmx];Return[(s[[2]]-CR0)/CRmx];]

fr3R[2  Khat,LAI,LBI,AF3,a3,b3,c3,165821.72231850054`,700000]

fr3R[20  Khat,LAI,LBI,AF3,a3,b3,c3,165821.72231850054`,700000]

Kshare3f[Kt0_,LAI_,LBI_,A_,a_,b_,c_,CR0_,CRmx_]:=Module[{tRes,wK,wA,wB,pY,Ksh},tRes=tRes3f[Kt0,LAI,LBI,A,a,b,c,CR0,CRmx]; wK=tRes[[7]];wA=tRes[[8]];wB=tRes[[9]];pY=wK Kt0+wA LAI+wB LBI; Return[wK Kt0/pY];]

LAshare3f[Kt0_,LAI_,LBI_,A_,a_,b_,c_,CR0_,CRmx_]:=Module[{tRes,wK,wA,wB,pY,Ksh},tRes=tRes3f[Kt0,LAI,LBI,A,a,b,c,CR0,CRmx]; wK=tRes[[7]];wA=tRes[[8]];wB=tRes[[9]];pY=wK Kt0+wA LAI+wB LBI; Return[wA LAI/pY];]

LBshare3f[Kt0_,LAI_,LBI_,A_,a_,b_,c_,CR0_,CRmx_]:=Module[{tRes,wK,wA,wB,pY,Ksh},tRes=tRes3f[Kt0,LAI,LBI,A,a,b,c,CR0,CRmx]; wK=tRes[[7]];wA=tRes[[8]];wB=tRes[[9]];pY=wK Kt0+wA LAI+wB LBI; Return[wB LBI/pY];]

kti3f[CRi_,Kt0_,LAI_,LBI_,A_,a_,b_,c_,CR0_,CRmx_]:=Module[{LAH,CRcr,piyi,wA,wK,tres,res},tres=tRes3f[Kt0,LAI,LBI,A,a,b,c,CR0,CRmx];(*Print[tres];*)LAH=tres[[6]];wK=tres[[7]];wA=tres[[8]];CRcr=tres[[1]];piyi=tres[[10]];
res=If[CRi<CRcr,((((Sqrt[a])+(Sqrt[c]) (Sqrt[CRi])) piyi)/(((Sqrt[b]) (Sqrt[wA])+(Sqrt[a]) (Sqrt[wK])+(Sqrt[c]) (Sqrt[CRi]) (Sqrt[wK])) (Sqrt[wK]))),((((Sqrt[a])+(Sqrt[c]) (Sqrt[CRcr])) piyi)/(((Sqrt[b]) (Sqrt[wA])+(Sqrt[a]) (Sqrt[wK])+(Sqrt[c]) (Sqrt[CRcr]) (Sqrt[wK])) (Sqrt[wK])))];
(*Print[res];*)
(*Print[tres,LAH,wK,wA,CRcr,piyi];*)Return[res];]

lai3f[CRi_,Kt0_,LAI_,LBI_,A_,a_,b_,c_,CR0_,CRmx_]:=Module[{tres,CRcr,piyi,res,wA,wK},tres=tRes3f[Kt0,LAI,LBI,A,a,b,c,CR0,CRmx];
wK=tres[[7]];wA=tres[[8]];CRcr=tres[[1]];piyi=tres[[10]];res=If[CRi<CRcr,(((Sqrt[b]) piyi)/((Sqrt[b]) wA+(Sqrt[a]) (Sqrt[wA]) (Sqrt[wK])+(Sqrt[c]) (Sqrt[CRi]) (Sqrt[wA]) (Sqrt[wK]))),(((Sqrt[b]) piyi)/((Sqrt[b]) wA+(Sqrt[a]) (Sqrt[wA]) (Sqrt[wK])+(Sqrt[c]) (Sqrt[CRcr]) (Sqrt[wA]) (Sqrt[wK])))];Return[res];]

yi3f[CRi_,Kt0_,LAI_,LBI_,A_,a_,b_,c_,CR0_,CRmx_]:=Module[{CRcr,ktiv,laiv,res},CRcr=Ans3crf[Kt0,LAI,LBI,A,a,b,c,CR0,CRmx][[2]];ktiv=kti3f[CRi,Kt0,LAI,LBI,A,a,b,c,CR0,CRmx];laiv=lai3f[CRi,Kt0,LAI,LBI,A,a,b,c,CR0,CRmx];
res=If[CRi<CRcr,((A ktiv laiv)/(b ktiv+((((Sqrt[a])+(Sqrt[c]) (Sqrt[CRi])))^2) laiv)),((A ktiv laiv)/(b ktiv+((((Sqrt[a])+(Sqrt[c]) (Sqrt[CRcr])))^2) laiv))];Return[res];]

.

value3f[K0_,LA_,LB_,AF_,a_,b_,c_,CR0_,CRmx_]:=Module[{LAH,CRcr,piyi,wA,wK,tres},tres=tRes3f[K0,LA,LB,AF,a,b,c,CR0,CRmx];piyi=tres[[10]];Return[piyi (CRmx-CR0)];]

value3f[10 Khat,LAI,LBI,AF3,a3,b3,c3,165821.72231850054`,400000]

welfaretot3f[K0_,LA_,LB_,AF_,a_,b_,c_,CR0_,CRmx_]:=Log[value3f[K0,LA,LB,AF,a,b,c,CR0,CRmx]]

welfareB3f[K0_,LA_,LB_,AF_,a_,b_,c_,CR0_,CRmx_]:=Log[value3f[K0,LA,LB,AF,a,b,c,CR0,CRmx] LBshare3f[K0,LA,LB,AF,a,b,c,CR0,CRmx]]

welfareA3f[K0_,LA_,LB_,AF_,a_,b_,c_,CR0_,CRmx_]:=Log[value3f[K0,LA,LB,AF,a,b,c,CR0,CRmx] LAshare3f[K0,LA,LB,AF,a,b,c,CR0,CRmx]]

welfareK3f[K0_,LA_,LB_,AF_,a_,b_,c_,CR0_,CRmx_]:=Log[value3f[K0,LA,LB,AF,a,b,c,CR0,CRmx] Kshare3f[K0,LA,LB,AF,a,b,c,CR0,CRmx]]