Last Update: March 9, 2026
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 enumerative and algebraic combinatorics, focusing on elegant bijective proofs. 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.
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 David Hilbert 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 #)
hw2DavidHilbert.txt and hw3DavidHilbert.txt
#Please do not post homework
or
#OK to post homework
Followed by
#Your Name, Date, Assignment X
Subject: HomeWork#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.
[For novices] Go over today's Maple code and try to understand it.
NuFP(pi)
that inputs a permutation pi of {1,...,n}, where n:=nops(pi) and outputs the number of places i from 1 to n, where pi[i]=i. For example
NuFP([2,1,3,5,4])=1
WtE(n,x)
that inputs a non-negative integer and a variable x and outputs the sum of xNuFP(pi) summed over all permutations of length n.
For which k , 0 ≤ k ≤ 5, are the following sequences in the OEIS, and what are their A number? (if thye exist)
[seq(coeff(WtE(i,x),x,k),i=0..8)]
Added Jan. 25, 2026: The nice homework solutions of students that kindly agreed to share their homework solutuions can be found in this directory
We did the following Maple code:
C2.txt , Contains procedures
Subject: HomeWork#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.
Go over today's Maple code and try to understand it.
Part I: Write a procedure
Bij(pi)
that inputs a permutation pi of {1,...n}, where n:=nops(pi), and outputs the pair [i,pi'], where i is the location of n, and pi' is the permutation of {1, ..., n-1} obtained from deleting n. For example
Bij([3,1,4,6,2,5])=[4,[3,1,4,2,5]]
Part II: Write a procedure
InvBij(Pair)
that inputs a pair Pair of the form [i,pi'], such that pi' is a permutation of {1,...,n-1} where n:=nops(pi')+1, and i is an integer between 1 and n inclusive, and outputs the permutation pi of {1, ...,n} obtained from pi' by inserting n right befire the i-th place (and if i=n, at the end. For example
invBij([4,[3,1,4,2,5]]=[3,1,4,6,2,5]
a(n)=n*a(n-1)
Part I: Using procedure, Contain3(pi,sig), write a procedure
Contain3S(pi,S) that inputs a set of patterns, all of length 3 and outputs true if and only of pi contains at least one of the patterns in S. Note that for any pattern sig of length 3, Contain3S(pi,{sig}) is the same as Contain3(pi,sig). For example
Contain3([1,2,4,3],{[1,2,3],[3,2,1]}) is true but Contain3([4,3,2,1],{[1,2,3],[2,3,1]}) is false.
Part II: Using Contain3S(pi,S) write a procedure
AvoidPer(n,S): inputs a pos. integer n and a set of patterns of length 3, S, outputs the subset of permute(n) that avoids all the patterns in S.
Part III: Conjecture an explicit formula for the number of permutations of {1, ...,n} avoding both the patterns 123 and 132, in other words, nops(AvoidPer(n,{[1,2,3],[1,3,2]})), by entering
seq(AvoidPer(n,{[1,2,3],[1,3,2]}),n=1..8)
Added Feb. 1, 2026: The nice homework solutions of students that kindly agreed to share their homework solutuions can be found in this directory
We did the following Maple code:
C3.txt , Contains procedures
d(n)=n*d(n-1)+(-1)^n
Subject: HomeWork#3 (or Homework #2#3 if you use one email message)
and an attachment (along with possibly hw2)
hw3FirstNameLastName.txt
and indicate whether it is OK to post. If you do not say "Please do not post", it will be posted.
Mul(pi,sig)
that inputs permutations pi, sig of the same length (n) and outputs the product (i.e. composition in the sense of functions) defined by sig[pi[i]], i=1..n. For exmpla
Mul([3,1,4,2],[4,1,2,3])=[2,4,3,1]
Pow(pi,k)
that compute pik i.e. pi multiplied by itself k times.
Then write a procedure, Idemp(n,k) that that finds the set of permutations of {1, ...,n} such that pik is the identity permutation [1,2,...,n]
Idemp(3,2)={[1,2,3],[1,3,2],[3,2,1],[2,1,3]}
[Idemp is short for "idempotent"]
d(n)=(n-1)*d(n-1)+(n-1)*d(n-2)
[Hint, if you look at the permutation in cycle decomposition, a derangement has no 1-cycles]. Look where n can reside.
[Solved by Aurora Hiveley
(see here),
Austin DeCicco, (see here),
Jike Liu, (see here),
]
d(n)=n*d(n-1)+(-1)^n
Hint: It is easier to prove that the latter recurrence implies the former, then use the fact that d(n)-n*d(n-1)=(-1)^n implies
d(n)-n*d(n-1)=(-1)*(d(n-1)-(n-1)*d(n-2)
Added Feb. 1, 2026: The nice homework solutions of students that kindly agreed to share their homework solutuions can be found in this directory
C4.txt , containing procedures:
Subject: HomeWork#4 (or Homework #4#5 if you use one email message)
and an attachment (along with possibly hw5)
hw4FirstNameLastName.txt
and indicate whether it is OK to post. If you do not say "Please do not post", it will be posted.
S:={seq(randperm(3),i=1..3)}; [seq(nops(AvoidPer(n,S)),n=1..8)];
how many of then are in the OEIS?
For those that are not in the OEIS, can you conjecture a formula?
how many of then are in the OEIS?
For those that are not in the OEIS, can you conjecture a formula?
a(n)=Sum(a(k)*a(n-1-k),k=0..n-1)
Use this recurrence (with option remember) to crank-out many terms, and conjecture an explicit formula.
Added Feb. 8, 2026: The nice homework solutions of students that kindly agreed to share their homework solutuions can be found in this directory
C5.txt , Contains the following procedures (in addition to those of C3.txt, see above)
Subject: HomeWork#5 (or Homework #4#5 if you use one email message)
and an attachment (along with possibly hw4)
hw5FirstNameLastName.txt
and indicate whether it is OK to post. If you do not say "Please do not post", it will be posted.
factor(WtE(powerset(n),S->nops(S),x));
by doing it for n=1,n=2,n=3,n=4, .... Note that this is the weight-enumerator of the set of substes of {1, ...,n} according to the weight S-> xNumberOfElementsOfS
Can you prove it?
NumPat3(pi,sig)
that inputs a permutation pi of any length and a permutation sig of length 3 (if it is not the procedure should return FAIL) and by using redu (of C4.txt), a variable co that starts as 0, and a triple do-loop that adds 1 to co each time it finds a triple that reduces to sig, and outputs the number of occurrences of the pattern sig in pi. For example
NumPat3([2,1,3,4],[1,2,3]);
should output 2, since [pi[1],pi[3],pi[4]]=[2,3,4] and [pi[2],pi[3],pi[4]]=[1,3,4] reduce to 123, and none of the other triplets do.
L:=[seq(WtE(permute(n),pi->NumPat3(pi,[1,2,3]),x),n=1..7)];
(if you have patience, try to do instead L:=[seq(WtE(permute(n),pi->NumPat3(pi,[1,2,3]),x),n=1..8)];) For Which j=0,1,2,3,... are the following sequences are in the OEIS? What are they A numbers? (if they exist)
[seq(coeff(L[i],x,j),i=1..nops(L))];
Prove that for every positive integer n,
WtE(permute(n),inv,x)=(1)(1+x)*(1+x+x^2)*...*(1+x+...+x^(n-1))
[Hint: Construct the permutations of length n from those of length n-1 and inserting n in every-which-way, and depending on the location see how it increases the number of inversions)
factor(WtE(permute(n),pi->nops(CycDec(pi)),x))=x(x+1)(x+2)...(x+n-1)
[Hint: Construct the permutations of length n from those of length n-1, given in cycle structure. Where can you stick the n w/o creating a new cycle?, adding the singleton cycle (n) increases the number by 1]
factor(WtE(permute(n),pi->nops(LtoR(pi)),x))=x(x+1)(x+2)...(x+n-1)
[Hint: Construct the permutations of length n from those of length n-1, by adding 1 to all the entries, and sticking 1 in every-which place. In most places it does not change the number of Left-To-Right maxima, but in one place it does. Which one?
Prove, that for every pos. integer n,
WtE(permute(n),maj,x)=(1)(1+x)*(1+x+x^2)*...*(1+x+...+x^(n-1))
Added Feb. 8, 2026: The nice homework solutions of students that kindly agreed to share their homework solutuions can be found in this directory
C6.txt , Contains the following procedures
Subject: HomeWork#6 (or Homework #6#7 if you use one email message)
and an attachment (along with possibly hw7)
hw6FirstNameLastName.txt
Write proceduers
BoringGames(S,a,b) and NuBoringGames(S,a,b) that output the sets, respectively, the number boring games.
[Hint: in addition to the condition that a and b are never negative you also need to tell Maple that BoringGames(S,a,b) is the empty set if a < b]
Soccer: [seq(NuBoringGames({1},i,i),i=1..20)]:
Old-Time Basketball: [seq(NuBoringGames({1,2},i,i),i=1..20)]:
Today's Basketball: [seq(NuBoringGames({1,2,3},i,i),i=1..20)]:
American football: [seq(NuBoringGames({3,6,7,8},i,i),i=1..20)]:
The famous Foata bijection, Φ inputs a permutation of {1, ...,n} in one-line notation, and outputs another permutation in one-line notation, as follows.
Added Feb. 15, 2026: The nice homework solutions of students that kindly agreed to share their homework solutuions can be found in this directory
One of the greatest experimental mathematicians of all time, Jesus Guillera, sadly died three days ago. His PhD advisor, Wadim Zudilin, kindly agreed to give a
Here are the slides.
After class, the following Maple code was written:
C7.txt , Contains the following procedures
(calling the sum a, the output is sqrt(128/a), since the sum is for 128/Pi^2)
Subject: HomeWork#7 (or Homework #6#7 if you use one email message)
and an attachment (along with possibly hw6)
hw7FirstNameLastName.txt
[The person to get the greatest number of digits will get a prize of 5 dollars]
Added Feb. 15, 2026: The nice homework solutions of students that kindly agreed to share their homework solutuions can be found in this directory
C8.txt , Contains the following procedures
Subject: HomeWork#8 (or Homework #8#9 if you use one email message)
and an attachment (along with possibly hw9)
hw8FirstNameLastName.txt
(xnP(p-1,p)+p-1)*xnP(p-1,p) mod p
you get 0, not enabling you to deduce that it stops producing integers, but for p=43 it breaks down, concluding that xn(43) is NOT an integer (even though it is too big to compute directly)
nops(LtoR(Foata(pi))=nops(CycDec(pi))
Write a procedure
AntiFoata(pi)
that is the inverse of Foata(pi)
That that for every permutation pi of size ≤ 7
AntiFoata(Foata(pi))=pi and Foata(AntiFoata(pi))=pi
xnk(n,k), xnkC(n,k), and xnkP(n,k,p) that give the first value (and those mod p) of the sequence defined by the recursion
xnk(n,k)= (1+xnk(0,k)^k+...+xnk(n-1,k)^k)/n
[Note that xnk(n,2) equals xn(n)]
verify that for k=3, and k=4, the first 15 terms are integers.
[Added Feb. 23, 2026: This was nicely solved by Austin DeCicco. See here. The answser is 89]
[Added Feb. 23, 2026: This was nicely solved by Austin DeCicco. See here. The answser is 97. For more terms see OEIS sequence A288641 ]
Added Feb. 22, 2026: The nice homework solutions of students that kindly agreed to share their homework solutuions can be found in this directory
C9.txt , Contains the following procedures
|(Not A[1]) Interset (Not A[2]) Interset ... (not A[k])|= n-(|A[1]|+|A[2]|+ ... |A[k]|)+ (|A[1] Intersect A[2]|+ ...+ |A[k-1] Intersect A[k]| - (|A[1] Intersect A[2] Intersect A[3]|+ ....)+ .... +(-1)*|A[1] Intersect ... A[k]|
(Note that this formula has 2k terms
Subject: HomeWork#9 (or Homework #8#9 if you use one email message)
and an attachment (along with possibly hw8)
hw9FirstNameLastName.txt
NumberOfProperties(n,L,i)
that inputs a positive integer n, a list of subsets, L, of {1, ..., n}, and a member of {1, ...,n} and outputs the number of sets in L such that i belongs to them. For example
NumberOfProperties(4,[{1,3},{2,4},{3,4}],1)=1, NumberOfProperties(4,[{1,3},{2,4},{3,4}],2)=1, NumberOfProperties(4,[{1,3},{2,4},{3,4}],3)=2, mberOfProperties(4,[{1,3},{2,4},{3,4}],4)=2
PIEgD(n,L,t)
that outputs the sum of tNmberOfProperties(n,L,i) over all i from 1 to n
L:=RanddL(1000,4): evalb(PIEg(n,L,t)=PIEgD(n,L,t));
[Added Feb. 22, 2026: This was nicely solved by Jike Liu. See here ]
Added Feb. 22, 2026: The nice homework solutions of students that kindly agreed to share their homework solutuions can be found in this directory
We did the following Maple code:
C10.txt , Contains the following procedures
Procedures from From hw8:
New procedures:
ParS(n): The set of partitions of n, done stupidly, by first finding Comps(n) and then sorting the members
Subject: HomeWork#10 (or Homework #10#11 if you use one email message)
and an attachment (along with possibly hw11)
hw10FirstNameLastName.txt
CompsG(n,A)
Write a procedure
CompsMod(n,a,S)
that inputs a positive integer n, a positive integer a and a subset S of {0,1,..., a-1} and outputs the set of compositions of n whose entries mod a belong to S. For example
CompsMod(n,1,{0}) is the same as Comps(n), and Comps(n,2,{1}) gives the set of compositions into odd parts.
[Hint: the set of integers of the form s (mod a) is {seq(a*i+s,i=0..infinity)} but you can safely replace it by {s
[seq( nops(CompsMod(n,2,{1})),n=1..10)];
[seq( nops(CompsMod(n,3,{1})),n=1..10)];
[seq( nops(CompsMod(n,5,{1,4})),n=1..10)];
OddParStupid(n)
that looks at all the members of Par(n) and selects those that only have odd parts.
DistinctParStupid(n)
that looks at all the members of Par(n) and selects those that have distinct parts.
Added March 2, 2026: This was solved by Austin DeCicco and Jike Liu
Added March 2, 2026: This was solved by Austin DeCicco and Jike Liu and Lucy Martinez
Added March 1, 2026: The nice homework solutions of students that kindly agreed to share their homework solutuions can be found in this directory
We did the following Maple code:
C11.txt ,
[NOTE: The previous version had a serious error. Thanks to Lucy Martinez (who won 5 dollars) for spotting it. It is now corrected].
Contains the following procedures
The rational function whose Taylor series is such that the coeff. of x^n is the EXACT number of compositions whose parts all obey
Subject: HomeWork#11 (or Homework #10#11 if you use one email message)
and an attachment (along with possibly hw10)
hw11FirstNameLastName.txt
CountNuCompsClever(a,b,A,B,N)
that inputs the positive integers a and b and a subset A of {1, ..., a} and a subset B of {0, ,b-1} and outputs the first N terms of the sequence enumerating compositions all whose parts have the property that i mod a belongs to A and the number of parts mod b belongs to B. In other words, a composition L qualifies if
member(nops(L) mod b,B) is true
and {seq(L[i] mod a, i=1..nops(L))} minus A={}
Hint: To get the first N+1 coefficients, starting at n=0 of the Taylor coefficients around x=0 you use the Maple command
[seq(coeff( taylor(f,x=0,N+3),x,i),i=0..N)]:
CountNuCompsStupid(a,b,A,B,N)
That does the same thing but as follows:
First write a procedure CountNuCompsStupid1(a,b,A,B,n), that finds the number of compositions of n that obeys the stated condition, but first using Comps(n) (there are 2n-1 of them, so you can go to n=16 easily), and for each of them, L, checks whether nops(L) mod b belongs to B, and all the members of L mod a belongs to A and collects them into a set and does nops.
Check that
CountNuCompsClever(a,b,A,B,15)= CountNuCompsStupid(a,b,A,B,15) for
a=3, b=4, A={1,2}, B={0,3} ;
a=2, b=3, A={1}, B={2}
Find as many as possible choices of (a,b,A,B) such that
CountNuCompsClever(a,b,A,B,20)
is in the OEIS
Added March 2, 2026: This was solved by Austin DeCicco
Added March 2, 2026: This was solved by Aurora Hiveley and Jike Liu
Added March 1, 2026: The nice homework solutions of students that kindly agreed to share their homework solutuions can be found in this directory
We did the following Maple code:
C12.txt ,
Subject: HomeWork#12 (or Homework #12#13 if you use one email message)
and an attachment (along with possibly hw13)
hw12FirstNameLastName.txt
A41c(N)
that inputs and outputs the same things as A41s(N) and AS41ok(N), but using The recurrence
p(n)= Sum((-1)^(j-1)*p(n-(3*j^2-j)/2,j=1..infinity)+ Sum((-1)^(j-1)*p(n-(3*j^2+j)/2,j=1..infinity)
with the convention that p(n)=0 if n is negative (so the above sums are only for j such that (3*j^2-j)/2 and (3*j^2+j)/2, respectively, are <=n
[Hint: first write A41c1(n) to compute p(n), and use option remember)
How does time(A41c(1000)) compare to time(A41ok(1000))?
p(A*n+B) mod A=0
How far can you verify it?
[Added March 9, 2026: This was fully solved by Austin DeCicco and JikeLiu, and partially by Aurora Hiveley.]
Added March 8, 2026: The nice homework solutions of students that kindly agreed to share their homework solutuions can be found in this directory
We did the following Maple code:
C13.txt (Here is Lucy's version (with notes)).
Subject: HomeWork#13 (or Homework #12#13 if you use one email message)
and an attachment (along with possibly hw12)
hw13FirstNameLastName.txt
Write a procedure
IsSuperDistinct(L)
that inputs a partition (a member of Par(n), written in the usual way as weakly decreasing list of integers) and outputs true iff for all i, between 1 and nops(L)-1, L[i]-L[i+1]>=d
Using this, write a procedure
SuperDistinctPars(n,d)
That outputs the subset of Par(n) consisting of d-super-distinct partitions
ParMod(n,a,A)
that inputs a positive integer n, another positive integer a, and a subset, A, of {0,1, .., a-1} and outputs the subset of Par(n) consisting of those partitions all whose entries mod a belong to A.
What OEIS seqeunce is {nops(ParMod(n,5,{1,4})) }?
Eventually nops(SYT(L)) will be impractical, since the sets SYT(L) gets very big. Adapt procedure SYT(L) to write a procedure
NuSYT(L)
that inputs an integer partition L, and outputs the NUMBER of Standard Young Tableaux of shape L. For example
NuSYT([2,2]); should output 2, and NuSYT([3,3,3]); should output 42. (REMEMBER TO HAVE option rememeber)
Conjecture an explicit expression for NuSYT([a,b]) (alias nops(SYT([a,b])) for all a ≥ b ≥ 0
[Added March 9, 2026: This was solved by JikeLiu]
Conjecture an explicit expression for NuSYT([a,b,c]) (alias nops(SYT([a,b,c])) for all a ≥ b ≥ c ≥ 0
[Added March 9, 2026: This was solved by JikeLiu]
Added March 8, 2026: The nice homework solutions of students that kindly agreed to share their homework solutuions can be found in this directory
We did the following Maple code: C14.txt