Problem 1.2

Find the matrix giving the number of 3 step walks

The second task in problem 1 asks to find the matrix which encodes all possible walks of length 3 (Knill, 2003). That is, to find the number of different sequences of edges which join every distinct sequence of vertices.

An n + 1 step walk from i to j consists of an n step walk from i to k and then a 1 step walk from k to j. That is, the ij entry of Lⁿ⁺¹ is given by the sum:

Equation 1

Which in English for this problem states that “the number of walks of length 3 from vertex i to j" is equal to the sum of “the number of walks of length 2 from vertex i to k” multiplied by “the number of walks of length 1 from vertex k to j” for k = 1,2. By matrix multiplication, for all step walks of length 3 from i to j this gives the following matrix:

Solution 1.2. The matrix representing the number of 3 walks from vertex i to j in graph G

Problem 1.3

Find the generating function for walks from i → j

The third task in problem 1 asks for the generating function from vertex i to j. To answer this question, Horváth et al (2010) consider an analytic generating function defined by a power series

Equation 2

Where the coefficient zⁿ denotes the number of n step walks from i to j. From task 1.3, we found that ω_n(i → j) is the ij entry of the matrix Lⁿ. The problem asks for the generating function that gives all the entries simultaneously, and so it makes sense to consider a matrix L given by the familiar power series (Horváth et al, 2010):

Equation 3

Where Lⁿ is the matrix containing the number of step walks from each vertex i to j (the general case of the solution to problem 1.2). The sum can be calculated using the familiar identity for geometric power series, that is:

Equation 4

To calculate the inverse of (I − z × L) we can use Cramer’s rule. According to Horváth et al (2010) for a matrix M let Mᵢⱼ denote the matrix obtained from M by removing the ith column and the jth row. If we do so, we obtain a matrix N whose ij entry is

Equation 5

By Cramer’s rule, if M is invertible (there exists some n×n matrix N such that M×N = N×M = I_n) then

Equation 6

That is, the ij entry of of the inverse matrix M is:

Equation 7

Applied to compute the inverse of M = (I − z × L), we obtain:

Equation 8

Substituting for M:

Solution 1.3. The generating equation for walks from i to j

As Horváth et al (2010) notes, this is Will’s solution in the movie, except his solution omits the term (−1)^(i+j) (likely due to notation), and he denotes the identity matrix with 1 instead of the more common I.

Problem 1.4

Find the generating function for walks from 1 → 3

To solve task 1.4, we simply apply the general formula for walks from i to j (from task 1.3) to the case of walks from 1 → 3:

Equation 9.

Whose determinants are trivial to find: