function computeEquilibrium_twoPlayers_Enhanced % Computes equilibrium strategie in a first-price auction with two % players using the boundary value method with fixed-point iterations % %! When using this code please cite the following article: %! G. Fibich and N. Gavish, Numerical simulations of asymmetric first-price auction, GEB, 2011 %! doi:10.1016/j.geb.2011.02.01 format long disp(['------- Parameters -------']) nGrid=1000; % Increase nGrid for better precision precision = ceil(log10(1/nGrid^4)); disp(['Estimated precision O(10^',num2str(precision),')']) v2=linspace(0,1,nGrid+2)';v2=v2(2:end-1);h=v2(2)-v2(1); %% Define distribution functions % Please be aware to change Fi and Fi/fi together alpha=1;F1overf1= @(x) (x/alpha);F1= @(x) (x.^alpha); beta=2;F2overf2= @(x) (x/beta );F2= @(x) (x.^beta); disp(['Distribution of player 1 is ',func2str(F1),' where alpha=',num2str(alpha)]); disp(['Distribution of player 2 is ',func2str(F2)]); disp(['---------- Results ---------']) %% Construct operators [Dv,Dv_RHS] = GetDeriviativeMatrix(nGrid,h); [Db,Db_RHS] = GetDeriviativeMatrix(nGrid,h,true); %% Construct initial guess b=v2/2; v1=v2; %% iterate r=[]; close for iter=1:150 v_coeff=-F1overf1(v1)./F2overf2(v2)./(v2-b); LHS_v=Dv+spdiags(v_coeff,0,nGrid,nGrid); RHS_v=v_coeff.*b-Dv_RHS; r(end+1)=norm(LHS_v*v1-RHS_v); v1=LHS_v\RHS_v; LHS_b=Db+spdiags(1./F2overf2(v2),0,nGrid,nGrid); RHS_b=v1./F2overf2(v2)-Db_RHS; b=LHS_b\RHS_b; end b_bar= [-1 4 -6 4]*b(end-3:end); disp(['b_bar =',num2str(b_bar,1-precision)]) b=[0;b;b_bar]; v1=[0;v1;1]; v2=[0;v2;1]; hold on;plot(b,v1,b,v2); legend('v_1(b)','v_2(b)','location','northwest');box on;axis tight;axis square %% Compute revenue R=b_bar-diff(fnval(fnint(spline(b,F2(v2).*F1(v1))),[0 b_bar])); disp(['Renevue =',num2str(R,1-precision)]); %% Subfunction for building operator matrices function [D,D_RHS] = GetDeriviativeMatrix(n,h,itisOneSided) if nargin<3 itisOneSided=false; end e=ones(n,1); D = spdiags([e -8*e 0*e 8*e -e], -2:2, n, n); D=D/(12*h); D_RHS=e*0; % Handle derivative around the origin D(1,1:5)=[-10 18 -6 1 0]/12/h;D_RHS(1)=0; D(2,1:5)=[-8 0 8 -1 0]/12/h;D_RHS(2)=0; % Handle derivative around one if itisOneSided D(end,end-4:end)=[3 -16 36 -48 25]/12/h; D(end-1,end-4:end)=[-1 6 -18 10 3]/12/h; else D(end,end-4:end)=[0 -1 6 -18 10]/12/h;D_RHS(end)=1/4/h; D(end-1,end-4:end)=[0 1 -8 0 8]/12/h;D_RHS(end-1)=-1/12/h; end return