How can I know if a vector $\mathbf{a}$ is tangent to a surface $S$? I am given a surface $S$ parametrized by $\mathbf{r} (u, v) = x(u, v) \mathbf{i} + y(u, v) \mathbf{j} + z(u, v) \mathbf{k}$ and a vector $\mathbf{a}.$ How can I know if the vector is tangent to the surface?
 A: You could, I believe, compute the surface normal at the basepoint of $a$, and then check to see if it's perpendicular to a.
A: An approach that generalizes to higher dimensions, where the tangent space is probably easier to calculate than its orthocomplement, would be to calculate the tangent vectors
$$\partial_u r(u,v) = \frac{\partial}{\partial u} x(u,v) {\bf i} + \frac{\partial}{\partial u} y(u,v) {\bf j} + \frac{\partial}{\partial u} z(u,v) {\bf k}$$
and
$$\partial_v r(u,v)= \frac{\partial}{\partial v} x(u,v) {\bf i} + \frac{\partial}{\partial v} y(u,v) {\bf j} + \frac{\partial}{\partial v} z(u,v) {\bf k},$$ and seeing if ${\bf a}$ can be written as a linear combination of them:
$$\left(\begin{matrix} a_1 \\ a_2 \\ a_3 \end{matrix}\right)=c\left(\begin{matrix} x_u \\ y_u \\ z_u \end{matrix} \right) + d \left(\begin{matrix} x_v \\ y_v \\ z_v \end{matrix}\right).$$
This is an overdetermined system. In three dimensions, you can solve the two by two system
$$\left(\begin{matrix} a_1 \\ a_2 \end{matrix}\right)=c\left(\begin{matrix} x_u \\ y_u \end{matrix} \right) + d \left(\begin{matrix} x_v \\ y_v \end{matrix}\right)$$
explicitly as
$$\left(\begin{matrix} c \\ d \end{matrix}\right) = \frac{1}{x_u y_v - x_v y_u} \left(\begin{matrix} a_1 y_v - a_2 x_v \\ -a_1 y_u + a_2 x_u\end{matrix}\right).$$
Once you enforce the condition $a_3 = c z_u + d z_v$, you end up (after multiplying by $x_u y_v - x_v y_u$) with the condition
$$a_1(y_v z_u - y_u z_v) + a_2(z_v x_u - z_u x_v) + a_3(x_v y_u - x_u y_v) = 0,$$
which is the same as saying ${\bf a} \cdot (\partial_u r \times \partial_v r) = 0$.
A: This is one way I would approach the problem either analytically or computationally. This is similar to J.J.'s answer but is a little less geometrical and allows for higher dimensions.
We have a parameterized surface ${\bf r}(u,v):U \to R^n$ with $(u,v) \in U\subset R^2$. Let's assume $U$ is bounded. From this we can compute ${\bf r}_u (u,v)$ and ${\bf r}_v (u,v)$. If ${\bf a}$ is tangent to our surface, then there will exist numbers $u,v,c_1,$ and $c_2$ such that
$${\bf a} = c_1 {\bf r}_u (u,v) + c_2 {\bf r}_u (u,v).$$
As mentioned, for $n \geq 3$ this is an over determined system if $u$ and $v$ are fixed. As a function of $u$ and $v$ we can compute the least-squares solution. We have an exact solution iff the least-squares solution gives an error of zero.
The system can be rewritten as 
$$a^{(1)} = c_1 r_u^{(1)}(u,v) + c_2 r_v^{(1)}(u,v)$$
$$\vdots$$
$$a^{(n)} = c_1 r_u^{(n)}(u,v) + c_2 r_v^{(n)}(u,v)$$
where the superscript denotes the coordinate in $R^n$. The least squares solution for $c_1$ and $c_2$ with $u,v$ fixed is the solution that minimizes 
$$E(c_1, c_2) = \sum_{i=1}^n (a^{(i)}-c_1 r_u^{(i)}(u,v) + c_2 r_v^{(i)}(u,v))^2.$$
Alternatively, if $Dr(u,v)$ is the Jacobian of $r$ at $u,v$, then we seek to find the minimum of $||a-Dc||^2$. Thus, ${\bf a}$ is tangent to iff 
$$\min_{u,v \in U} \min_{{\bf c} \in R^2} ||{\bf a}-(D {\bf r})(u,v) {\bf c}||^2 = 0.$$
If I get to it I'll work out the exact solution to the inner minimum.
