# Math behind the minimum distance between point and the hyperplane

In the figure, I tried to indicate a straight line as a hyperplane which is denoted by pi. And the equation of the hyperplane is w^t.x = 0. Here hyperplane is passing through the origin point.

Could anyone help to prove how the minimum distance d between the point and the plane is?

d = w^t.P / ||w||

What I tried is written below:

I got from a tutorial that vector w = w^t. I am not sure how both would be equal to each other. Please help me here, How they are equal?

Now, if w = w^t, then we can write

w^t.P = ||w||.||P||.cos(theta)

=> ||P|| = w^t.P / ||w||.cos(theta)

As ||P|| = d then, => d = w^t.P / ||w|| cos(theta)

cos(theta) remain in the equation. Which I don't know how to eliminate.

• I assume you mean the minimum distance between a point and a plane?
– user277126
Jan 11, 2022 at 11:40
• Yes, I also edited my question. Thank you for pointing out Jan 11, 2022 at 13:16

Let's denote a vector from the origin $$0$$ to the point $$P$$ as $$p$$, i.e. $$p = \overrightarrow{0P}$$. Let's denote as $$P_{\pi}$$ the projection (point) of $$P$$ onto the plane $$\Pi$$ (and $$p_{\pi}$$ it's corresponding vector from the origin).

What do we know?

1. The vector from $$P_{\pi}$$ to $$P$$ is parallel to $$w^T$$ so $$p - p_{\pi} = \lambda w^T \iff p_{\pi} = p - \lambda w^T$$ for some constant $$\lambda$$. Note: if $$|| w^T || =1$$ then $$\lambda$$ is your distance $$d$$.
2. $$p_{\pi}$$ is orthogonal to $$w^T$$ ($$w^T$$ is a vector normal to the plane $$\Pi$$). This means: $$\langle p_{\pi}, \lambda w^T \rangle = 0$$
3. You can assume the inner product to be the dot product, i.e. $$\langle a, b \rangle = a^Tb$$

Use (1) and (2) to find $$\lambda$$. Assuming $$|| w^T || = 1$$ it is your answer. Otherwise: $$d = || \lambda w^T || = \lambda || w^T ||$$

• Could you please make me understand in a more easy way maybe with an image? Jan 11, 2022 at 13:21
• What are you struggling to understand? Can you identify vectors $p, p_{\pi}, \lambda w^T$ in your image? If so - you should be able to see which vectors are parallel/perpendicular to each other (point 1). If you can visualize the vectors - do you understand the concept of an inner/dot products? If so - you should know that for two vectors $a, b$, if they are orthogonal (perpendicular) then $a^Tb = 0$ (points 2, 3) Jan 11, 2022 at 13:59
• At point 1 why p−pπ = λw^T. Why are you writing constant terms here? And the pπ term is along with the plane pi, right? Jan 11, 2022 at 15:18
• You know that $w^T$ is perpendicular (normal) to the plane so it's parallel to $p - p_{\pi}$. But you don't know if length of $w^T$ is exactly equal to the length of $p - p_{\pi}$ (blue dotted line in your image). So you need to account for a scaling factor (here - $\lambda$). Jan 11, 2022 at 15:43
• Thank you. I understood your explanation now Jan 11, 2022 at 16:32

we can write

w^t.P = ||w||.||P||.cos(theta)

...

cos(theta) remain in the equation. Which I don't know how to eliminate.

You know that $$\Vert P \Vert \text{cos}(\theta) = d$$ because the the three points (origin, the point $$P$$ and the projection of $$P$$) make a right-angled triangle.

(this is a bit indirect argument, you will have to prove that the shortest vector from $$P$$ to the plane, is perpendicular to the plane)

$$w^t \cdot P = \Vert w \Vert \underbrace{\Vert P \Vert \text{cos}(\theta)}_{=d} = \Vert w \Vert d$$

Btw, the image below (from this question here, the same as yours but a 2d hyperplane) might show the situation more clearly. It depicts the cases for multiple points $$P$$ and each time the shortest vector from P to the plane points into the same direction and is perpendicular to the plane.

• vector w and its transpose directs in the same direction, that's why they are equal vector? Jan 11, 2022 at 14:37
• Thank you for the answer. I could do prove by myself after you point the value of d = ||P||.cos(theta) Jan 11, 2022 at 16:30

I solved the equation and add an image with the solution. I hope people who were answering my question could give a glance, whether I did any mistake or not.

Thank you