# How do I check if the normal vector is pointing inside or outside?

Lets say I've a sphere $$x^2+y^2+z^2=1$$ and I need to solve an integral $$\iint_S\vec F\cdot\vec ndS$$. while $$S$$ is the sphere.
And I can't use gauss law because $$\vec F$$ is not continuous at some point inside $$S$$. I had $$\vec F=\left(\frac{x}{\sqrt{x^2+y^2+z^2}},\frac{y}{\sqrt{x^2+y^2+z^2}},\frac{z}{\sqrt{x^2+y^2+z^2}}\right).$$

So I went and tried to go for it normally using ball coordinates $$\vec r(\theta,\phi)=(\cos\theta \sin\phi, \sin\theta \sin\phi, \cos\phi).$$ And I found that $$r_{\theta}\times r_{\phi}=(-\cos\theta \sin^2\phi,-\sin\theta \sin^2\phi,-\sin\phi \cos\phi).$$ Now I know that this could be the normal pointing inside the ball or outside of it.

In order to try to check, I tried to reach a point $$(1,0,0)$$ on it, and check if the "$$x$$" part of the normal is positive or negative in that point.

But I got lost trying to find $$\phi,\theta$$ which satisfy that, and wanted to know if there's any better way to decide in what direction the normal I found is pointing.

Any feedback is appreciated, thanks in advance!

• A common way to decide the direction of a normal vector is to memorize it. When you take the cross product of two vectors, the result will always be in a certain direction. This can be determined using the right hand rule (or any other rules you invent). Commented Jul 4, 2021 at 7:13
• Think of different common surfaces. For a paraboloid $z = x^2 + y^2$ or for a cone $z = \sqrt{x^2+y^2}$, the outward normal vector would generally point downward in the negative $z$ direction. So you should make sure $k$ component of the normal vector has the negative sign. For a sphere centered at origin, you know $(x, y, z)$ is outward. So for $z \gt 0$ you can say that it points generally in the upward direction whereas for $z \lt 0$, it points generally in the downward direction so it is outward normal vector. Commented Jul 4, 2021 at 8:01
• @MathLover Thanks alot, that makes sense, I was also thinking of using the idea of $\theta, \phi$. so if I want to check point $(1,,0,0)$ I know for sure $\phi = \frac{\pi}{2}$, and $\theta = 0$ (as im on xy plane on $x=1,y=0$) and with that I found that this vector is pointing inwards with $\phi = \frac{\pi}{2}$ and $\theta = 0$. what do you think? Commented Jul 4, 2021 at 8:07
• Yes you can do that for a check. Take any point $P(x, y, z)$ on the sphere and connect the origin $O$ (center) to this point on the sphere. Both vectors $\vec{OP}$ and $\vec {PO}$ are normal to the surface. $\vec {OP} = (x-0, y- 0, z-0)$ is pointing outward whereas $\vec {PO} = (0 - x, 0 - y, 0-z)$ is pointing inward. In your case, the unit normal vector $(-\cos\theta \sin\phi, -\sin\theta \sin\phi, -\cos\phi)$ is for a point on the surface given by $(\cos\theta \sin\phi, \sin\theta \sin\phi, \cos\phi)$ and so it is clear it is pointing towards the origin. Commented Jul 4, 2021 at 8:31

One general rule for a region $$\ R\$$ defined by $$\ R=\big\{x\in\mathbb{R}^3\,\big|\,f(x)< C\,\big\}$$, where $$\ f:\mathbb{R}^3\rightarrow\mathbb{R}\$$ is a differentiable function, and $$\ C\in\mathbb{R}\$$ a constant, is that when $$\ f(x)=C\$$ and $$\ \nabla f(x)\ne\vec{0}\$$, then $$\ \nabla f(x)\$$ is an outward normal to the boundary of $$\ R\$$ at the point $$\ x\$$. If you get the normal at a given point in some other way, as you've done by taking the cross product of two tangents to the boundary, then the direction of the normal is outward if the directional derivative of $$\ f\$$ at that point in the direction of the normal is positive, and it's an inward normal if the directional derivative is negative. If the directional derivative is zero, then you need to look at higher order directional derivatives to tell whether $$\ f\$$ is increasing or decreasing in the given direction.
In your case, with $$\ S\$$ being the unit sphere, of which the inside is the open unit ball, $$\ R=\big\{\,(x,y,z)\,|\,x^2+y^2+z^2<1\,\big\}\$$, you have $$\ f(x,y,z)=x^2+y^2+z^2\$$, and $$\ \nabla f(x,y,z)=2\big(x\,\vec{\mathbf{i}}+y\,\vec{\mathbf{j}}+z\,\vec{\mathbf{k}}\big)=2\vec{r}\$$, so $$\ \vec{r}\$$ itself, as a positive multiple $$\ \frac{1}{2}\nabla f\$$ of $$\ \nabla f\$$ is an outward (unit) normal. Note that your cross product, $$r_\theta\times r_\phi=-\sin\phi\,\vec{r}(\theta,\phi)\ ,$$ as a negative multiple of $$\ \vec{r}\$$ (for $$\ 0<\phi<\pi\$$) , must be an inward normal.
If you take the scalar product of your two vectors, $$\vec r . (r_\theta \times r_\phi)$$, you get a quantity which is always negative, showing the vector points inwards.
BTW you are using $$\theta$$ and $$\phi$$ the opposite way round from what I would regard as usual.
• Which is which of $\theta$ and $\phi$ in spherical coordinates is very much not universal. It is more common in math to see $\theta$ as the $xy$ plane angle, so that it's basically the same as it is in polar and cylindrical coordinates, while $\phi$ is the angle against the $z$ axis. However, I know physicists are fond of the opposite convention, and I personally found that immensely confusing when I took courses in quantum mechanics and general relativity. Commented Jul 4, 2021 at 7:42
• @RogerJBarlow Thanks for the answer, Could you explain what quantity means? because I'm a little confused as if i take for example $\theta = \pi$ I will get a positive value in the first component, but I'm not sure if I understood what you meant. Commented Jul 4, 2021 at 7:57
• for two vectors $\vec a$ and $\vec b$, if $\vec a . \vec b$ is positive then $\vec a$ and $\vec b$ are in the same direction, if it is negative they are in opposite directions. In this case it is always negative (or, at least non-positive) as $0 \le \phi \le \pi$ . Indeed your second vector is just your first vector multiplied by $-\sin \phi$. Commented Jul 4, 2021 at 13:00