# Project a vector onto the intersection of surfaces

I want to project a vector $\vec v$ onto a surface $S$ defined as the intersection of other surfaces. For example, in 5-dimension I have the surface $S(x_1,x_2,x_3,x_4,x_5)=c$, defined by the intersection of the two surfaces

$g_1(x_1,x_2,x_3)=c_1 \quad$ with $\quad x_4, x_5$ vary freely

$g_2(x_1,x_4,x_5)=c_2 \quad$ with $\quad x_2, x_3$ vary freely

I don't want to compute the intersection surface $S$ because it may be impossible for higher dimensions.

At first I thought I could simply project the vector on the two subspaces $\{x_1,x_2,x_3\}$ and $\{x_1,x_4,x_5\}$, ie. on each surface $g_1$ and $g_2$, and take the reunion of all projection. But it is wrong because the surfaces $g_i$ are not the projection of S.

Any ideas, or relevant literature? Thank you.

I am currently thinking about something : let suppose we deal with planes, as pictured bellow. I want to project a vector $\vec v$ on their intersection line (green line). Each plane is defined by two vector director. If the two planes intersect, they must have a common vector director ($\vec u_1 = \vec u_2 = \vec u$ on the picture). I project $\vec v$ on each subspace, giving $\vec v_1$ and $\vec v_2$. Finally, I project each $\vec v_i$ on $\vec u$, and sum the results.

Or equivalently, directly project $\vec v$ onto $\vec u$.

Well, it is not quite satisfying as it requires to find $\vec u$, which seems to me to be equivalent to find the intersection, which I don't want.

• Not sure I understand your notation and terminology: "$S(x_1,x_2,x_3,x_4,x_5)=c$" seems to refer to a four-dimensional object (a level set of a function $S$), but by "$g_1(x_1,x_2,x_3)=c_1$" do you mean a two-dimensional surface in the three-dimensional subspace $\{x_4=x_5=0\}$, or the four-dimensional level set on which $x_4$ and $x_5$ vary freely? If the former, could you explain exactly how $S$ is defined by the equations $g_1(x_1,x_2,x_3)=c_1$ and $g_2(x_1,x_4,x_5)=c_2$? Commented Aug 4, 2014 at 12:26
• By "g1(x1,x2,x3)=c1" I mean "the four-dimensional level set on which x4 and x5 vary freely". I changed the formulation, I hope it's clearer now.
– J-D
Commented Aug 4, 2014 at 12:40
• Thanks; that clarifies. :) One other issue: Presumably the vector $v$ is given/known. Are you also given a point $p$ of $S$, and you want the component of $v$ tangent to $S$ at $p$? (If so, as I'm guessing, your question has a straightforward algorithmic solution using calculus and linear algebra, which I'll sketch out if no one beats me to it.) Commented Aug 4, 2014 at 12:59
• Right :) I take a known vector $\vec v$, at a point $p$ of $S$, and I want the component of $\vec v$ tangent to $S$.
– J-D
Commented Aug 4, 2014 at 13:11

Let $p$ be a point of $S$ and $v$ a vector based at $p$. The algorithmic solution to your question has two phases: Describe the set $T_{p} S$ of vectors tangent to $S$ at $p$, and project $v$ into $T_{p} S$.

Here's a general sketch (including technical hypotheses that are "almost certainly true in real situations"): Suppose $S$ is defined by $m$ equations in $n > m$ variables; precisely, assume $S$ is a regular level set defined by equations $$g_{i}(x_{1}, \dots, x_{n}) = c_{i},\quad i = 1, \dots, m,$$ in which the function $g_{i}$ have continuous first partial derivatives and the gradient vectors $n_{i} = \nabla g_{i}(p)$ are linearly independent. The tangent space $T_{p}S$ is the set of vectors $x$ satisfying $\langle n_{i}, x\rangle = 0$ for all $i$. This is a homogeneous linear system of $m$ equations in $n$ variables. A basis for the set of solutions can be found by "standard linear algebra techniques" (Gaussian elimination).

Once you have a basis $\{w_{1}, \dots, w_{n-m}\}$ of $T_{p} S$, use the Gram-Schmidt algorithm to construct an orthonormal basis $\{u_{1}, \dots, u_{n-m}\}$ of $T_{p} S$. The desired projection is $$\sum_{j=1}^{n-m} \langle v, u_{j}\rangle u_{j} = \langle v, u_{1}\rangle u_{1} + \dots + \langle v, u_{n-m}\rangle u_{n-m}.$$ The final formula is essentially trivial to work with; the "hard part" is to calculate an orthonormal basis of $T_{p} S$.

Example: Suppose $S$ is defined by \begin{align*} g_{1}(x_{1}, \dots, x_{5}) &= (x_{1} - 1)^{2} + x_{2}^{2} - (x_{3} - 1)^{2} = 0, \\ g_{2}(x_{1}, \dots, x_{5}) &= x_{1} + x_{4} + x_{5} = 0, \end{align*} and $p = (0, \dots, 0)$ is the origin. The respective gradients are \begin{align*} \nabla g_{1} &= \bigl(2(x_{1} - 1), 2x_{2}, - 2(x_{3} - 1), 0, 0\bigr), \\ \nabla g_{2} &= (1, 0, 0, 1, 1), \end{align*} and the gradient vectors at $p$ are $$n_{1} = (-2, 0, 2, 0, 0),\quad n_{2} = (1, 0, 0, 1, 1).$$ The resulting system of equations $\langle n_{i}, x\rangle = 0$ has coefficient matrix $$\left[\begin{array}{@{}rcccc@{}} -2 & 0 & 2 & 0 & 0 \\ 1 & 0 & 0 & 1 & 1 \\ \end{array}\right].$$ Gaussian elimination converts this to the reduced row-echelon matrix $$\left[\begin{array}{@{}ccccc@{}} 1 & 0 & 0 & 1 & 1 \\ 0 & 0 & 1 & 1 & 1 \\ \end{array}\right],$$ from which we can solve for $x_{1}$ and $x_{3}$ in terms of the free variables $x_{2}$, $x_{4}$ and $x_{5}$: $$x_{1} = -x_{4} - x_{5},\quad x_{3} = -x_{4} - x_{5}.$$ Successively setting each free variable to $1$ and the other free variables to $0$ gives a basis of $T_{p} S$: $$w_{1} = (0, 1, 0, 0, 0),\quad w_{2} = (-1, 0, -1, 1, 0),\quad w_{3} = (-1, 0, -1, 0, 1)$$

Now orthonormalize. Gram-Schmidt gives \begin{align*} u_{1} &= w_{1}, \\ u_{2} &= \tfrac{1}{\sqrt{3}} w_{2}, \\ u_{3} &= \tfrac{1}{\sqrt{15}}(1, 0, 1, 2, -3). \end{align*}

Finally, if $v = (v_{1}, v_{2}, v_{3}, v_{4}, v_{5})$ is an arbitrary vector at the origin, its projection into $T_{p} S$ is \begin{multline*} \langle v, u_{1}\rangle u_{1} + \langle v, u_{2}\rangle u_{2} + \langle v, u_{3}\rangle u_{3} \\ = v_{2} u_{1} + \left(\tfrac{-v_{1} - v_{3} + v_{4}}{\sqrt{3}}\right) u_{2} + \left(\tfrac{v_{1} + v_{3} + 2v_{4} - 3v_{5}}{\sqrt{15}}\right) u_{3} \\ = v_{2} (0, 1, 0, 0, 0) + \left(\tfrac{-v_{1} - v_{3} + v_{4}}{3}\right) (-1, 0, -1, 1, 0) \\ + \left(\tfrac{v_{1} + v_{3} + 2v_{4} - 3v_{5}}{15}\right) (1, 0, 1, 2, -3). \end{multline*}

• Very nice. It helps, a lot thank you.
– J-D
Commented Aug 4, 2014 at 16:10
• You're very welcome. :) Commented Aug 4, 2014 at 16:36