# Understanding formula for hyperplanes

I came across this formula that classifies a vector by using a hyperplane:

Let $a,b \in \mathbb{R}^n$, then the (implicitely defined) space-dividing hyperplane $H$ is orthogonal to $b-a$. With $x \in \mathbb{R}^n$ we can see that $$0 < (b-a)^Tx - \frac{1}{2}(||b||^2 - ||a||^2)$$

and we can conclude that $d(x,a)> d(x,b)$. We can then say that $x$ lies on a specific side of the hyperplane. I dont get any insight or intuition for this inequation. So I played with it, to get some understanding:

If I move $x$ towards the hyperplane, then the term on the right approaches zero. So I get $$(b-a)^Th = - \frac{1}{2}(||b||^2 - ||a||^2)$$ with $h \in H$

If the $b-a$ would be normalized, the term on the right would be the distance between the origin and the hyperplane. So we get $$d(0,H) = - \frac{1}{2||b-a||}(||b||^2 - ||a||^2)$$ But this does not give me any interpretation or intuition, why that works.

A hyperplane through the origin can be expressed via the equation $\mathbf n^T\mathbf x=0$, i.e., as the set of all points with position vectors $\mathbf x$ that are orthogonal to some fixed vector $\mathbf n$, the normal to the hyperplane. For vectors, $\mathbf n^T\mathbf x$ is just a different way to write the dot product $\mathbf n\cdot\mathbf x$. Recall its geometric meaning: it’s a positive multiple of the length of the projection of $\mathbf x$ onto $\mathbf n$, which is itself some multiple of $\mathbf n$. So, if the dot product is positive, this projection points in the same direction as $\mathbf n$; if it’s negative, the projection points in the opposite direction. For any point $\mathbf x$, then, the quantity $\mathbf n^T\mathbf x$ tells you on which side of the hyperplane the point lies: if $\mathbf n^T\mathbf x\gt0$, the point is on the same side of the hyperplane as $\mathbf n$, if it’s negative, the point is on the opposite side, and if it’s zero, the point is on the hyperplane. Moreover, the quantity $\mathbf n^T\mathbf x$ is proportional to the perpendicular distance of $\mathbf x$ from the hyperplane: $\mathbf n$ is orthogonal to it, so this distance is the length of the projection of $\mathbf x$ onto $\mathbf n$.
For an arbitrary hyperplane that might not pass through the origin, we can pick some fixed point $\mathbf x_0$ on the hyperplane and translate it to the origin to get the equation $\mathbf n^T(\mathbf x-\mathbf x_0)=0$, which expands into $\mathbf n^T\mathbf x-\mathbf n^T\mathbf x_0=0$, for this hyperplane. As before, we can determine which side of the hyperplane relative to the direction of $\mathbf n$ that any point lies on by examining the sign of $\mathbf n^T(\mathbf x-\mathbf x_0)$ and similarly for the relative distances of arbitrary points from this hyperplane. To get a feel for what’s going on, play around with this in two dimensions, where hyperplanes are straight lines.
For your dividing hyperplane $H$, we have $\mathbf n = \mathbf b-\mathbf a$. Since $\|\mathbf v\|^2=\mathbf v^T\mathbf v$ and the dot product is commutative, we have $(\mathbf b-\mathbf a)^T(\mathbf b+\mathbf a) = \|\mathbf b\|^2-\|\mathbf a\|^2$ and so can factor the equation of $H$ into $$\mathbf n^T\left(\mathbf x - \frac12(\mathbf b+\mathbf a)\right) = 0.$$ From this we can read $\mathbf x_0=\frac12(\mathbf b+\mathbf a)$, the midpoint of $\mathbf a$ and $\mathbf b$: $H$ is the perpendicular bisector of the line segment $\mathbf a\mathbf b$. Now, $\mathbf b-\mathbf a$ points from $\mathbf a$ toward $\mathbf b$ and so, too, toward $\mathbf b$ from their midpoint. Therefore, based on the above discussion, if $(\mathbf b-\mathbf a)^T\mathbf x - \frac12\left(\|\mathbf b\|^2-\|\mathbf a\|^2\right)\gt0$, then $\mathbf x$ lies on the same side of $H$ as does $\mathbf b$, while if it’s negative, then it’s on the same side as $\mathbf a$.
• Nice. I'd put more emphasis on the relationship $$\lVert b\rVert^2-\lVert a\rVert^2=(b-a)^T\cdot(b+a)$$ which you certainly implied, but which doesn't stand out when skimming your post while being crucial fo the connection from midpoint to difference of squared norms.