# Calculate the normal unit vector for scalar function

In theory, if I have a certain function I can get his normal unit vector by using the gradient of it.

$$\hat{f} = \dfrac{\nabla f}{|| \nabla f ||}$$

Example (correction from answer):

$$z = 2 -x -y$$ $$f(x,y,z)= z + x + y -2$$ $$\nabla f(x,y,z)= \hat{i} + \hat{j} + \hat{k}$$ $$\dfrac{\nabla z}{|| \nabla z ||}= \dfrac{1}{\sqrt{3}} (\hat{i} + \hat{j} + \hat{k})$$

Is that correct?

what about this example: $$z = \sqrt{x^2+y^2}$$ $$\nabla f(x,y,z)= \dfrac{x}{\sqrt{x^2+y^2}} \hat{i} + \dfrac{y}{\sqrt{x^2+y^2}} \hat{j} + -\hat{k}$$ $$\dfrac{\nabla f}{|| \nabla f ||}= \dfrac{\dfrac{x}{\sqrt{x^2+y^2}} \hat{i} + \dfrac{y}{\sqrt{x^2+y^2}} \hat{j} + -\hat{k}}{\sqrt{ (\dfrac{x}{\sqrt{x^2+y^2}} )^2 + (\dfrac{y}{\sqrt{x^2+y^2}} )^2 + (-1)^2 }}$$

$$\dfrac{\nabla f}{|| \nabla f ||}= \dfrac{\dfrac{x}{\sqrt{x^2+y^2}} \hat{i} + \dfrac{y}{\sqrt{x^2+y^2}} \hat{j} + -\hat{k}}{\sqrt{2}}$$

-
Is $z$ a function name, or are you describing a surface? – copper.hat Jul 10 '12 at 17:20
It's a surface. – fneron Jul 10 '12 at 17:23

No, this is not correct. You must first write $f(x,y,z)=x+y+z-2$. Then, calculate $\nabla f=\vec i+\vec j+\vec k$ which gives $$\hat{f} = \dfrac{\nabla f}{|| \nabla f ||}=\frac{1}{\sqrt 3}(\vec i+\vec j+\vec k)$$ This is the required normal unit vector.
In your new problem,in calculation of $\nabla f$,there is an error; it should be $\nabla f=\frac{x}{\sqrt{x^2+y^2}}\vec i+\frac{y}{\sqrt{x^2+y^2}}\vec j-\vec k$. Check it.Everything else is fine. – Aang Jul 10 '12 at 18:33