Why mathematicians hate Good Will Hunting

I still remember the movie night when I first watched Good Will Hunting with my mom. Matt Damon played a janitor at the Massachusetts Institute of Technology. While mopping the hallways, he walked past a blackboard with an advanced math problem written on it. He stopped and started solving the problem. I watched, mesmerized, as he created seemingly illegible structures of dots and lines—until suddenly a math professor came out of a lecture hall and chased him away.
The audience was previously told that that problem was meant to be incredibly difficult, taking years of expert thinking to resolve, yet it was quickly worked out by Damon’s insightful janitor in just moments. At the time, I was fascinated by the idea that people could possess a hidden talent that no one suspected was there.
As I got older and more mathematically savvy, I dismissed the whole thing as Hollywood hokum. Good Will Hunting might tell a great story, but it isn’t very realistic. In fact, the mathematical challenge doesn’t hold up under much scrutiny. With the award ceremony for the Oscars this month, many people are thinking back on past winners—including Good Will Hunting. It’s worth taking a closer look at the blackboard in a film that, in 1997, took nine nominations and won for both original screenplay and actor in a supporting role.
On supporting science journalism
If you’re enjoying this article, consider supporting our award-winning journalism by subscribing. By purchasing a subscription you are helping to ensure the future of impactful stories about the discoveries and ideas shaping our world today.
Based on Actual Events
The film was inspired by a true story—one I personally find far more compelling than the fairy tale version in Good Will Hunting. The real tale centers George Dantzig, who would one day become known as the “father of linear programming.”
Dantzig was not always a top student. He claimed to have struggled with algebra in junior high school. But he was not a layperson when the event that inspired the film occurred. By that time, he was a graduate student in mathematics. In 1939 he arrived late for a lecture led by statistics professor Jerzy Neyman at the University of California, Berkeley. Neyman wrote two problems on the blackboard, and Dantzig assumed they were homework.
Dantzig noted that the task seemed harder than usual, but he still worked out both problems and submitted his solutions to Neyman. As it turned out, he had solved what were then two of the most famous unsolved problems in statistics.
That feat was quite impressive. By contrast, the mathematical problem used in the Hollywood film is very easy to solve once you learn some of the jargon. In fact, I’ll walk you through it. As the movie presents it, the challenge is this: draw all homeomorphically irreducible trees of size n = 10.
Before we go any further, I want to point out two things. First, the presentation of this challenge is actually the most difficult thing about it. It’s quite unrealistic to expect a layperson—regardless of their mathematical talent—to be familiar with the technical language used to formulate the problem. But that brings me to the second thing to note: once you translate the technical terms, the actual task is simple. With a little patience and guidance, you could even assign it to children.
Solving the Good Will Hunting problem
Let’s get into the vocabulary. In mathematics, a tree is a type of graph—that is, a collection of points that are connected to one another. Trees, notably, cannot contain loops, so you cannot connect the points in a way that causes them to close into one. The size of the tree is given in terms of the number of points, or nodes, in the graph. In this case, we know we are meant to draw all possible tree graphs with 10 nodes.

The term “homeomorphic” basically refers to the idea that the nodes in this network always follow a particular sequence; the exact shape of the tree is not as important as the sequence of connections. When I draw a connection between nodes A and B, I can make that link longer or shorter or rotated slightly, and it won’t matter so long as the overall structure of the network remains the same. The important part is that A connects to B.
To think about that in a different way, imagine a tree shaped like an X with five nodes and a tree shaped like a K with five nodes. These trees are considered to be the same tree because the number of nodes and sequence of connections are unchanged between the two shapes.
And “irreducible,” in this case, means that every node in the graph must be connected by either one line or by three or more lines such that no node is connected by only two lines: if a node was connected by only two lines, it could be reduced into just a single line.

So in plain language, the task is to draw all trees with the specified properties that each have 10 nodes. There are several approaches to this. For example, you could write a computer program that solves the task in a fraction of a second. Or you could start drawing all the graphs that fulfill these criteria by hand. It turns out that you may only need a few minutes of doodling if you decide to go with the latter route.
To demonstrate that, you can first draw a tree consisting of one central node that radiates out with nine connections, giving us a total of 10 nodes. That design meets the required criteria—it’s one of our homeomorphically irreducible trees of size n = 10. Good work!
Next, draw a tree with eight connections—you’ll find this design leads to a dead end because you won’t be able to add a node without either re-creating the previous tree or introducing a reducible line. Move on to drawing a tree that begins with a node that has seven connections. You will still need to place two more nodes, but you can imagine adding them to one of the seven you’ve just drawn. At this point, you should be able to keep doodling through the possibilities.

If you prefer an even more systematic approach—though it may take you a bit more time, depending on your comfort with graph theory—one clever solution involves considering which mathematical conditions the trees must fulfill and representing them with equations.
For this approach, we can define nk as the number of nodes n with k connections. Because the tree should be irreducible, there is no circumstance where n2 can exist, so n2 = 0. Furthermore, we know the tree must have 10 nodes total—that means you’ll never have n10 or n11, and so on. The maximum is n9.
We can then represent what we know with a mathematical formula:
n1 + n3 + n4 + n5 + n6 + n7 + n8 + n9 = 10

Note that we skipped n2 because we know that would equal 0.
There’s another constraint that we can express. Our tree with 10 nodes will ultimately have 18 lines, or connections, between them if we count in such a way that the link between node A and node B counts twice, with one being A-B, and the other being B-A. We can use that to build an equation where we represent each connection and node individually. For example, if a node links to one other node, it creates one connection: 1n1. If a single node links to three other nodes, there will be three connections created, so 3n3, etcetera. This leads us to the next equation:
n1 + 3n3 + 4n4 + 5n5 + 6n6 + 7n7 + 8n8 + 9n9 = 18
Now you’ve created two equations that corral and constrain our tree-drawing options. But we need to combine them to identify the terms most relevant for our task. You can subtract the first equation from the second to produce:
2n3 + 3n4 + 4n5 + 5n6 + 6n7 + 7n8 + 8n9 = 8
This equation serves as a reference for drawing your various trees. The idea is to take terms that, together, will equal 8 when you sum their first integer, or coefficient. Look at 8n9 for example. That tells us we only need one n9 to build our tree, which corresponds to the drawing in which a single node has nine connections.
If you try to draw n8, you’ll hit the dead-end scenario, with no tree that meets our criteria. If you were using our equation for reference, you wouldn’t even bother trying to draw it because you’d see you couldn’t combine 7n8 with another term such that the first number in each would equal 8.
But a node with seven connections, n7,can work if you combine it with n3,meaning you can combine a tree with seven connections (represented by 6n7 in the equation) and a tree with three connections (2n3) to find another solution to the problem. And you can carry on with the process from there!

Better Examples Exist
I can understand why Good Will Hunting’s filmmakers shied away from Dantzig’s actual work. The solution he devised was not short—and the trees are probably more visually appealing for a cinematographer.
But I still think the filmmakers chose this particular math problem poorly, even for a Hollywood film. The history of mathematics has many amazing stories, including true stories of actual laypeople solving an open problem, that could be great fodder for films.
In the field of geometry, for example, many breakthroughs regarding tiling the plane have been achieved by ambitious people who hadn’t studied mathematics or anything similar. One of my personal favorites occurred in 2022, when retired print technician David Smith finally found the long-sought “einstein tile,” a polygon that can fill a plane completely without any gaps and without the resulting pattern ever repeating itself.
This article originally appeared in Spektrum der Wissenschaft and was reproduced with permission. It was translated from the original German version with the assistance of artificial intelligence and reviewed by our editors.



