#OK to post homework #Lucy Martinez, 02-06-22, Assignment 5 restart: read `C5.txt`: with(plots,implicitplot): with(combinat): #Write Maple code for the pay-offs for both players in term of the variables p1, and p2 (how much price to decide) and the parameters a,b,c #for the profit function of both players. Either by hand, or using Maple, find the Best Response Functions, and the Nash Equilibrium. #Confirm it graphically (for specific, numeric, a,b,c) by using Maple's implicitplot. #----------------------Problem 1-----------------------# #Payoffs: u1(p1,p2)=(a-p1+bp2)(p1-c) and u2(p1,p2)=(a-p2+bp1)(p2-c) solve({(a+c+b*p2)/2=p1,(a+c+b*p1)/2=p2},{p1,p2}); # p1=(a+c)/(2-b), p2=(a+c)/(2-b) #here a=8,b=1, c=5 implicitplot([p1=(13+p2)/2,p2=(13+p1)/2],p1=0..15,p2=0..15, scaling=constrained); #----------------------Problem 2-----------------------# ##Game 1: G1:=RG(30,30,100000): NE(G1); #this gives the index of the nash equilibrium # {[10, 29], [11, 26]} BestTot(G1); # {[11, 26]}, 199185 BetterForBoth(G1,10,29); # {[11, 26], [14, 13], [17, 11]} BetterForBoth(G1,11,26); # {} ##Game 2: G2:=RG(30,30,100000): NE(G2); {[28, 5]} BestTot(G2); # {[3, 30]}, 195781 BetterForBoth(G2,28,5); # {} ##Game 3: G3:=RG(30,30,100000): NE(G3); # {[3, 26], [28, 19]} BestTot(G3); # {[3, 15]}, 197854 BetterForBoth(G3,3,26); BetterForBoth(G3,28,19); # {} # {} #----------------------Problem 3-----------------------# # write a procedure BeatNE(a,b) # that inputs positive integers a and b and outputs the set of all games (given as bi-matrices) # for which there is a unique Nash Equilibrium, AND there exist a strategy choice that is better for BOTH players. AllGames:= proc(a,b) local S,pi1,pi2,i1,j1:NULL;S:=permute(a*b): {seq(seq([seq([seq([pi1[b*i1+j1],pi2[b*i1+j1]],j1=1..b)],i1=0..a-1)],pi2 in S),pi1 in S)}: end: BeatNE:=proc(a,b) local G,L: L:={}: for G in AllGames(a,b) do if nops(NE(G))=1 then if nops(BetterForBoth(G,NE(G)[1,1],NE(G)[1,2]))>0 then L:=L union {G}; fi: fi: od: L: end: BeatNE(2,2); # {[[[1, 1], [3, 2]], [[4, 3], [2, 4]]], # [[[1, 1], [3, 4]], [[2, 3], [4, 2]]], # [[[1, 2], [3, 4]], [[2, 3], [4, 1]]], # [[[1, 3], [3, 4]], [[2, 2], [4, 1]]], # [[[1, 4], [3, 3]], [[2, 2], [4, 1]]], # [[[1, 4], [4, 3]], [[2, 2], [3, 1]]], # [[[1, 4], [4, 3]], [[3, 2], [2, 1]]], # [[[2, 1], [3, 2]], [[4, 3], [1, 4]]], # [[[2, 2], [3, 1]], [[1, 4], [4, 3]]], # [[[2, 2], [4, 1]], [[1, 3], [3, 4]]], # [[[2, 2], [4, 1]], [[1, 4], [3, 3]]], # [[[2, 3], [4, 1]], [[1, 2], [3, 4]]], # [[[2, 3], [4, 2]], [[1, 1], [3, 4]]], # [[[2, 4], [4, 3]], [[3, 2], [1, 1]]], # [[[3, 1], [2, 2]], [[4, 3], [1, 4]]], # [[[3, 2], [1, 1]], [[2, 4], [4, 3]]], # [[[3, 2], [2, 1]], [[1, 4], [4, 3]]], # [[[3, 3], [1, 4]], [[4, 1], [2, 2]]], # [[[3, 4], [1, 1]], [[4, 2], [2, 3]]], # [[[3, 4], [1, 2]], [[4, 1], [2, 3]]], # [[[3, 4], [1, 3]], [[4, 1], [2, 2]]], # [[[4, 1], [2, 2]], [[3, 3], [1, 4]]], # [[[4, 1], [2, 2]], [[3, 4], [1, 3]]], # [[[4, 1], [2, 3]], [[3, 4], [1, 2]]], # [[[4, 2], [2, 3]], [[3, 4], [1, 1]]], # [[[4, 3], [1, 4]], [[2, 1], [3, 2]]], # [[[4, 3], [1, 4]], [[3, 1], [2, 2]]], # [[[4, 3], [2, 4]], [[1, 1], [3, 2]]]} BeatNE(2,3); # [Length of output exceeds limit of 1000000] #----------------------Problem 4-----------------------# EstBeatNE:=proc(a,b,K,M) local L, S, G, i: L:=[0,0,0]; for i from 1 to M do G:=RG(a,b,K): if nops(NE(G))=1 then L[1]:=L[1]+1: S:=G[NE(G)[1,1],NE(G)[1,2],1]+G[NE(G)[1,1],NE(G)[1,2],2]: if BestTot(G)[2] > S then L[2]:=L[2]+1: fi: if nops(BetterForBoth(G,NE(G)[1,1],NE(G)[1,2])) > 0 then L[3]:=L[3]+1: fi: fi: od: for i from 1 to 3 do L[i]:=L[i]/M: od: evalf(L): end: EstBeatNE(10,10,1000,1000); # [0.4200000000, 0.2180000000, 0.1040000000] EstBeatNE(10,10,1000,1000); # [0.4060000000, 0.2140000000, 0.1170000000] EstBeatNE(10,10,1000,1000); # [0.4180000000, 0.2120000000, 0.1080000000] EstBeatNE(10,10,1000,1000); # [0.4160000000, 0.2200000000, 0.1100000000] EstBeatNE(10,10,1000,1000); # [0.4260000000, 0.2020000000, 0.09000000000] #----------------------Problem 5-----------------------# A:=q1*(1-q1-q2)^(d1): B:=q2*(1-q1-q2)^(d2): P1:=diff(A, q1); P2:=diff(B,q2); # P1 := (1 - q1 - q2)^(d1) - d1q1(1 - q1 - q2)^(d1-1) # P2 := (1 - q1 - q2)^(d2) - d2q2(1 - q1 - q2)^(d2-1) solve({P1=0,P2=0},{q1,q2}); # q1=d2/(d1d2 + d1 + d2), q2=d1/(d1d2 + d1 + d2)