\section{Tangent Planes}
Recall, for a function $f(x,y)$ of two variables, the graph of $f$ is the set
$
\{(x,y, f(x,y)) : (x,y) \in \mathcal{D}(f)\}.
$
This graph is a subset of $\mathbb{R}^3$.  In this section, we will assume that the graph $z = f(x,y)$ is ``nice enough'' near some $(x,y) = (a,b)$, so that it has a tangent plane at the point $(a,b, f(a,b))$. 
This is an \underline{assumption} that we will examine later. For now, we state the following without proof.

\medskip\noindent
\fbox{\begin{minipage}{\textwidth}
\begin{theorem} \label{24thm1}
Assume that there is a neighbourhood $B_r(P)$ of a point $P=(a,b)$ such that $f(x,y)$ and both of its partials $f_1(x,y)$, $f_2(x,y)$ are continuous on $B_r(P)$. Then the graph $z=f(x,y)$ has a tangent plane at $(a,b,f(a,b))$.
\end{theorem}
\end{minipage}
}


\medskip

This covers many common functions (polynomials, exponentials, trig functions...) whose partial derivatives are continuous on their domain of definition, but excludes ``pathological" examples such as Example 2.3.4 in Section 2.3.

\subsection{Equation for the Tangent Plane}
To determine an equation for the tangent plane at $(a,b,f(a,b))$, we need:
\begin{itemize}
\item a point that lies in the plane,
\item a vector $\mathbf{n}$ perpendicular to the plane.
\end{itemize}
The point $(a,b,f(a,b))$ lies in the tangent plane. Now we need to find the normal vector. Our strategy for this is to find two vectors $\mathbf{T_1}$, $\mathbf{T_2}$ that are parallel to the tangent plane, then take their cross product to find $\mathbf{n}$.

We can find $\mathbf{T_1}$ and $\mathbf{T_2}$ as follows.
If the tangent plane exists, it has to contain two tangent lines to the curves
$
(x, b, f(x,b))
$
and
$
(a,y, f(a,y))
$
where $(a,b)$ is the (fixed) given point and $x$ and $y$ are variable.


%\vfill
%\pagebreak

\begin{figure}[H]\label{24fig1}
\centering
\includegraphics[width= .6\textwidth]{24fig1.png}
\caption{The graph of a function $z = f(x,y)$, its tangent plane, and the tangent lines described here.}
\end{figure}

Suppose we take a cross-section in the plane $y = b$.  Then we obtain the following.


\begin{figure}[H]\label{24fig2}
\centering
\includegraphics[width= .65\textwidth]{24fig2.pdf}
\caption{An intersection of the previous surface with the $y = b$ plane.}
\end{figure}

In the plane $y = b$, the tangent line is parallel to the $y = 0$ plane, and has slope $f_{x} (a,b)$ in the $y = b$ plane.  In $\mathbb{R}^3$,  the direction vector of this tangent line is given by the formula
$$
\mathbf{T_1} = \mathbf{i} + f_x (a,b) \mathbf{k}.
$$
Notice that $\mathbf{T_1}$ has no $\mathbf{j}$ component because $\mathbf{T_1}$ is parallel to the $xz$-plane.  Similarly, the tangent line in the plane $x = a$ has the direction vector
$$
\mathbf{T_2} = \mathbf{j} + f_y (a,b) \mathbf{k}.
$$

We now find the normal vector. The vectors $\mathbf{T_1}$ and $\mathbf{T_2}$ are both parallel to the tangent plane at $(a,b,f(a,b))$.  Hence, the vector
$$
\mathbf{n} =
\begin{vmatrix}
\mathbf{i} & \mathbf{j} & \mathbf{k} \\[1ex]
1 & 0 & f_x (a,b) \\[1ex]
0 & 1 & f_j (a,b)
\end{vmatrix}
=- f_x (a,b) \mathbf{i} - f_y (a,b) \mathbf{j} + \mathbf{k}
$$
is perpendicular to the tangent plane.  The equation for the tangent plane then follows from the calculation,
\begin{eqnarray*}
\quad & \quad & \mathbf{n} \cdot \langle x - a, y - b, z - f(a,b) \rangle = 0 \\[1ex]
\quad & \Leftrightarrow & -f_x (a,b) (x - a) - f_y (a,b) (y - b) + (z - f(a,b)) = 0
\end{eqnarray*}

A simplification leads to the following formula.

\begin{proposition}
Suppose that $z = f(x,y)$ admits a tangent plane at the point $(a,b, f(a,b))$ in $\mathbb{R}^3$.  Then, the equation of this tangent plane is given by
\begin{equation}\label{24eq1}
z = f(a,b) + f_x (a,b) (x - a) + f_y(a,b) (y - b)
\end{equation}
\end{proposition}

\medskip
\textbf{Beware!} This equation is only valid {\bf if} the tangent plane exists at the given point $(x,y,z) = (a,b,f(a,b))$ on our surface $z = f(x,y)$.

\medskip

The vector $\mathbf{n} = \mathbf{T_1} \times \mathbf{T_2}$ is the \textbf{normal vector} to the surface at $(a,b,f(a,b))$, and the line passing through $(a,b,f(a,b))$ and parallel to $\mathbf{n}$ is sometimes called the \textbf{normal line} to the surface at that point.

\begin{figure}[H]\label{24fig3}
\centering
\includegraphics[width= .9\textwidth]{24fig3.png}
\caption{The vector $\mathbf{n}$ at the point $(a,b,f(a,b))$ on the tangent plane.}
\end{figure}


\subsection{Tangent Planes May Not Exist} It is entirely possible that the tangent plane to $z = f(x,y)$ at a point $(a,b, f(a,b))$ might not exist.  This may happen \textit{even in situations where we could apply the tangent plane equation} \eqref{24eq1}.  Below is an example of a surface $z = f(x,y)$ where $f_x (0,0)$ and $f_y (0,0)$ both exist and yet there is no good approximating tangent plane for the surface at $(0,0,f(0,0))$.

\begin{example}
Consider the graph of $f(x,y)$ where $f$ is given by
$$
f(x,y) =
\begin{cases}
\frac{x y}{x^2 + y^2} \, , \, (x,y) \neq 0 \\
0,  \quad \quad (x,y) = 0
\end{cases}
$$
We previously calculated that $f_x (0,0) = f_y (0,0) = 0$ (and, clearly, $f(0,0) = 0$).  Hence, were a tangent plane to exist at $(a,b,f(a,b)) = (0,0,0)$, it would necessarily have equation
$$
z = 0 + 0 (x - 0) + 0 (y - 0) = 0.
$$
But there is a problem! Notice that, for $t \neq 0$,  $f(t,t) = 1/2$.  Hence, the graph of $f(x,y)$ contains the punctured line $L_0 = \{(t,t,1/2) : t \in \mathbb{R} \setminus \{0\}\}$.  This line is parallel to the ``false'' tangent plane $\{(x,y,z) : z = 0\}$ and lies at a distance $1/2$ from it.
In particular, the false tangent plane $\{z = 0 \}$ fails to give a good approximation to the graph $\{(x,y,f(x,y) : (x,y,z) \in \mathbb{R}^3\}$ along the punctured line $L_0$. 

\begin{figure}[H]\label{24fig4}
\centering
\includegraphics[width= .9\textwidth]{24fig4.png}
\caption{The surface $z = f(x,y)$ overlaid with the line $\{(t,t,1/2) : t \in \mathbb{R}\}$ and the plane $\{(x,y,z) : z = 0\}$. }
\end{figure}

\end{example}


\section*{Worked Problems}
In the questions below, we will take it for granted that the tangent planes at the given points exist. This is provided to us by Theorem \ref{24thm1}.


\begin{enumerate}[1.]
\item {\it Find the equation of the tangent plane to the graph $f(x,y) = x y^2$ at $(x,y) = (2,1)$. }

\bigskip
We have $f(2,1) = 2 \cdot 1 = 2$, and
\begin{eqnarray*}
f_x (x,y) = y^2 & \Longrightarrow & f_x(2,1) = 1 \\[1ex]
f_y (x,y) = 2 x y & \Longrightarrow & f_y (2,1) = 4
\end{eqnarray*}
The tangent plane has normal vector $\mathbf{n} = \langle -1, -4,1 \rangle$ and equation
$$
z = 2  + 1 (x - 2) + 4 (y - 1) = x + 4 y - 4.
$$

\bigskip


\item {\it Find the vector parametric equation of the normal line to the surface $z = x y^2$ at $(x,y) = (2,1)$.}

\bigskip

We already have,
$$
\mathbf{n} = \langle-f_x (2,1), -f_y (2,1), 1 \rangle = \langle -1, -4 , 1\rangle.
$$
Moreover,  the line necessarily passes through the point $(2,1,f(2,1)) = (2,1,2)$. The equation of this line is therefore,
$$
\mathbf{r} (t) =\langle 2,1,2 \rangle + t \langle -1, -4 ,1 \rangle
$$

\bigskip



\item  {\it Find all points on the surface $z = x^4 + 2 y^2$ where the plane tangent to the surface is parallel to the plane $x + y + z = 0$.}

\bigskip

We have $\frac{\partial z}{\partial x} = 4 x^3$ and $\frac{\partial z}{\partial y} = 4y$.  The normal vector to the surface at an arbitrary point $(x,y,z)$ is given by,
$$
\mathbf{n_1} = - 4 x^3 \mathbf{i} - 4y \mathbf{j} + \mathbf{k}
$$
We want this vector to be parallel to the vector normal to the plane $x + y + z = 0$, which is the vector $\mathbf{n_2} = \mathbf{i} + \mathbf{j} + \mathbf{k}$.  Notice that the coefficient of $\mathbf{k}$ in $\mathbf{n_1}$ and $\mathbf{n_2}$ is the same (equal to 1). So, if we want $\mathbf{n_1}$ and $\mathbf{n_2}$ to be parallel,  we must have $\mathbf{n_1} = \mathbf{n_2}$. In particular, by equating $\mathbf{i}$ and $\mathbf{j}$ components
$$
x^3 = - \frac{1}{4},  \, \, -4y = 1 \Longrightarrow x = - \sqrt[3]{\frac{1}{4}},  \, \, y = - \frac{1}{4}.
$$
Let us determine $z = f(x,y) = x^4 + 2 y^2$,  which is,
$$
z = \left(- \sqrt[3]{\frac{1}{4}}\right)^4 + 2\left(-\frac{1}{4}\right)^2 = \left(\frac{1}{4}\right)^{4/3} + \frac{1}{8}.
$$
So, the only point $(x,y,z) = (x,y,f(x,y))$ on the surface with tangent plane parallel to the plane $x + y + z = 0$ is,
$$
(x,y,z) = \left( - \sqrt[3]{\frac{1}{4}},  \,  - \frac{1}{4}, \left(\frac{1}{4}\right)^{4/3} + \frac{1}{8} \right)
$$

\bigskip

 \item 
{\it  Find all points on the paraboloid $z=x^2+4y^2$ where the tangent plane is parallel to the plane
 passing through the points $(0,0,0)$, $(6,1,4)$, $(1,-1,2)$. (For each such point, provide its $(x,y,z)$ coordinates.)}

\bigskip

Two planes are parallel if and only if their normal vectors are parallel. Therefore, we need to find the normal vector $\mathbf{n}$ to the plane containing the three given points, and then we need to find the points on the paraboloid where the normal vector $\mathbf{N}$ to the paraboloid is a multiple of $\mathbf{n}$.

Let $O=(0,0,0)$, $P=(6,1,4)$ and $Q=(1,-1,2)$. We can get a normal vector to the plane by taking the cross product of 
$\vec{OP}=\langle 6,1,4 \rangle$ and $\vec{OQ}=\langle 1,-1,2 \rangle$:
\begin{equation*}
\mathbf{n} = \vec{OP} \times \vec{OQ} = \left|
\begin{array}{ccc}
\ii & \jj & \kk\\
6 & 1 & 4\\
1 & -1 & 2\\
\end{array} 
\right| = \langle 6,-8,-7 \rangle.
\end{equation*}
Next, we find a vector normal to the paraboloid. Let 
$f(x,y)=x^2+4y^2$, so that the graph of $f$ is the paraboloid in question. Given $(a,b)\in\rr^2$, a normal vector to the tangent plane is given by $\mathbf{N}(a,b)=\langle -f_x(a,b),-f_y(a,b),1\rangle = \langle -2a,-8b,1 \rangle.$

Note that $\mathbf{N}(a,b)$ is parallel to $\mathbf{n}$ exactly when $\mathbf{N}(a,b)=\lambda\mathbf{n}$ for some $\lambda\in\rr$. In terms of components, this means that
\begin{equation*}
\left\{
\begin{array}{rcl}
-2a & = & 6\lambda\\
-8b & = & -8\lambda\\
1 & = & -7\lambda\\
\end{array}
\right.
\end{equation*}
From the last equation we get $\lambda=-\frac{1}{7}$, and then the other two equations imply that $a=\frac{3}{7}$ and $b=-\frac{1}{7}$. Hence the only point on the paraboloid where the tangent plane is parallel to the plane through $O,P,Q$ is $(\frac{3}{7},-\frac{1}{7},\frac{13}{49})$, where we found the $z$-coordinate from the equation of the paraboloid.

\end{enumerate}


\section*{Practice Problems}
\begin{enumerate}[1.]

\item{Find the equation of the tangent plane to the graph of the function
$f(x,y)=ye^{xy^2}$ at the point $(0,2)$.}

\bigskip

\item{Find the equation of the tangent plane to the surface $z=5x^2y-y^2$ at the point
where $x=-1$, $y=3$.}

\bigskip

\item {Find all points $(x,y,f(x,y))$ where the tangent plane to the graph of the function
$f(x,y)=x^2+3xy-2y^2$ is parallel to the plane $x+10y-z=3$. For each such point, find the
equation of the tangent plane.}

\bigskip

\item 
{Find all points $P=(1,b,c)$ such that $P$ lies on the paraboloid $z=x^2+y^2$ and the tangent plane to this
paraboloid at $P$ passes through the point $(2,4,18)$.}

\bigskip

\item {Find all values of $(a,b)$ such that the tangent plane to the surface
$z=4x^2-y^2$ at $(a,b,4a^2-b^2)$ is parallel to the line with parametric
equations $x=t+1$, $y=2t$, $z=-4t+9$.}
\end{enumerate}





