I'm trying to show the following:
Let $V$ be a finite dimensional euclidean vector space, with two vector subspaces $S_1 \subset V$ and $S_2 \subset V$. Suppose that $X, Y$ are affine subspaces with $X = x + S_1$ and $Y = y + S_2$, that $P_U$ is the orthogonal projection onto a vector subspace $U$, and finally that $$ d(X, Y) = \min \{d(x,y) \mid x \in X,\, y \in Y\}. $$
Show that the following is true: $$ d(X, Y) = \lVert P_{S_1 + S_2}(x - y) + y - x \rVert. $$
I've learned and used a similar formula before: $$ d(v, U) = \inf\{\lVert v - u \rVert\ \mid u \in U\} = \lVert P_{U^{\perp}}(v) \rVert $$ with $U$ being a vector subspace of the vector space $V$. In this case there was also the condition that $V = U \oplus U^{\perp}$. I guess my problem is that I can understand the orthogonal projection visually if I project a vector onto, for example, a plane, but I can't understand the projection onto two subspaces.
Edit: Thank you @Stéphane Jaouen for the picture, it was invaluable when trying to come up with some sort of proof.
Regarding the proof, I have the following so far:
$$ d(X,Y) = \| x - y \| $$ The definition of $d(X,Y)$ is the norm of the two vectors $x \in X$, $y \in Y$. Both these vectors are at the same time in our vector space, i.e. $x, y \in V$.
With the Pythagoras' theorem we get $$ \| x - y \|^2 = \| P_{S_1 + S_2}(x - y) \|^2 + \| s^{\perp} \|^2 $$ with $s^{\perp}$ being a vector orthogonal to $S_1 + S_2$. (In Stéphane's picture this would be $\vec{PV}$). Rearrange this equation to get $$ \| s^{\perp} \|^2 = \| x - y \|^2 - \| P_{S_1 + S_2}(x - y) \|^2 $$ Therefore the shortest distance between $X$ and $Y$ is $$ \begin{align*} d(X,Y) &= \| x - y \| \\ &= \| s^{\perp} \| \\ &= \| s^{\perp} \| \\ &= \| (x - y) - P_{S_1 + S_2}(x - y)\| \end{align*} $$ If we look at $(x - y)$ and $P_{S_1 + S_2}(x - y)$ as vectors, the distance will be the same if we change the direction of the vector and we can rewrite this as $$ \begin{align*} &= \| P_{S_1 + S_2}(x - y) - (x - y)\| \\ &= \| P_{S_1 + S_2}(x - y) - x + y\| \\ &= \| P_{S_1 + S_2}(x - y) + y - x\| \\ \end{align*} $$
I'm not really sure whether I can just transfer the result of Pythagoras' theorem into my equation, however.
Before we go any further, I think it's helpful to follow the advice of @Ted Shifrin.
$ x,y \in \mathbb R^3; \color{green}{S_1}, \color{red}{S_2}$ two vector lines; $S_1\oplus S_2$ is represented in $\color{grey}{\text{grey}}$; $P:=P_{\color{grey}{S_1\oplus S_2}}(x-y)$; $V:=x-y=\vec{OP}+\vec{PV}$; $\vec{OP}=\color{green}{\vec{OP_1}}+\color{red}{\vec{OP_2}}; x_1:=x-\color{green}{P_1}; y_1:=y+\color{red}{P_2};\color{Green} {X}:=x+\color{DarkGreen} {S_1}; \color{Orange} {Y}:=y+\color{red} {S_2}$
$$d(\color{green}X,\color{orange}Y)=||x_1-y_1||=||\vec{PV}||=\lVert x-y-P_{S_1 + S_2}(x - y) \rVert$$
Regarding the proof, you have $$\forall \xi\in X=x_1+S_1, \forall \eta \in Y=y_1+S_2$$ $$\xi=x_1+u_1, \eta=y_1+u_2$$with $u_i\in S_i(i=1,2)\subset S_1+S_2$
Then $||\xi-\eta||^2=||x_1-y_1||^2+||u_1+u_2||^2$(Pythagora's theorem)
So $||\xi-\eta||^2\geq ||x_1-y_1||^2$ and finally $$||\xi-\eta||\geq||x_1-y_1||$$
So, $$d(X,Y)=||x_1-y_1||=||\vec{PV}||=\lVert x-y-P_{S_1 + S_2}(x - y) \rVert.\square$$