Last Update: May 12, 2022
Dr. Zeilberger's Email: DoronZeil at gmail dot com ; Official Email: zeilberg@math.rutgers.edu
Experimental Mathematics used to be considered an oxymoron, but the future of mathematics is in that direction. In addition to learning the philosophy and methodology of this budding field, students will become computer-algebra wizards, and that should be very helpful in whatever mathematical specialty they are doing (or will do) research in.
We will first learn Maple, and how to program with it. This semester we will learn, from an experimental mathematics point of view, algorithmic and computational Game Theory. The final projects may lead to published papers. People who already took previous editions of this class are welcome to take it again, since except for the basics, there is very little overlap with previous years.
This class is suitable for graduate students in other departments, and the software development skills learned will be useful for doing any quantitative research. Very smart advanced undergraduates are also welcome. In particular, the methods learned for researching Game theory should be applicable almost everywhere.
Added March 31, PICK A PROJECT
Chapter 1 of Karl Sigmund's fascinating book
For more details, see this 2002 masterpiece.
It should be sent to the email address
ShaloshBEkhad at gmail dot com
Subject: HomeWork#X
and then attach a .txt file(s) called
hwXYourFirstNameYourLastName.txt
where X is the number of the assignment
Except for the first assignment, you should have two attached .txt files.
For example, when Yukun Yao submits homework assignments 2 and 3, he should email ShaloshBEkhad at gmail dot com, with
Subject: HomeWork#2#3
and attach the text files (the source code plus human comments (such lines must start with #)
hw2YukunYao.txt and hw3YukunYao.txt
#Please do not post homework
or
#OK to post homework
Followed by
#Your Name, Date, Assignment X
Lecture 1 ( Thurs., Jan. 20, 2022)
Rand2PlayerGame(a,b,K): A random 2-player (static) game where the Row player has a strategies (Row 1, .., Row a), the Column player has b strategies (Col. 1, ..., Col. b)
and the pay-offs are from 0 to K. For example, to see a random game where Player Row has four strategy choices, and Player Column has five strategy choices
and the pay-offs are integers from 0 to 20 type:
matrix(Rand2PlayerGame(4,5,20));
IsDom(v1,v2): Given two lists of numbers is v1[i]<=v2[i] for all i?. For example
IsDom([1,3,2],[2,4,3]); should return true but IsDom([1,3,2],[2,4,1]); should return false
IsStrictDom(v1,v2): Given two lists of numbers is v1[i]
Subject: hw#1
and an attachment
hw1FirstNameLastName.txt
and indicate whether it is OK to post. If you do not say "Please do not post", it will be posted.
matrix(GameDB()[4]);
matrix(GameDB()[5]);
and for each of these two games, spell-out (like we did in class), for each choice (i,j), write the pay-off functions u_1(i,j) and u_2(i,j)
[Modified Jan. 23, 2022, thanks to comments by Lucy Martinez, Rebecca Embar, and George Spahn]
[Mandatory for experts, optional for novices] Using procedure IsDom(v1,v2) (that I added after class), Write a Maple procedure
FindDominatedRowStrategy(G)
FindDominatedColumnStrategy(G)
that inputs a 2-player game, G, and outputs either a row or column (respectively) that can be (weakly) eliminated, or returns FAIL.
[Added Jan. 23, 2022, thanks to comments by Lucy Martinez, Rebecca Embar, and George Spahn]
[Mandatory for experts, optional for novices] Using procedure IsStictDom(v1,v2) (that I added Jan. 23), Write a Maple procedure
FinStrictdDominatedRowStrategy(G)
FindStrictDominatedColumnStrategy(G)
that inputs a 2-player game, G, and outputs either a row or column (respectively) that can be (strongly) eliminated, or returns FAIL.
[Modified Jan. 23, 2022, thanks to comments by Lucy Martinez, Rebecca Embar, and George Spahn]
[Mandatory for experts, optional for novices] Using the above, write a procedure
ShrinkGame(G)
that tries to shrink a game, if possible, or returns FAIL, then iterate it and write
ReducedGame(G)
that keeps shrinking the game until it not shrinkable any more.
Added Jan. 24, 2022: The students' nice solution can be found in this directory
Lecture 2 (Monday , Jan. 24, 2022)
PrintGamec(G): prints the game nicely, like in the book
PrintGame(and2PlayerGame(4,5,20));
Inputs a list L of numbers, output the SET of places (indices) where it is maximum. For example MyMaxIndex([5,6,7,7,1,7]); should give {3,4,6}
add(x[LoadedCon(1/3)],i=1..300);
Subject: hw#2
and an attachment
hw2FirstNameLastName.txt
and indicate whether it is OK to post. If you do not say "Please do not post", it will be posted.
IsNash(G,a1,a2)
That inputs a 2-player game bi-matrix G, and members a1,a2 of A1, A2 respectively (that in our convention are integers from {1, ..., nops(G)} and {1, ..., nops(G[1])}) and outputs true or false according to whether [a1,a2] is a Nash Equilibrium.
PureNashEqui(G)
that inputs a bi-matrix G, and outputs the (possibly) empty set of pairs [a1,a2] that are (pure) Nash Equilibria.
Generate 5 random 2-player games where Player Row has 10 strategies, and Player Column has 12 strategies, and for each find their set of (pure) Nash Equilibria
Added Jan. 30, 2022: The students' nice solution can be found in this directory
Lecture 3 (Thurs. , Jan. 27, 2022)
Subject: hw#3
and an attachment
hw3FirstNameLastName.txt
and indicate whether it is OK to post. If you do not say "Please do not post", it will be posted.
(i) The outcome of the sequential (aka dynamical) version of the game where Player Row goes first
(ii) The outcome of the sequential (aka dynamical) version of the game where Player Column goes first
(iii) The set (possibly empty) of (pure) Nash Equilibria
Check these answers using procedures DynRC, DynCR, and your own PureNashEqui(G) that hopefully you wrote for hw2
AllGames(a,b)
that inputs positive integers a and b and outputs the set of all (a*b)!2 possible games where Player Row has a strategies, Player Column has b strategies, each player's payoffs are distinct and drawn from {1, ..., a*b}
FullStat(a,b)
that inputs positive integers a and b (not too big!) and outputs the following list
[Number of Games with No Nash Equilibria, Number of Games with One Nash Equilibria, Number of Games with Two Nash Equilibria, Number of Games where the Row Player was better off playing second, Number of Games where the Column Player was better off playing second, Number of Games where DynRC(G)=DynCR(G)]
What are
(i) FullStat(2,2)
(ii) FullStat(3,2) [It may take a while]
SampleStat(a,b,K)
that inputs positive integers a and b, and a fairly large positive integer K, and generates K random games where Row has a strategies and Col has b strategies and outputs the following list of numbers (in floating-point, i.e. decimals)
evalf( [(Number of Games with No Nash Equilibria)/K, (Number of Games with One Nash Equilibria)/K, (Number of Games with Two Nash Equilibria)/K, (Number of Games where the Row Player was better off playing second)/K, (Number of Games where the Column Player was better off playing second)/K, (Number of Games where DynRC(G)=DynCR(G))/K]):
Run the following five times
(i) SampleStat(10,10,10000)
and see if the answers are similar.
Added Jan. 30, 2022: The students' nice solution can be found in this directory
Lecture 4 (Monday , Jan. 31, 2022)
Subject: hw#4
and an attachment
hw4FirstNameLastName.txt
and indicate whether it is OK to post. If you do not say "Please do not post", it will be posted.
(A-q)^d
For some positive number d. What are
(i) The best quantity choice for a MONOPOLY (make sure that you get A/2 when d=1)
(ii) The best quantity choice for Company 1 and Company 2 in the Stackelberg model (make sure that you get A/2 and A/4 when d=1)
(iii) The Nash Equilibrium choice where each is a best response of the other (make sure that you get A/3 and A/3 when d=1)
Added Feb. 7, 2022: The students' nice solution can be found in this directory
Lecture 5 (Thurs. , Feb. 3, 2022)
contains, in addition to previous codes (use Help2();, Help3();, Help4(); to see the corresponding list), the following procedures
Subject: hw#5
and an attachment
hw5FirstNameLastName.txt
and indicate whether it is OK to post. If you do not say "Please do not post", it will be posted.
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.
What are the sets
BeatNE(2,2)
BeatNE(2,3) [If it does not take too long]
Using RG(a,b,K), write a procedure
EstBeatNE(a,b,K,M)
that inputs a,b,K (as for RG(a,b,K) and a large integer M, generates M random games, and counts, out of these M games, how many have the property that they have exactly one Nash Equilibria, followed by the number of those, among the former, that have the property that the total pay-offs is better than the total pay-off of the Nash Equilibria, followed by the number of those (games with exactly one NE) that have the property that there exists a strategy choice that is NOT a NE but nevertheless is better for both of them (like (Silent, Silent) in the Prisoner's Dilemma). Divide these numbers by M, and take evalf
What did you get for
EstBeatNE(10,10,1000,1000)?
(Run it five times and see whether you get similar answers)
u1:=q1*(1-q1-q2)^(d1);
u2:=q2*(1-q1-q2)^(d2);
Assume that d1 and d2 are numbers between 0 and 1. Using Maple's built-in functions `diff` and `solve', find an explicit expression, in terms of the parameters d1,d2 for the Nash Equilibrium. (Make sure that when d1=1, d2=1 you get (1/3,1/3)).
Added Feb. 7, 2022: The students' nice solution can be found in this directory
(In-person) Lecture 6, Monday, Feb. 7, 2022
Subject: hw#6
and an attachment
hw6FirstNameLastName.txt
and indicate whether it is OK to post. If you do not say "Please do not post", it will be posted.
evalf(PayOffG(G,p1,p2))
Write a procedure
TagedyOfTheCommons(v,G,c,n)
that inputs
(i) An expression,v, for a function that is positive in the variable G, in 0 ≤ G ≤ 1, but whose first and second derivatives are negative there (like in Fig. 1.2.4 in the book with G_max=1);
(ii) a number c, the cost of buying and caring for the goat, (between 0 and 1);
(iii) a positive integer n, the number of farmers;
and outputs the Nash Equilibrium G*.
Hint: use Maple's "diff" command, and "fsolve" command to solve the equation
What did you get for
seq(TagedyOfTheCommons(sqrt(1-G),G,0.5,n),n=1..10);
seq(TagedyOfTheCommons((1-G)^(1/4),G,0.5,n),n=1..10);
seq(TagedyOfTheCommons((1-G)^(3/4),G,0.5,n),n=1..10);
Confirm that as the number of farmers get larger, the total number of goats, in the Nash equilibrium, gets farther and farther away from the social optimum.
Added Feb. 14, 2022: The students' nice solution can be found in this directory
Lecture 7 (Thurs. , Feb. 10, 2022)
contains, in addition to previous codes (use Help2();, Help3();, Help4(); Help5(); and Help6(); to see the corresponding list), the following procedures
Subject: hw#7
and an attachment
hw7FirstNameLastName.txt
and indicate whether it is OK to post. If you do not say "Please do not post", it will be posted.
I LOVE ...
where ... is either a favorite number (Pi, e, sqrt(2), Golden Ratio) where the decimal digits are wrapped around the Valentine, or ... is a favorite sequence (Fibonacci, Catalan, Thue-Morse cube-free word (that only has 0's and 1..), or square-free word (that only has 0,1,2), etc.
Submit (in addition to hw7FirstLast.txt, two files ValentineFirstLast.txt (for the Maple code) and ValentineFirstLast.jpg (for the picture).
The students will vote for the best valentine, and the winner will win a chocolate box.
Added Feb. 14, 2022: The students' beautiful Valentines (and Maple source code) can be found here
TypeCounts22(K1,K2)
that inputs a very large positive integer (at least ten million, otherwise there may be some Maple issues, the current code for MNE22(G) does not address some pathological cases, but if you make K1 large enough it should not be a problem), and fairly large positive integer K2 (say, around 10000), uses RG(2,2,K1) K2 times and outputs the following list of length 4 of floating-point numbers
evalf([Number of Games with Exactly One Pure Nash Equilibrium, Number of Games with Exactly Two Pure Nash Equilibrium and No Mixed one, Number of Games with No Pure Nash Equilibrium and one Mixed , Number of Games with Two Pure and One Mixed]/K2)
Run it five times with K1=10^8, and K2=10000 and observe whether you get similar-looking answers (of course, not exactly the same)
(iv) a broken line of the form [0,1]->[0,a]->[1,a]->[1,0]
Similary for Player Column. Altogether there are 16 possibilities. A NE (mixed or pure) is an intersection point of these two Best Response "correspondences"
PayOffG(G,p1,p2)
To write a procedure
PayOffGG(G,p1,p2)
where G is an arbitrary 2-person game, with say, m (=nops(G)) strategies for Player Row, and n (=nops(G[1]) strategies for Player Column, and p1, p2, are probability vectors (i.e. they add up to 1) and outputs a list of length 2 with the payoffs of Player Row and Player Col.
[Note: You should check that they add-up to 1, and return FAIL if they don't, but do not check that they are all posiitive, since we may need it for symbolic probability vectors like [x1,x2,1-x1-x2]]
Added Feb. 14, 2022: The students' beautiful homework is in this directory
(In-person) Lecture 8, Monday, Feb. 14, 2022
Today we admired the beautiful valentines. The data for the contest is here, and here are the oucomes. Congratulations to Yuxuan Yang, Lucy Martinez, and Robert Dougherty-Bliss for being voted the best entries. However, I believe that they were all very good!.
Subject: hw#8
and an attachment
hw8FirstNameLastName.txt
and indicate whether it is OK to post. If you do not say "Please do not post", it will be posted.
Prove that in the version of the Snwodrift game in section 1.4, with T>R>S>P, (Refuse,Pay) and (Pay,Refuse) are two pure Nash equilibria. Either by hand, or using Maple, prove that in addition there is a mixed Nash equilibrium. Find an explicit expression for that additional Nash equilibrium, in terms of the parameters T,R,S,P, and check it for random numerical values using MNE(G).
Added Feb. 21, 2022: The students' beautiful homework is in this directory
Lecture 9 (Thurs. , Feb. 17, 2022)
Programs done on Feb. 17, 2022
C9.txt
contains, in addition to previous codes (use Help2();, Help3();, Help4();, Help5();, Help6();, Help7();, to see the corresponding list), the following procedures
MNE2(G): The set of mixed Nash equilibria for a 2-person game with each player having two strategies, where G is given as a 2 by 2 bimatrix. It gives all the pairs (p1,p2) such that if Player Row plays stragety R1 with prob. p1 (and hence strategy R2 with prob. 1-p1) and Player Col plays stragety C1 with prob. p2 (and hence strategy C2 with prob. 1-p2) these stochastic stragies are Best responses to each other, in the sense that for either player deviating from them (while the other player keeps his or her strategy) will make her or his EXPETED payoff worse. Try:
G:=RG(3,3,100); MNE2(G):
Subject: hw#9
and an attachment
hw9FirstNameLastName.txt
and indicate whether it is OK to post. If you do not say "Please do not post", it will be posted.
StatSymGames(n,K1,K2)
that inputs a positive integer n (the number of players), and positive integers K1 and K2 (where K1 is very big, say 10000000, and K2 is between 1000 and 2000) , and generates K2 random SYMMETRIC n-player games (with payoffs between 0 and K1), and outputs the following list <> evalf([Number of Games with Only Pure Nash Equlibria, Number of Games with Only Mixed Nash Equlibria,Number of Games with both pure and mixed Nash Equlibria,Number of Games where the Social Optium is NOT one of the NE]/K2)
Run
StatSymGames(3,10^10,1000);
several times, and make sure that you get similar answers. Then, computing-time permitting (I did not try it out!)
Do the same things for
StatSymGames(4,10^10,1000);
and
StatSymGames(5,10^10,1000);
[[[R,R],[S,T]],[[T,S],[P,P]]
with the assumption
T > R > S > P
Find a closed-form expression, in terms of the parameters T,R,S,P for the sum of tha payoffs in the MIXED Nash equilibrium, that always exists.
[Hint: use the answer to ex. 3 in hw8]
For all 24 orderings of T,R,S,P. How many of these permutations yield a mixed NE?
For all possible 9!=362880 permutations of ordering a11,a12,a13,a21,a22,a23,a31,a32,a33, find the mixed Nash equibria for the symmetric game
[a11,a11],[a12,a21],[a13,a31]
[a21,a12],[a22,a22],[a23,a32]
[a31,a13],[a32,a23],[a33,a33]
and find how many have only mixed starategies.
Added Feb. 21, 2022: The students' beautiful homework is in this directory
(In-person) Lecture 10, Monday, Feb. 21, 2022
Subject: hw#10
and an attachment
hw10FirstNameLastName.txt
and indicate whether it is OK to post. If you do not say "Please do not post", it will be posted.
CountInstablities(M,W,pi)
That enters ranking tables M,W, and a current matching pi, and counts how many of the n*(n-1) ordered pairs of husbands 1 ≤ i1, i2 ≤ n are such that i1 is married to j1, i2 is married to j2, but i1 would rather be married to j2 (instead of his current wife j1) and j2 would rather be married to i1 (rather than her current husband i2)
GFstab(n,K,x)
That inputs positive integers n and a large positive integer K, generates K times, random ranking tables using RT(n), and a random matching, pi, and outputs the polynomial in x (of degree ≤ n(n-1)), whose coeff. of xi is the number of those random choices that lead to exactly i instablities. By taking the first and second derivatives w.r.t. to x, estimate the expectation and variance of the "number of instabilities".
Added Feb. 28, 2022: The students' beautiful homework is in this directory
Lecture 11 (Thurs. , Feb. 24, 2022)
Programs done on Feb. 24, 2022
C11.txt ,
contains , in addition to the procedures of C10.txt, listed by Help10();, the following procedures
Subject: hw#11
and an attachment
hw11FirstNameLastName.txt
and indicate whether it is OK to post. If you do not say "Please do not post", it will be posted.
CheckOpt(M,W)
that inputs M and W, finds the matchings where the men do the proposing and the one where the women do it, and verify that each man got a better (or equal) wife (in his eyes) and each woman get a worse (or equal) husband in the first case.
EstStat(n,K)
That inputs a positive integer n , and a large positive integer K (at least 1000), generates K exaples of M,W (using RT(n)) and outputs the average number of proposals, followed by the standard-deviation.
Run
EstStat(n,10000)
for n=10..., 150, (with increments of 10)
Can you conjecture an approximate "trend"?
[1,3,2,4], [3,2,1,4], [3,1,4,2]
By using
CountInstablities(M,W,pi)
that you wrote for hw10, write a procedure
MayBeNotSoStupidFindStable(M,W)
that starts out with a random permutation, looks at all its n-1 neighbors, and moves to the one with the least number of instablities. It keeps doing it until you either get a stable matching, or get into a "valley", where there are still instabilities, but none of the neighbors has less instabilities (then return FAIL). It should also record the number of iterations. How often does it give you a stable matching? Is it sometimes better than Gale-Shapley?
Added Feb. 28, 2022: The students' beautiful homework is in this directory
(In-person) Lecture 12, Monday, Feb. 28, 2022
The data strunctre is a "table"
FM(BM(g,n),n)=g and BM(FM(f,n),n)=f
Subject: hw#12
and an attachment
hw12FirstNameLastName.txt
CheckBMFM(n,K) and CheckFMBM(n,K)
that inputs a random function, call it f, defined on subests of {1,...,n} and chackes that FM(BM(f,n),n)=f and BM(FM(f,n))=f, viewed as tables, by checking that you always get the same value if you evaluate it at any subset of {1,...n}
Why doing, for a given set-valued table generated by RG(n,K), for specific n and K, e.g. n=3, K=10,
evalb(f=BM(FM(f,n),n)) gives you, in Maple, "false"?
while it should be "true" (and if you evaluate it at specific sets they always agree)
CheckSuperAdditivity(f,n)
that inputs a function on the set of subsets of {1, ...,n} and outputs true iff for every two disjoint subsets S and T of {1,...,n}, you have
f[S union T] ≥ f[S] + f[T]
Check for a few random choices of FM(RG(5,20),5), it is indeed super-additive
After loading
C12.txt , to a Maple session,
Enter the following one-line Maple code
A:=proc(n) local f,S,PN,i1:PN:=powerset(n):for S in PN do f[S]:=nops(S)!:od: BM(f,n)[{seq(i1,i1=1..n)}];end:
What OEIS (if any) is this sequence? Can you explain why?
Added March 7, 2022: The students' beautiful homework is in this directory
Lecture 13 (Thurs. , March 3, 2022)
Programs done on March 3, 2022
C13.txt ,
contains , in addition to the procedures of C12.txt, listed by Help12();, the following procedures
Subject: hw#13
and an attachment
hw13FirstNameLastName.txt
Same as above, but using the second formula there.
Call it SVC1(f,n,C). Make sure that
SVC1(f,n,{i}) is the same as SVi(f,n,i). It is analogous to SV(f,n)
Hint: what the article calls "synnergy" is our own BM(f,n). What they call v(S) is our f[S].
What they call φi(v) is our SVi(f,n,i).
Implement the formulas for φi,j(v) Given there, using both formulas, call them SVij1(n,f,i,j) and SVij2(n,f,i,j)
Make sure that
add(SVij1(n,f,i,j),j=1..n)=SVi(n,f,i) ,
add(SVij2(n,f,i,j),j=1..n)=SVi(n,f,i) ,
for randomly chosen functions f, gotten from RSG(8,1000), and all i from 1 to 8.
Added March 7, 2022: The students' beautiful homework is in this directory
(In-person) Lecture 14, Monday, March 7, 2022
Subject: hw#14
and an attachment
hw14FirstNameLastName.txt
Pick three elections at random, write down the weights [number of seats] (that add up to 120) for each of them, call it L, and use SSVc(L,61) to find their Shapley-Shubik values.
Added March 13, Vikrant Ashvinkumar and Robert Doughery-Bliss wrote nice Python code that enabled the systematic computation for all the elections. See here and here .
Let f(n,i) be the Shapley-Shubik value of player i (i goes from 1 to 2n) if the weights are [1,2,....2*n] and the cut-off is n(2n+1)+1. Can you find a formula, or at least an estimate, or an asymptotic formula, for f(n,i)?
Added March 13, 2022: The students' beautiful homework is in this directory.
Lecture 15 (Thurs. , March 10, 2022)
Ac(n): Same as A(n) above but much cleverer and faster, using the third-order recurrence gotten from the amazing Almkvist-Zeilberger algoirthm.
PiApc(n): Same as PiAp(n) but using Ac(n) rather than A(n), hence much faster for larger n.
Added March 21, 2022: Read Vikrant Ashvinkumar's insightful comment.
Subject: hw#15
and an attachment
hw15FirstNameLastName.txt
DecDigits(a,K)
that inputs a number a and outputs the LIST of its first K digits. For example,
DecDigits(Pi,6);
should be [3,1,4,1,5,9]
Read the excellent article by the late (amazing) Borwein brothers (Jonathan and Peter) and the equally amazing Carl Dilcher (may he live a long life), and after settings Digits to at least 1000, check out this phenomena by using the abobe procedure DecDigits to write a procedure
WrongDigits(a,b,K)
that inputs two numbers a and b and a positive integer K and outputs the list of places where their decimal digits differ up to the K-th place. Try:
Digits:=1000: WrongDigits(Pi,NorthM(500000),100):
[If it does not take too long, try:
Digits:=1000: WrongDigits(Pi,NorthM(5000000),200):
]
Is that sequence in the OEIS.
Read the excellent paper by G. M. Phillips, and implement Archimedes's method (adapted to your day) by writing a procedure
Archimedes(k,N)
that inputs a small positive integer k, and a positive integer N and outputs what Phillips calls pn and Pn, i.e. HALF the perimeter of an inscribed and circumscribed polygon with k*2N sides. Note that Archimeder(k,1) is [2*k*sin(Pi/k),2*k*tan(Pi/k)]. Confirm Archimides' calculation by typing
Archimedes(3,5)
BestMachin(a)
That finds the (hopefully) unique k such that FindMachin(a,k) is as small as possible
Is [seq(BestMachin(a),a=2..10)] in the OEIS? If not, should it be?
by using the Maple command "time" show why, starting at a certain n, PiApc(n) is so much faster than PiAp(n). For what values of n does
PiApc(n) ;
returns something in less than 5 seconds, while
PiAp(n);
is hopeless?
Jesus(n)
that finds the sum of the first n terms of Jesus Guillera's beautiful series for 128/π2 given in his homepage (in a Ramanujan-style notation, that must be deciphered). What is the error in Jesus(20)?
What's nice about Machin's formula is that FindMachin(1/5,4) has numerator 1 (or rather -1). Do there exist integres a and k ≥ 2 such that FindMachin(a,k) has this property that its numerator is -1 or 1?
Is there a k and integers 6 ≤ a[1] ≤ a[2] ≤ a[k], b such that
ATAN([1/a[1], ...,1/a[k],1/b])=1 OR ATAN([1/a[1], ...,1/a[k],-1/b])=1
Note that, thanks to Machin
ATAN([1/5, 1/5,1/5,1/5,-1/239])=1
Added March 13, 2022: The students' beautiful homework is in this directory.
(In-person) Lecture 16, Monday, March 21, 2022
Subject: hw#16
and an attachment
hw16FirstNameLastName.txt
IsCondorcet(P)
that inputs a voting profile P with v:=nops(P) voters and n:=nops(P[1]) candidates, and outputs true iff you have an instance of the Condorcet paradox. For example
IsCondorect([[1,2,3],[2,3,1],[3,1,2]]); should be "true" but IsCondorect([[1,2,3],[1,2,3],[1,3,2]]); should be "false"
(Hint, a voting profile P is Condorcet iff SV(Tour(P)) is NOT a permutation of [0,1,..., n-1])
ExactCond(n,v)
that inputs positive integres n and v and outputs the EXACT ratio of voting profiles that are Condorcet.
EstCond(n,v,K)
that inputs a large positive integer K, and integers n and v , and generates K random voting profiles with v voters and n candidates, and oututs the ratio (in floatig points) of those that happen to be Condorcet.
Check it against ExactCond(n,v) for n=3 and v=3,4,5.
for each of n=3,4,5, and v=20,30,40, run
EstCond(n,v,10000)
several times, make sure that you get close answers. Do you see a trend?
Borda(P)
that inputs a voting profile P and outputs the Borda score of the n candidates.
CondorcetRank(P)
that inputs a voting profile P and outputs the ranking according to the Condorcet criterion. For example,
CondorcetRank([[1,2,3],[1,2,3],[1,2,3]]);
should output [{1},{2},{3}]
while
CondorcetRank([[1,2,3],[2,3,1],[3,1,2]]);
should output [{1,2,3}]
BordaRank(P)
that inputs a voting profile P and outputs the ranking according to the Borda criterion. For example,
BordaRank([[1,2,3],[1,2,3],[1,2,3]]);
should output [{1},{2},{3}]
while
BordaRank([[1,2,3],[2,3,1],[3,1,2]]);
should output [{1,2,3}]
Added March 27, 2022: The students' beautiful homework is in this directory.
Lecture 17 (Thurs. , March 24, 2022)
Comps(n,k): The set of all compositions of n into exactly k parts (with non-negative entrties)
There is no hw17 (lucky you!)
(In-person) Lecture 18, Monday, March 28, 2022
Number of G-Condorcet vote-count-profiles with 2*n-1 voters
Subject: hw#18
and an attachment
hw18FirstNameLastName.txt
SeqCoStupid(N)
that inputs a positive integer N and outputs the first N terms of the sequence
"Number of voting-profiles (NOT vote-count profiles) with 2*n-1 voters that lead to 1->2->3->1"
Read this gem and implement Theorem 1 to write a procedure
SeqCoSmart(N)
that does the same thing as SeqCoStupid(N), but hopefully faster.
[Hint, use the taylor command to exapand the rational function in t to N+1 terms, extract the first N coefficients of t, getting polynomials in the 6 variables, x123, ..., x321, and then apply the "umbra" as described in the paper.
How much faster is SeqCoSmart(20) than SeqCoStupid(20)?
Find a nice combinatorial proof (if possible a bijective one) of the fact that we conjectured in class (and that can be made into an ugly proof) that the number of vote-count-Conrorcet scenariors with 2*v-1 voters is binomial(v+3,5) (recall that the total number of vote-count scenarios is binomial(2*v+4,5)
Added March 31, 2022: It seems that Rebecca Embar solved it! She won the 10 dollars, but you are welcome to do it for fun.
Added April 4, 2022: Read Rebecca Embar's beautiful bijective proof and accompanying Maple code here ,
is a polynomial of degree d in n.
Using GP(L,n), as a subroutine, first write a procedure
GQP1(L,p,n)
that inputs a list L and tries to guess a quasi-polynomial of period p that fits the data, and then write
GQP(L,n)
that tries out p=1, p=2, until either a success or failure. the output should be a list of polynomials in n,let's call it P, such that if n mod p=i (but we take i=1,...p, rather than the usual i=0,..,p-1) then L[n]=P[i][n]. For example
GQP([1,-2,3,-4,5,-6,7,-8,9,-10,11,-12,13,-14])
should output [n,-n]
Added April 4, 2022: The students' beautiful homework is in this directory.
Lecture 19 (Thurs. , March 31, 2022)
It does not agree with NuC of C18.txt with G=[[0,1,1],[0,0,1]] (see homework below for a reward for fixing this discrepancy)
Subject: hw#19
and an attachment
hw19FirstNameLastName.txt
x1a1 .... xkak -> (a1+...+ak)!/(a1!*...*ak!)
(ii) What are the A-mumbers (if they exist) of the following sequences
(a) UmbT(x+y,[x,y],20);
(b) UmbT(x+y+z,[x,y,z],20);
(c) UmbT(x1+x2+x3+x4,[x1,x2,x3,x4],20);
(d) UmbT(1+2*x+3*y,[x,y],20);
(e) UmbT((1+x)*(1+y)*(1+z),[x,y,z],20);
[Optional challenge, 10 dollars to be divided among the solvers]
To my dismay, procedure Zs does not agree with procedure NuC(v,G) of C18.txt . In other words, for example
Zs(10) is NOT [seq(NuC(v,[[0,1,1],[0,0,1]]),v=1..10)]
I don't have any clue why. At least one of them is wrong (possibly both!). Please fix it.
Added April 4, 2022: quite a few people indicated the problem, but only Blair Seidler wrote the corrected code that is now part of C18.txt . Blair won the ten dollars.
Added April 4, 2022: The students' beautiful homework is in this directory.
(In-person) Lecture 20, Monday, April 4, 2022
Subject: hw#20
and an attachment
hw20FirstNameLastName.txt
ConjLP(R)
that inputs a finite set of positive integers R, and outputs the pair
[M,C]
where M is a positive integer ≥ 2 and C is a subset of {0,1,...,M-1} such that PR(n,R)[1]=0 if and only if n mod M belongs to C. For exmaple,
ConjLP({1,2})
should output
[3,{0}]
[Hint, first output LP(10000,R), call it, L, say, then look for the smallest M such that
convert(L mod M,set)
has less than M elements. This is your conjectured M. Then, for that M, convert(L mod M,set) is your conjectured C.
ProveLP(R,M,C)
that proves automatically the conjecture that indeed n is a losing position for the R-game iff n mod M belongs to C, or returns FAIL.
Hint: the defining propery of the set of losing positions of a game is that every legal move (in this game, subtracting an element of R), is NOT in that set, and for every element, n, NOT in that set, there exists an element r, in R, such that n-r is in the set.
The classical game of k-file Nim consists of k piles having n[1],..., n[k] pennies respectively, and a legal move consists of taking as many pennies as one wishes (from 1 to the whole pile) from ONE pile. For exmaple from the position [3,2,2] one can reach, in one move
[2,2,2],[1,2,2],[0,2,2];[3,1,2],[3,0,2];[3,2,1],[3,2,0];
Write a procedure
Nim(N)
that inputs a list of non-negative integers of length k:=nops(N) and outputs 0,{} if it is a losing position, and 1,S, if it is a winning positiion where S is a list of pairs {[a,b]} meaning: remove b pennies from the a-th pile. For example
Nim([3,3]) should output "0,{}{ while Nim([7,3]) should output 1,{[1,4]}
[Modified April 7, 2022: By symmety, the winning vs. losing status is invariant under permutation, so it would be more efficient just to output the list of weakly-increasing (or if you wish, weakly-decreasing) losing positions.
Write a procedure
NimL(k,N)
that inputs a positive integer k, another positive integer N and outputs the set of lists of length k with entries ≤ N that are losing positions for k-pile Nim. For example
NimL(2,3);
should output {[0,0],[1,1],[2,2],[3,3]}
Nim2V(a,b)
that inputs non-negative integers a and b and outputs 0,{} or 1,S where the members of S are either of the form [i,0],[0,i],[i,i]. For example,
Nim2V(2,1)
should output 0,{}
Nim2V(3,2)
should output
1,{[1,1],[2,0]}
[Added April 7, 2022: thanks to Natasha Ter-Saakov for correcting a previous error. She won a dollar]
Nim2VL(N)
that inputs a positive integer N and outputs the LIST of pairs [a,b], 0 ≤ a ≤ b ≤ N, that are losing positions for the above game. with increasing order of the first component.
Characterize such losing pairs.
Added April 11, 2022: The students' beautiful homework is in this directory.
[Also see Lucy Martinez's interesting observatiobs.]
Lecture 21 (Thurs. , April 7, 2022)
THIS LECTURE IS IN FOND MEMORY OF Jerrold B. Tunnell (Sept. 16, 1950- April 1, 2022).
[Added April 13, 2022: See the bottom of this sad link .
C21.txt , contains
[Needs more work!]
Tn(n,A,B,C): the set of triples [x,y,z] in Z^3 such that n=A*x^2+B*y^2+C*z^2
[Needs more work!]
Subject: hw#21
and an attachment
hw21FirstNameLastName.txt
IsSquareFree(n)
that inputs a positive integer n and outputs true or false according to whether n is a product of DISTINCT primes or not, respectively. Use it to get procedure JTseqW(N) of C21.txt to work properly. It is based on the the wikipedia article on Tunnell's theorem
Implement (correctly!) the clever construction of Jerrold Tunnell's brilliant academic son Sasa Radomirovic.
[Added April 11, 2022: Dr. Yuxuan Yang met this challenge! (and also found a typo!). See his brilliant implementation
Added April 11, 2022: The students' beautiful homework is in this directory.
(In-person) Lecture 22, Monday, April 11, 2022
Subject: hw#22
and an attachment
hw22FirstNameLastName.txt
LP(G)
that inputs a directed graph w/o cycles, G (let n:=nops(G)) and outputs the subest of {1,...,n} of its losing positions.
AvNuLP(n,p,K)
that inputs a positive integer n, a rational number p between 0 and 1 and a large integer K and outputs an approximation to the average size of the set of losing positions, for a random directed graph (w/o cycles) with n vertices, by averaging over K random graphs gotten from RDG(n,p).
What did you get for
AvNuLP(n,p,10000)
for 3*4=12 cases
n=10,50, 100; p=1/5,2/5,3/5,4/5
Added April 18, 2022: The students' beautiful homework is in this directory.
Lecture 23 (Thurs. , April 14, 2022)
LaGn(G): Same as LaG(G) from C22.txt, but hopefully better (at least more adaptable for the Centipede games, coming up next)
Els(): The Elster Centipede game taken from this brilliant opinion, using our data strcuturee for genearlized Centipede game G,[[Sink1, [Reward1a,Reward1b]], [[Sink2, [Reward2a,Reward2b]], ...
Subject: hw#23
and an attachment
hw23FirstNameLastName.txt
WikiCent(n)
That generalizes the four-stage game given there with payoffs (1,0),(0,2),(3,1),(2,4) at the bottom and to the extereme right (3,3)
but please change the (3,3) to (3.1,3.1)
to a 2n-stage game with payoffs, at the bottom
(1,0),(0,2),(3,1),(2,4),(5,3),(4,6) ...., (2n-2,2n)
and to the extereme right (2n-1+ 0.1,2n-1+0.1)
It should be expressed in our data-structure like in Els() above. Name the n non-leaves on the top row in order, followed by the leaf at the extreme right, followed by the leaves at the bottom.
The second part should be the reward table (but with our convention that the pair of rewards is [a,b], where a is the reward of the player currently at that vertex and b the reward of the other player. Regardless whether they happen to be Player I or Player II.
[{3,4,5},{3,4,5},{6},{},{},{}], [DoronZeilberger,JaneLegrange,CeliaZeilberger,TamarZeilberger,HadasZeilberger,AlexandraAhmed]
Another example
[{3,4,5},{3,4,5},{},{},{6},{}],[Adam,Eve,Cain,Abel, Seth, Enos]
(Of course, Enos had children, or else we would not be here, but this is the directed graph when Enos was a child)
Apply GenS(G), and LaGn(G) to your family graph. For the most ancient generation in GenS(G) (the last in the list), find whether they are winning or losing if you use it to play the game. For example in Dr. Z.'s graph, Alexandra,Tamar, and Hadas are "losers", while Doron, Jane, and Celia are "winners".
TEN DOLLAR PRIZE FOR THE LARGEST NUMBER OF GENERATIONS!
Added April 18, 2022: The students' beautiful homework is in this directory.
(In-person) Lecture 24, Monday, April 18, 2022
WikiCent(n): The centipede game 2*n non-leaf vertices and 2*n+1 leaves wich that 1 goes 2 and 2*n+2, 2 goes to 3 and 2*n+3, ..., 2*n goes to 2*n+1 and 4*n+1, and the reward pairs for vertex 2*n+1 is [2*n-1+0.1,2*n-1+0.1], the reward pair of vertex 2*n+2 is [0,1], and the reward pair for vertex [2*n+3+i] (i=0..2*n-2) is [i,i+2]
WikiCent1(n): Same as WikiCent(n) but with ONE edge removed, making it beter for BOTH players
Lecture 25 (Thurs. , April 21, 2022)
Subject: hw#25
and an attachment
hw25FirstNameLastName.txt
BestPrune(G,R)
that inputs a directed graph G followed by the set of Rewards {[i,[a,b]], i is a sink} and tries to see whether there exists an edge whose deletion will make the label of vertex 1 (the pay-offs) better for BOTH players. It should output the edge or FAIL. Test it with
BestPrune(Els());
BestPrune(WikiCent(20));
RandCent(n,p,K)
that generates a random centipded pair G,R, where G is RDG(n,p) and the payoffs for the sinks of G are random integers from 0 to K
FindParadox(n,p,K,K1)
That tries K1 times to generate RandCent(n,p,K) and stops as soon as it finds something that is not FAIL. If it can't find anything, it should return FAIL. What did you get for
FindParadox(30,1/2,100,1000)?
Added April 25, 2022: The students' beautiful homework is in this directory.
(In-person) Lecture 26, Monday, April 25, 2022
Subject: hw#26
and an attachment
hw26FirstNameLastName.txt
NimSum(a,b)=SGnim([a,b])
for all non-negative integers a and b
SGwyt(a,b)
that finds the Sprague-Grundy value of the position [a,b] in Wythoff's game whose rules are the same as 2-pile Nim, except that one can also remove the SAME number of pennies from both piles.
FindUP(L)
that inputs a list L and outputs a pair of lists L1,L2 such that (conjecturally)
L=[op(L1),op(L2)^infinity]
i.e., after an initial segment L1, it starts being periodic of period nops(L2)
[seq(SGwyt(i,b)-b,b=0..infinity)]
for i=0,1,2,3 (the further the better!)
SGwyt(5,10100)
While it is very fast to compute SGnim([10100, 2*10100]), do it! Find
SGwyt([10100, 2*10100])
More generally, find a fast algorithm (similar to NimSum), to compute SGwyt(a,b)
Added May 2, 2022: The students' beautiful homework is in this directory.
Lecture 27, Guest Lecture by Dr. Neil Sloane (Thurs. , April 28, 2022)
Today we were lucky to have a guest-lecture by guru Neil Sloane. Here are his slides,
Optional Homework due whenever
Investigate some of the fascinating open problems, and if possible solve them.
(In-person) Lecture 28, Monday, May 2, 2022
There is no Maple code for today. We first proved Ariel Rubinstein's seminal result that if two players take turns proposing to share a dollar, and the other player can accept the proposal, and end the game immediately, or refuse, in which case it is his turn to propose, and they do it indefinitely. Due to inflation the current value shrinks by a factor of δ each time period, so it is to both players' interest to end the game as soon as possible, since the total amount keeps shrinking. Assuming that there is an equilibrium offer of the first player, let's call it R, i.e. to offer 1-R to the second player, if the second player refuses, now he is in the identicail position that the first person (since infinity-1=infinity), hence in equilibrium
1-R=Rδ
Solving for R, we get the following theorem:
Ariel Rubinstein's theorem: The first player should offer δ/(1+δ) to the other player, and keep 1/(1+δ) for himself.
We than discussed the repeated Prisoner's dillemma with discount factor δ and proved that if the payoff matrix is
[[P,P],[T,S]]
[[S,T],[C,C]]
with
T > C > P > S
[T is the temptation payoff, C is the cooporation payoff, P is the punishment payoff (for defecting), and S is the sucker's payoff.]
If you apply the trigger stragegy: Cooporate as long as your opponent does, but as soon as he defects, play Nash equilbrium. If
δ ≥ (T-C)/(T-P)
It is a so-called subgame perfect Nash Equilibrium for both opponents to apply the above trigger strategy, and they both will live happily ever after.
Work on your project and submit.
Added May 10, 2022: Read the students' FASCINATING PROJECTS
On May 10, 2022, 8 out of the 12 students were able to come to the annual field trip to the Princeton cemetery (and this year also to St. Paul cemetery not far from it). We first visited Kurt Gödel, and John von Neumann (co-founder of Game Theory), then visited the graves of my good friend Herb Wilf's advisor Herbert Robbins, then the great "solver of problems", Dave Robbins (no relation), that has a beautiful engraving of 3D Ferrers diagrams of plane partitions, then the grave of Rutgers RUTCOR founder, Peter Hammer, then (since we had some extra time) the grave of Aaron Burr, and finally that of John Tukey (of Fast Fourier Transform fame).
Then we went to St. Paul's cemetery and tried to find the grave of John Nash. I promised to give the book "The Essential John Nash" to the person who would find it. The lucky winner was Vikrant Ashvinkumar.
GROUP PICTURE IN FRONT OF THE GRAVE OF JOHN AND ALICIA NASH
After that we had a tasty dinner at the nearby Amazing Thai restaurant, also attended by my beloved wife, Dr. Jane D. LeGrange.