A Matrix Definition of a Line
Every so often, I see a tweet so marvellous I can’t believe it’s true. Then I bookmark it and forget about it for months, until I don’t know what to write next.
An example is @robjlow’s message from June:
Aren't determinants wonderful? pic.twitter.com/vxIKeS4Lrq
— Robert Low (@RobJLow) June 26, 2018
a) Isn’t that lovely? and b) Hang on, is it really true?
Let’s algebra
Working out the determinant using my favourite diagonal stripes method gives $x(y_1 - y_2) + y(x_2 - x_1) + (x_1 y_2 - x_2 y_1) = 0$.
Does that look plausible? Certainly it’s a straight line, and certainly replacing $x$ and $y$ with either $x_1$ and $y_1$ or $x_2$ and $y_2$ makes it a true statement.
Maybe we can rearrange it into a nicer form? $y(x_1 - x_2) = x(y_1 - y_2) + (x_1 y_2 - x_2 y_1)$, or $y = \frac{y_1 - y_2}{x_1 - x_2} x + \frac{x_1 y_2 - x_2 y_1}{x_1 - x_2}$. The gradient looks right and the $y$-intercept looks plausible.
But wait, we can convince ourselves more elegantly!
Let’s algebra!
If a point lies on the line between $\br{x_1, y_1}$ and $\br{x_2, y_2}$, it can be written as (abusing notation slightly) $k \br{x_1, y_1} + \br{1-k} \br{x_2, y_2}$ - with the point where $k=0$ corresponding to $\br{x_1, y_1}$ and $k=1$ to $\br{x_2, y_2}$.
That is to say, any point that lies on the line between the two points is a linear combination of them - which means the top row of the matrix can be written as a linear combination of the other two. The rows of the matrix are not linearly independent, so its determinant is zero!
Similarly, you can show that only points on the line can be written in this form, so the determinant defines the line. How lovely!
- Thanks to Rob for the original tweet!