Let $X$ be an inner product space. Let $E\subset X$ be closed under scalar multiplication and $x \in X$. Then $x \perp E$ if and only if $\operatorname{dist}(x,E)=||x||$.
I am able to show the forward part but not able to prove the backward part i.e. $\operatorname{dist}(x,E)=||x|| \implies x \perp E$
Please provide some hints!
A set that is closed under scalar multiplication is a union of lines through the origin. So let's consider a line $L$ with direction vector $v$.
Clearly, $\operatorname{dist}(x,L)\le \|x\|$ always holds.
Claim: $\operatorname{dist}(x,L)=\|x\|\iff \langle x,v\rangle =0$.
Proof: consider the polynomial $p(t)=\|x-tv\|^2 = \|x\|^2-2t\langle x,v\rangle +t^2\|v\|^2$. Since $p(0)=\|x\|^2$, the only way for $p$ to satisfy $\min p = \|x\|^2$ is to have the minimum at $x=0$; i.e., to have the coefficient of $x$ equal to zero. $\qquad\Box$
For a general union of lines $E = \bigcup L_\alpha$ we have $$ \operatorname{dist}(x,E) = \inf_\alpha \operatorname{dist}(x,L_\alpha) $$ The only way for this to be equal to $\|x\|$ is to have $\operatorname{dist}(x,L_\alpha)=\|x\|$ for all $\alpha$, which by the above is equivalent to $x\perp L_\alpha$ for all $\alpha$.