Hesse normal form and how to calculate the smallest distance to a point I want to show that the smallest distance of a point to a hyperplane (given by $\langle x, n \rangle + d = 0$, where $n$ is the normal of the plane with$\|n\|_2=1$ and $d\in\mathbb{R}$ is given by putting the point into the equation of the plane.
My proof: We call $P_H$ the projection onto the hyperplane and want to show that
\begin{align*}
    \|p-P_H p\|_2 = d(p,H) \overset{!}{=} |h(p)| = |\langle p, n \rangle + d|.
\end{align*}
Since $p-P_H p\in H^\perp$, we get $p - P_H p = (\lambda-d) n$ for some $\lambda\in\mathbb{R}$. With that, we get
\begin{align*}
    |h(p)| &= |\langle p, n\rangle+d| = |\langle p,n\rangle - \langle P_H p, n\rangle+d| = |\langle p - P_h p, n\rangle + d| \\
    &= |\lambda| = |\lambda| \cdot\|n\|_2 = \|\lambda n\|_2 = \|p-P_h p + \lambda n\|_2.
\end{align*}
Where is my mistake?
Right solution: We call $P_H$ the projection onto the hyperplane and want to show that
\begin{align*}
    \|p-P_H p\|_2 = d(p,H) \overset{!}{=} |h(p)| = |\langle p, n \rangle + d|.
\end{align*}
Since $p-P_H p\in H^\perp$, we get $p - P_H p = \lambda n$ for some $\lambda\in\mathbb{R}$. With that, we get
\begin{align*}
    |h(p)| &= |\langle p, n\rangle+d| = |\langle p,n\rangle - \langle P_H p, n\rangle + \underbrace{\langle P_H p, n\rangle}_{=~-d} + d| = |\langle p - P_h p, n\rangle | \\
    &= |\lambda| = |\lambda| \cdot\|n\|_2 = \|\lambda n\|_2 = \|p-P_h p\|_2 = d(p,H).
\end{align*}
Even better solution (wrong definition in the first one, I want to keep the orientation): We call $P_H$ the projection onto the hyperplane and want to show that
\begin{align*}
    \lambda = d_{\text{or.}}(p,H) \overset{!}{=} h(p) = \langle p, n \rangle + d,
\end{align*}
where $\lambda\in\mathbb{R}$ is the unique number such that $p = P_H p+\lambda n$. It exists because of $p-P_H p\in H^\perp$. We have
\begin{align*}
    P_H p + h(p) n &= P_H p + \big(\langle p, n\rangle+d\big)n = P_H p + \Big(- \langle P_H p, n\rangle + \underbrace{\langle P_H p,
    n\rangle}_{=~-d} + \langle p, n\rangle + d\Big)n \\
    &= P_H p + \langle p - P_H p, n\rangle n = P_H p+\lambda n = p,
\end{align*}
where we used that $P_H p$ lies in the hyperplane and therefore fulfills $\langle P_H p, n\rangle + d = 0$.
 A: When you write
$$|\langle p, n\rangle+d| = |\langle p,n\rangle - \langle P_H p, n\rangle+d|$$
you are replacing $p$, the vector from origin to that point, with $p - P_h$, the difference vector to the projected point. The two are not equal.
What you can do is subtract the projected point then add it back in. Knowing that the projected point is on the plane, you can replace one of these two inner products with $-d$ and use that to cancel $d$, while the other can be moved into the inner product the way you did.
A: Another standard approach is to
think your problem in terms of constrained minimization.
Let $\mathbf{p}$ be a point in space.
Your problem is to minimize
$
\phi(\mathbf{x}) = 
\| \mathbf{x-p} \|^2
$
s.t. $\mathbf{x}^T\mathbf{n}+d=0$.
The Lagrangian writes
$$
L(\mathbf{x},\lambda) 
=
\phi(\mathbf{x})
-\lambda (\mathbf{x}^T\mathbf{n}+d)
$$
At optimum, it holds
\begin{eqnarray*}
\frac{\partial L}{\partial \mathbf{x}}
&=&
2(\mathbf{x}^* - \mathbf{p})
-\lambda^* \mathbf{n}
=
0
\rightarrow
\mathbf{x}^* = \mathbf{p} + 
\frac{\lambda^*}{2} \mathbf{n}
\\
\frac{\partial L}{\partial \lambda}
&=&
(\mathbf{x}^*)^T\mathbf{n}+d
= \mathbf{p}^T \mathbf{n} +
\frac{\lambda^*}{2} \| \mathbf{n} \|^2 + d
= 0
\rightarrow
\frac{\lambda^*}{2}
= - \frac{\mathbf{p}^T \mathbf{n}+d}{\| \mathbf{n} \|^2}
\end{eqnarray*}
The minimal distance writes
$$
d 
=
\| \mathbf{x}^*-\mathbf{p} \|
= \frac{|\lambda^*|}{2} \| \mathbf{n} \|
= \frac{| \mathbf{p}^T \mathbf{n}+d |}{\| \mathbf{n} \|}
$$
