I read a comment on Hacker News sometime December 2019 about the general long division algorithm being unintuitive. This guy stated his credentials and the comment after his said surely he could come up with a proof in around 15-30 minutes, so I like Math and I like to think I'm at least somewhat good at it for not being a mathematician, so I challenged myself to write up a proof just for fun. Although I wrote out the first sketch of the proof that night it took me until now to do a writeup of it.
You might ask well why a proof, and I just have to say I feel a proof is the best way to see something intuitively. Here is my attempt at proving the long division algorithm. If you notice any mistakes please let me know on twitter or on a github issue on my blog or by any other means you can contact me with.
First I'll show an example of the long-division algorithm the way I learned it in school. This is honestly what I first wrote down to get the correct mental model of the algorithm.
So, first we will divide 128 by 5 just as an example.
We set up the equation:
We first notice five doesn't go into 1 so we do our first division of five on 12 instead five goes into 12 two times so we write two on top and subtract or :
that subtraction produces two:
Then we bring down the 8:
and repeat until we get:
So, there are some parts there that may seem a little mysterious and hand-wavy, so lets start by clearing those up. First of all at this step where we subtract 10:
We are really or atleast can really divide 5 from 12, if you want to think of it that way 5 from 12*10 which is 120. and subtracting 100 which five goes into 100 twenty times.
This mental model will come in handy for our proof. There are some other mental models that will help us for example notice that the right side of this equation is our result rewritten:
Or we could rewrite our division as
WARNING: this is gonna get a bit more math-intensive than the rest of the post after this point...
This was my first attempt to the proof which I did that night upon reading the HN comment, though it appears correct to me, I'm not sure I like it as much as the second Proof Attempt I have below.
Thus we see the general form is like the following where all numbers, , are of the set and is of the set .
So, we know is the remainder, and is the result.
Thus we need to prove equality of:
Let's multiply each side of the equation by and then prove equality by simplifying the right hand side.
This was my second and in my opinion more elegant approach that I wrote up sometime well I was reviewing my other proof to be posted. It's very similar, but better in my opinion as I did not have to manipulate both sides of the equation (because generally manipulating both sides can get you into false proof territory.)
We could do this one other way where we start at:
We could just simplify the right hand side of the equation to make it equal the left hand side.
(Distributive property of division and subtraction)
(Cancelling out like terms with division)
(Commutative property of addition/subtraction)
(Cancelling out like terms with subtraction)