# Finding Tangent Line and Tangent Plane using gradient

So in 3D Function $$z=f(x,y)$$

The gradient is $$\nabla f(x,y) = \begin{bmatrix}\frac{∂f}{∂x}\\\frac{∂f}{∂y}\end{bmatrix}$$

If I want to find the equation of tangent line at the point $$P(x_0,y_0)$$

Then, $$\begin{bmatrix}\frac{∂f(x_0,y_0)}{∂x}\\\frac{∂f(x_0,y_0)}{∂y}\end{bmatrix}⋅\begin{bmatrix}x-x_0\\y-y_0\end{bmatrix} = 0$$

Now, If I want the tangent plane to that point $$P(x_0,y_0,f(x_0,y_0))$$

I, somehow, need to add the third component to that gradient vector with value = -1 $$\begin{bmatrix}\frac{∂f(x_0,y_0)}{∂x}\\\frac{∂f(x_0,y_0)}{∂y}\\-1\end{bmatrix}$$

And then the tangent plane equation becomes $$\begin{bmatrix}\frac{∂f(x_0,y_0)}{∂x}\\\frac{∂f(x_0,y_0)}{∂y}\\-1\end{bmatrix}⋅\begin{bmatrix}x-x_0\\y-y_0\\z-z_0\end{bmatrix} = 0$$

My question is where is that minus one come from?

I think it wouldn't be safe to write in an exam that I just add minus 1 to another component of gradient vector. When the question is about finding tangent line of level curve and tangent plane.

It also happen in 2D function as well when the gradient is just the slope and it has only one dimension. If I want to find tangent equation, I just add -1 to second component of gradient vector.

PS. Anyway, I do know a basic method to find tangent equation in 2D by just finding slope and put the point in $$y-y_0 = m(x-x_0)$$

Hint: with the obvious parametrization of the surface as function graph $$x = x,\qquad y = y,\qquad z = f(x,y)$$ we have that $$\begin{bmatrix}\frac{∂f(x_0,y_0)}{∂x}\\\frac{∂f(x_0,y_0)}{∂y}\\-1\end{bmatrix} = \cdots\times\cdots$$ is the normal vector, vector product of the tangent vectors...