I must find the distance between $S^n(0,1)$ and the plane $P=\{x\in\mathbb{R}^N/<x,v>=a\}$, for some $a\in \mathbb{R}$ and $v\in\mathbb{R}^N$.
I tried to use the lagrange multipliers by defining $f,\phi_1,\phi_2:\mathbb{R}^{N+1}\to\mathbb{R}$
$f(u,v)=\{u\in\mathbb{R}^N,v\in\mathbb{R},(x,y)\in S^N/|(u,v)-(x,y)|\}$ is the distance function I want to minimize.
$\phi_1(x,y)=\{x\in\mathbb{R}^N,y\in\mathbb{R}/|(x,y)|^2=1\}$, the sphere.
$\phi_2(x,0)=\{x,v\in\mathbb{R}^N, a\in \mathbb{R}/<(x,0),(v,0)>=a\}$
Then, I can make $\nabla f(p)=\lambda_1\nabla\phi_1(p)+\lambda_2\nabla\phi_2(p)$
But I'm lost, $f$ depends actually on $(u,v)$ but also on $(x,y)$, so the gradient doesn't fit in the equation. Any help will be appreciated.
For $x\in S^{N-1}=\{x\in\mathbb{R}^N~:~|x|=1\}$ and $y\in P$ you get critical points of the distant if $T_xS^{N-1}=T_yP$ since both sets are manifolds of dimension $N-1$. Since $T_yP=\{z\in\mathbb{R}^N~:~\langle z,v\rangle =0\}$ and $T_xS^{N-1}=\{z\in\mathbb{R}^N~:~\langle z,x\rangle=0\}$ it can just match if $x=\lambda v$ for some $\lambda \in\mathbb{R}$. Since $x\in S^{N-1}$ we get $1=|x|=|\lambda||v|$ and $|\lambda|=\frac1{|v|}$. Therefore either $x_-=-\frac1{|v|}v$ or $x_+=\frac1{|v|}v$ minimizes the distance.
Now you need the point $y\in P$, which minimizes the distance to $S^{N-1}$. Therefore $y$ needs to be orthogonal to $$ T_{x_\pm}S^{N-1}=\{z\in\mathbb{R}^N~:~\langle z,x_{\pm}\rangle =0\}=\{z\in\mathbb{R}^N~:~\langle z,v\rangle =0\}, $$ which yields $y=\mu v$ for some $\mu\in\mathbb{R}$. You can compute $ a=\langle y,v\rangle = \langle \mu v,v\rangle = \mu \langle v,v\rangle = \mu |v|^2 $. So you point on $P$ is $y=\frac{a}{|v|^2}v$.
Finally you check $$ |x_\pm-y|=\left|\pm\frac1{|v|}v-\frac{a}{|v|^2}v\right|=\frac{|a\pm|v||}{|v|^2}|v|=\frac{|a\pm|v||}{|v|}. $$ You minimal distance is then $$ \min\left\{\frac{|a+|v||}{|v|},\frac{|a-|v||}{|v|}\right\}=\begin{cases} \frac{|a+|v||}{|v|} & a<0\\ \frac{|a-|v||}{|v|} & a>0 \end{cases}. $$ We just consider the case, that $P\cap S^{N-1}=\emptyset$, otherwise the distance is obiously $0$, and therefore $a\neq 0$.
If you like to check when $P\cap S^{N-1}=\emptyset$, then you consider that $v$ is orthogonal on $P$. Therefore $|y|=\left|\frac{a}{|v|^2}v\right|=\frac{|a|}{|v|}$ gives the distance from $P$ to the orgin. For $P\cap S^{N-1}=\emptyset$ it is necessary, that $|y|>1$ which is the same as $|a|>|v|$. In that case you can simplify your minimal distance since $\min\{|a+|v||,|a-|v||\}=|a|-|v|$ and you get your minimal distance $$ \begin{cases} \frac{|a|-|v|}{|v|}=\frac{|a|}{|v|}-1 & |a|>|v|\\ 0 & |a|\leq |v| \end{cases}. $$ Remark:
Some arguments just work, if you know, that you have minimizing points on $S^{N-1}$ and $P$. But since $P$ is closed and $S^{N-1}$ is compact, it is easy to prove, that they exists.