BETA
BETA

The Math Behind SPR and UF

By Jack "Jackie Peanuts" Moore | 02/25/21

Everything that goes into SPR and UF comes from one equation: The formula for how to calculate losers rounds from victory in a double elimination bracket. Where "x" is either the seed or placement in question, losers rounds from victory can be calculated with the following function:

is the floor function, which rounds down to the nearest integer.
is the ceiling function, which rounds up to the nearest integer.
I'll write these as "floor(x)" and "ceiling(x)" respectively later on, which unfortunately won't look nearly as cool.
Logarithms are extremely useful functions when dealing with exponents, and that's why they're useful with brackets. It's easier to see with a single elimination bracket. In that format, 1 person gets first place, 1 person gets second, 2 tie for third, 4 tie for fifth, 8 tie for ninth, 16 tie for 17th, and so on. That pattern—2, 4, 8, 16—can also be expressed with powers of two: 2¹, 2², 2³, 2⁴. Logarithms are the inverse of exponents, so log₂(2) = 1, log₂(4) = 2, log₂(8) = 3, and log₂(16) = 4. Rounds from victory for a given placing can then be calculated by the following relatively simple formula (at least compared to our monstrosity above): Where x is the placing or seed, Rounds From Victory = ceiling[log₂(x)]. The table below will show why the ceiling function is necessary:
The ceiling function makes us count up at 3, 5, 9, and 17. Those, not coincidentally, are also where the ties happen in single elimination brackets.
Double elimination, however, throws a wrench into things. There are still ties at third, fifth, ninth, and 17th in double elimination brackets, but the single elimination formula misses half of the possible placings: fourth, seventh, 13th, 25th, and so on. While a single elimination bracket sorts people into powers of two, a double elimination bracket requires two losers rounds for each winners round, splitting those powers of two in half. So what we need is not just a function that counts up at 3, 5, 9 and 17 as above, but also at 4, 7, 13, and 25. That's where the second part of the formula above, the ceiling[log₂(2⁄3*x)], comes in. Observe:
This takes advantage of the pattern in these new numbers where we have to increment: 4, 7, 13, 25, 49. Note the difference between each number in this sequence: 3, 6, 12, 24. That pattern can also be written as 3*2⁰, 3*2¹, 3*2², 3*2³, and so on for any 3*2ⁿ until we run out of entrants. That's why the 2/3 is there: after reducing, log₂(2⁄3*3*2ⁿ) = log₂(2*2ⁿ) = log₂(2ⁿ⁺¹) = n+1. That means you know the function log₂(2⁄3*x) will always return a whole number with any seed or placement that can be expressed as 3*2ⁿ for some integer n. That matters because the ceiling function won't count up until the next seed or placement, 3*2ⁿ + 1 (because logarithms are constantly increasing functions, and log₂(3*2ⁿ + 1) thus must be greater than log₂(3*2ⁿ), forcing the ceiling function to round up).
Finally, logarithms don't work for values of 0 or below, because there is never any possible x such that 2ˣ= 0. That's why we need to manually slam the first step in there and just say, oh, by the way, Losers Rounds From Victory = 0 when the seed is 1. That one shouldn't require much convincing anyway.
If you've ever wondered, like me, how you can play in so many tournaments and still not be able to do bracket math like "What place did I get, knowing that I went 3-2?" this is a big part of the reason why. The math behind double elimination brackets is actually pretty complicated. Thankfully, here at PGstats.com we have computers to do that work for us, so you can sit back, relax, and let us crunch the numbers for you.