Take a piece of string. Tie it in a knot. Now glue the two ends together so it forms a closed loop. That closed, knotted loop — floating in three-dimensional space — is what mathematicians call a knot.
Why a closed loop? If the ends are free, you can always just slide the knot off the end of the string — every knot unties. By joining the ends, the knottedness is trapped. There is no way to cheat. The only way to change the knot is to deform the loop smoothly through space — stretching, bending, rearranging — but never cutting it or passing it through itself. This makes the question "is this knot really knotted?" a precise mathematical one rather than a vague physical one.
The simplest knot is just a plain circle with no crossings at all — the unknot. (Yes, a plain circle counts as a "knot" in this field — it is the trivial case, analogous to zero being a number.) The simplest actual knot is the trefoil, which is what you get if you make the simplest possible overhand knot and then join the ends. After that, there is a whole zoo: the figure-eight knot, the cinquefoil, torus knots, and so on — catalogued meticulously since the 1800s.
A link is the same idea but with two or more loops tangled together — like chain links. The Hopf link is the simplest: just two circles linked once through each other.
Why would you want to know whether two knots are "the same"? Consider: if someone hands you a horribly tangled loop of string, is there any sequence of moves that will untangle it into a plain circle — or is the knottedness fundamental, impossible to remove without cutting? This is not an idle question. It arises naturally in molecular biology (DNA strands form knots whose topology affects how enzymes can act on them), in chemistry (molecular knots have different properties from their unknotted counterparts), and in physics (quantum field theories and statistical mechanics both involve knot-like structures). But even purely as mathematics, it is a deep and beautiful problem.
Here is the fundamental difficulty: if someone hands you two tangled loops of string, how do you know whether one can be deformed into the other without cutting? A trefoil looks different from a figure-eight knot, but can you prove they are truly distinct, or might one just be a rearranged version of the other? Worse, the same knot can look wildly different depending on how you lay it on a table. You can add unnecessary extra crossings by twisting the string, or rearrange crossings by sliding strands over each other. Two diagrams that look completely different might secretly be the same knot.
You cannot just count crossings — the same knot can be drawn with more or fewer crossings depending on how you arrange it on the page. What you need is an invariant: some quantity you can compute from a knot diagram that is guaranteed to give the same answer no matter how you draw that particular knot, but (hopefully) gives different answers for genuinely different knots.
Think of it like a fingerprint. If two people have different fingerprints, you know they are different people. An invariant works the same way for knots: if two knots have different invariants, they are definitely different knots. (The reverse is not guaranteed — just as two different people could theoretically have very similar fingerprints, two different knots could have the same invariant. A stronger invariant is one that distinguishes more knots.)
The Kauffman bracket (discovered by Louis Kauffman in 1987) is exactly such an invariant. It assigns a polynomial — an algebraic expression in a variable A — to each knot. If two knots have different brackets, they are definitely different knots. It is one of the most elegant constructions in all of mathematics, and it can be computed by a beautifully simple procedure.
A knot lives in three-dimensional space, but that is hard to work with on paper or in a computer. So we project it — imagine holding the knot above a table and looking straight down. The shadow it casts is a flat curve that crosses itself wherever one strand passes over another. This flat picture is a knot diagram.
At each place the curve crosses itself, we get a crossing. We draw the under-strand with a small gap to show it passes behind — this is the one piece of 3D information we preserve in the flat picture. A knot diagram with its crossing information is enough to reconstruct the full 3D knot (up to the kind of smooth deformations we allow).
Each crossing involves four arcs — the four strands leading into and out of the crossing point. (An "arc" is the portion of the knot between two adjacent crossings.) We label these arcs with numbers and list them in counter-clockwise order starting from the incoming under-strand. This is called PD (planar diagram) notation — it is the standard way to encode a knot as pure data that a computer can work with. The entire topology of the knot is captured by this list of arc labels at each crossing.
For example, the trefoil has 3 crossings and 6 arcs. Its PD notation is:
Each bracket lists the four arc numbers at that crossing. Notice that every arc number appears exactly twice across all the crossings — once where it enters a crossing and once where it leaves another. This is how the crossings are "wired together" into a continuous loop. The figure-eight knot has 4 crossings and 8 arcs; the Hopf link has 2 crossings and 4 arcs.
The key operation in computing the Kauffman bracket is smoothing. The basic idea is: what if we could "undo" a crossing? At each crossing, instead of having two strands cross over each other, we reconnect the strands so they no longer cross at all — they just curve past each other. This eliminates the crossing entirely.
But here is the crucial point: there are two different ways to reconnect the strands. Imagine you are standing at the crossing looking at the four arcs coming in. You can pair them up two ways — and each way produces a different reconnection:
Connect arc 0 with arc 3, and arc 1 with arc 2. Visually, this joins the strands into two curves that "pass by" each other horizontally.
Connect arc 0 with arc 1, and arc 2 with arc 3. This joins the strands the other way — they "bounce back" on themselves vertically.
Each smoothing choice eliminates one crossing. If we choose a smoothing for every crossing in the knot, we eliminate all the crossings, and the knot dissolves into a collection of simple, non-crossing loops — plain circles sitting on the page with no crossings at all.
This is the key insight: a knot is complicated because of its crossings. Smoothing removes that complexity entirely, leaving behind the simplest possible topological objects — circles. The price we pay is that there were choices involved (A or B at each crossing), and different choices produce different numbers of circles. The Kauffman bracket is a way of bookkeeping all those choices and their consequences into a single algebraic expression.
A state is a specific choice of smoothing (A or B) for every crossing. A knot with n crossings has 2n possible states — every combination of A and B across all crossings. (This is the same as counting in binary: for 3 crossings, you get AAA, AAB, ABA, ABB, BAA, BAB, BBA, BBB — eight states total.)
For each state, once all crossings are smoothed away, we are left with some number of simple closed loops. We count them. This loop count is the crucial piece of information from each state. Intuitively, more loops means the smoothing "separated" the knot into more pieces, while fewer loops means the strands stayed more connected.
For instance, the trefoil has 3 crossings, so 2³ = 8 states. Some states yield 1 loop, some yield 2, and some yield 3. Different knots produce different patterns of loop counts across their states — and this is ultimately what makes the bracket different for different knots.
The explorer below lets you see this for yourself — click on the crossings to change the smoothing and watch the loop count change. Try to find the state that produces the most loops, and the one that produces the fewest.
Now we assemble the bracket. The idea is to sum a contribution from every state — all 2n of them. We do not pick a single "best" smoothing; we consider all possible smoothings simultaneously, weighted by algebraic factors that keep track of which choices were made. This "consider every possibility and sum them up" approach is called a state sum, and it is a powerful technique that appears throughout mathematical physics.
Each state contributes a term to the sum. The contribution depends on two things:
If a state uses a A-smoothings and b B-smoothings, its weight is A(a−b). Each A-smoothing contributes a factor of A, each B-smoothing a factor of A−1. So a state with all A-smoothings has the highest positive power of A, and a state with all B-smoothings has the most negative power. This is how the variable A encodes which smoothing choices were made.
Each simple loop in the resolved diagram is "worth" a factor of d = −A² − A⁻². If there are ℓ loops, the loop factor is dℓ−1. (Why ℓ−1 instead of ℓ? The first loop is "free" — it comes from the normalization convention that the unknot, a single circle, has bracket equal to 1 rather than d.) The value of d is not arbitrary — it is the unique value that makes the bracket invariant under certain diagram rearrangements called Reidemeister moves.
Because the variable A can have both positive and negative exponents (like A−7), the result is a Laurent polynomial. A regular polynomial has only non-negative powers (like 3x² + x + 5). A Laurent polynomial extends this to include negative powers too (like A−7 + A5). All the coefficients turn out to be integers, which is remarkable — despite all the intermediate computation, the final answer is always clean.
The bracket is almost a full knot invariant on its own. It can change by a factor under one particular type of diagram rearrangement (adding or removing a twist). To correct for this, we account for the writhe — each crossing has a sign (+1 or −1, determined by the orientation of the strands), and the writhe is their sum. Dividing out the writhe-dependent factor gives the Jones polynomial (or rather, Kauffman's version of it in the variable A):
This f-polynomial is a true knot invariant: it does not depend on how you draw the diagram at all. It only depends on the knot itself. The Jones polynomial was originally discovered by Vaughan Jones in 1984 through a completely different route (via operator algebras in quantum mechanics); Kauffman's bracket gives a beautifully elementary way to compute it using nothing more than counting loops and doing polynomial arithmetic.
The C89 program implements this entire computation from scratch, with zero dependencies — just pure arithmetic and loop-counting. Here is what each part handles:
The code defines a Poly type that stores an array of integer coefficients and a lowest exponent. For instance, the polynomial A−3 + 2A5 would be stored as coefficients [1, 0, 0, 0, 0, 0, 0, 0, 2] starting at exponent −3. Addition and multiplication follow the standard rules of polynomial algebra — the same rules you learned in school, just extended to handle negative exponents. This data structure is the workhorse: all the bookkeeping of "collect like terms in A" is handled here.
Each knot is stored as an array of crossings in PD notation — exactly the arc-label lists described in section 3. The trefoil, figure-eight, and Hopf link are hard-coded from the standard Knot Atlas database. Each crossing also stores its sign (+1 or −1) for computing the writhe.
This is the topological heart of the computation. For a given state (a specific smoothing choice at every crossing), the code builds a pairing table: at each crossing, it records which arc gets connected to which. Then it traces through these connections — start at any arc, follow the pairing to a partner arc, jump to that arc's other crossing, follow the pairing there, and so on, until you return to where you started. That is one loop. Repeat for any unvisited arcs to find all the loops. The result is just a count: how many independent closed loops did this state produce?
The main computation: loop over all 2n states (using a simple integer counter where each bit represents A=0 or B=1 at that crossing). For each state, compute the weight A(#A−#B), count the loops, raise d to the appropriate power, multiply them into a polynomial term, and add it to the running total. When done, the accumulated sum is the Kauffman bracket ⟨K⟩.
The program checks its computed results against known values from the mathematical literature. The trefoil's bracket matches Kauffman's published result. The figure-eight's bracket is palindromic (its coefficients read the same forwards and backwards) — this reflects the remarkable fact that the figure-eight knot is amphichiral: it is equivalent to its own mirror image, the only knot with 4 or fewer crossings that has this property. The Hopf link bracket is correct. And crucially, the trefoil and figure-eight have different brackets, confirming that the invariant successfully distinguishes them. All 9 tests pass.
The interactive tool below is a direct JavaScript port of this C code — the same polynomial arithmetic, the same loop-counting algorithm, the same PD data. The results match exactly.