Is the gradient a surface normal vector or does it point in the direction of maximum increase of f

Solution 1:

They’re talking about gradients of two different functions. In the first case, you’ve got, for example, the graph of some function $f:\mathbb R^{n-1}\to\mathbb R$, i.e., the surface described by $y=f(\mathbf x)$. In this case, $\nabla f\in\mathbb R^{n-1}$ points in the direction of greatest increase. In the second case, you’ve got a level surface of a function, that is, some function $g:\mathbb R^n\to\mathbb R$ and the surface defined implicitly by $g(\mathbf x)=0$. In this second case, the gradient $\nabla g\in\mathbb R^n$ is normal to the tangent (hyper)plane, and so is a surface normal.

The two ideas are connected, of course. The surface $y=f(\mathbf x)$ can also be viewed as a level surface of the function $g:(\mathbf x;y)\mapsto f(\mathbf x)-y$, and so $\nabla g=(\nabla f;-1)$.