I have been trying to find some great maths related movies recently and I have found “Good Will Hunting”. It is an old movie (1997), but even though I have heard a lot about it I never watched it. So, I thought it is the time to give it a try. The movie follows a 20 year old laborer Will Hunting, an unrecognized genius who, as part of a deferred prosecution agreement after assaulting a police officer, becomes a client of a therapist and studies advanced mathematics with a renowned professor.

The movie is incredible and I loved it. You get to see how Will re-evaluates his relationships with people around him and how he confronts his past and decides about his future. Totally recommend this movie. I this post I don’t want to talk about the sentimental part, but I want to mention some interesting mathematics which appears in it.

The problem I am talking about is the one which appears at the beginning of the movie, when the professor gives his students a tricky task:

The problem is not extremely easy to understand because it does involve quite a lot of university level maths: linear algebra (elementary theory of matrices, powers of matrices, Jordan normal-form), analysis (convergence in normed vector spaces, power series, convergence of power series), combinatorics  (generating function, counting, recurrence formulae) and graph theory (adjacency matrix, paths, powers of the adjacency matrix).

The problem mostly comes from the mathematics field called Graph Theory. This is  the study of graphs – mathematical structures which model pairwise relations between objects. A graph in this context is made up of vertices, nodes, or points which are connected by edges, arcs, or lines. We can say that graphs can be undirected (there is no distinction between the 2 vertices associated with each edge) and directed (its edges are directed from one vertex to another).

It turns up that in the end the problems is related to Cayley’s formula stating that the number of labeled trees on n nodes is nn-2. Then he lists 8 different unlabeled trees with 10 nodes. To make more light into this, you have to understand that a tree is an undirected graph in which any two vertices are connected by exactly one path. In case you were wondering, mathematics has also the notion of forest in this case: a disjoint union of trees.

For a more mathematical explanation, I advice you to read Mathematics in Good Will Hunting II: Problems from the Students Perspective. Also, Numberphile has a great movie on this problem: