The page you are reading is part of a draft (v2.0) of the "No bullshit guide to math and physics."
The text has since gone through many edits and is now available in print and electronic format. The current edition of the book is v4.0, which is a substantial improvement in terms of content and language (I hired a professional editor) from the draft version.
I'm leaving the old wiki content up for the time being, but I highly engourage you to check out the finished book. You can check out an extended preview here (PDF, 106 pages, 5MB).
We saw in the previous chapters that the electric field $\vec{E}$ is a useful concept in order to visualize the electromagnetic effects produced by charged objects. More specifically, we imagined electric field lines which are produced by positive charges $+Q$ and end up on negative charges $-Q$. The number of field lines produced by a charge $+2Q$ is the double of the number of field lines produced by a charge $+Q$.
In this section, we learn how to count the number of field lines passing through a surface (electric flux) and infer facts about the amount of charge that the surface contains. The relationship between the electric flux leaving a surface and the amount of charge contained in that surface is called Gauss' law.
Consider the following reasoning. To keep the numbers simple, let us say that a charge of 1[C] produces exactly 10 electric field lines. Someone has given you a closed box $B$ with surface area $S$. Using a special instrument for measuring flux, you find that there are exactly 42 electric field lines leaving the box. You can then infer that there must be a net charge of 4.2[C] contained in the box.
In some sense, Gauss' law is nothing more than a statement of the principle of conservation of field lines. Whatever field lines are created within some surface must leave that surface at some point. Thus we can do our accounting in two equivalent ways: either we do a volume accounting to find the total charge inside the box, or we do a surface accounting and measure the number of field lines leaving the surface of the box.
a vector $\hat{n}$ which points perpendicular to the surface at that point.
Instead of a point charge $Q$, we can have charge spread out:
The charge density of a long wire of length $L$ is $\lambda = \frac{Q}{L}$.
The charge density of a disk with radius $R$ is $\sigma = \frac{Q}{\pi R^2}$.
The charge density of a cube of uniform charge and side length $c$ is $\rho = \frac{Q}{c^3}$.
Recall the following basic facts about volumes and surface areas of some geometric solids. The volume of a parallelepiped (box) of sides $a$, $b$, and $c$ is given by $V=abc$, and the surface area is given by $A=2ab+2bc+2ac$. The volume of a sphere of radius $r$ is $V_s=\frac{4}{3}\pi r^3$ and the surface area is $A_s=4\pi r^2$. A cylinder of height $h$ and radius $r$ has volume $V_c=h\pi r^2$, and surface area $A_c=(2\pi r)h + 2 (\pi r^2)$.
For any surface $S$, the electric flux passing through $S$ is given by the following vector integral \[ \Phi_S = \int_S \vec{E} \cdot d\vec{A}, \] where $d\vec{A}=\hat{n} dA$, $dA$ is a piece of surface area and $\hat{n}$ points perpendicular to the surface.
I know what you are thinking “Whooa there Johnny! Hold up, hold up. I haven't seen vector integrals yet, and this expression is hurting my brain because it is not connected to anything else I have seen.” Ok you got me! You will learn about vector integrals for real in the course Vector Calculus, but you already have all the tools you need to understand the above integral: the dot product and integrals. Besides, in first electromagnetism course you will only have to do this integral for simple surfaces like a box, a cylinder or a sphere.
In the case of simple geometries where the strength of the electric field is constant everywhere on the surface and its orientation is always perpendicular to the surface (\hat{E}\cdot\hat{n}=1) the integral simplifies to: \[ \Phi_S = \int_S \vec{E} \cdot d\vec{A} = |\vec{E}| \int_S (\hat{E} \cdot \hat{n}) dA = |\vec{E}| \int_S 1 dA = |\vec{E}|A. \]
In all problems and exams in first year electricity and magnetism we will
have $\Phi_S = |\vec{E}|A$ or $\Phi_S = 0$ (if $\vec{E}$ is parallel to the surface),
so essentially you don't have to worry about the vector integral.
I had to tell you the truth though, because this is the minireference
way.
Gauss' law states that the electric flux $\Phi_S$ leaving some closed surface $S$ is proportional to the total amount of charge $Q_{in}$ enclosed inside the surface: \[ \frac{Q_{in}}{\varepsilon_0} = \Phi_S \equiv \int_S \vec{E} \cdot d\vec{A}. \] The proportionality constant is $\varepsilon_0$, the permittivity of free space.
Consider a spherical surface $S$ of radius $r$ enclosing a charge $Q$ at its centre. What is the strength of the electric field strength, $|\vec{E}|$, on the surface of that sphere?
We can find this using Gauss' law as follows: \[ \frac{Q}{\varepsilon_0} = \Phi_S \equiv \int_S \vec{E} \cdot d\vec{A} = |\vec{E}| A = |\vec{E}| 4 \pi r^2. \] Solving for $|\vec{E}|$ we find: \[ |\vec{E}| = \frac{Q}{4 \pi \varepsilon_0 r^2} = \frac{k_eQ}{r^2}. \] I bet you have seen that somewhere before. Coulomb's law can be derived from Gauss' law, and this is why the electric constant is $k_e=\frac{1}{4\pi \epsilon_0}$.
Consider line charge of charge density $\lambda$ [C/m]. Imagine a charged wire which has 1[C] of charge on each meter of it. What is the strength of the electric field strength at a distance $r$ from the wire?
This is a classical example of a bring your own surface (BYOS) problem: the problem statement didn't mention any surface $S$, so we have to choose it ourselves. Let $S$ be the surface are of a cylinder of radius $r$ and height $h=1$[m] that encloses the line charge at its centre. We now write down Gauss' law for that cylinder: \[ \begin{align} \frac{\lambda (1 [\textrm{m}])}{\varepsilon_0} & = \Phi_S \equiv \int_S \vec{E} \cdot d\vec{A} \nl & = \vec{E}({r}) \cdot \vec{A}_{side} + \vec{E}_{top} \cdot \vec{A}_{top} + \vec{E}_{bottom} \cdot \vec{A}_{bottom} \nl & = (|\vec{E}|\hat{r}) \cdot \hat{r} 2 \pi r (1 [\textrm{m}]) + 0 + 0 \nl & = |\vec{E}| (\hat{r}\cdot \hat{r}) 2 \pi r (1 [\textrm{m}]) \nl & = |\vec{E}| 2 \pi r (1 [\textrm{m}]). \end{align} \]
Solving for $|\vec{E}|$ in the above equation we find \[ |\vec{E}| = \frac{ \lambda }{ 2 \pi \varepsilon_0 r } = \frac{ 2 k_e \lambda }{ r }. \]
Which you should also have seen before (Example 1 in electrostatic_integrals ).
Assume you have two large metallic plates of opposite charges (a capacitor). The (+) plate has charge density $+\sigma$[C/m$^2$] and the (-) plate has $-\sigma$[C/m$^2$]. What is the strength of the electric field between the two plates?
Consider first a surface $S_1$ which makes a cross section of area $A$ that contains sections of both plates. This surface contains no net charge, so by Gauss' law, we conclude that there are no electric field lines entering or leaving this surface. An electric field $\vec{E}$ exits between the two plates and nowhere outside of the capacitor. This is, by the way, why capacitors are useful: since they store a lot of energy in a confined space.
Consider now a surface $S_2$ which also makes a cross section of area $A$, but only goes halfway through the capacitor, enclosing only the (+) plate. The total charge inside the surface $S_2$ is $\sigma A$, therefore by Gauss' law \[ \frac{\sigma A}{\varepsilon_0} = |\vec{E}|A, \] we conclude that the electric field strength inside the capacitor is $|\vec{E}| = \frac{\sigma }{\varepsilon_0}$.
We will see in capacitors, that this result can also be derived by thinking of the electric field as the spacial derivative of the voltage on the capacitor. You should check that the two approaches lead to the same answer for some physical device with area $A$, plate separation $d$.
The flux $\Phi_S$ is a measure of the strength of the electric field lines passing through the surface $S$. To compute the flux, we need the concept of directed area, that is, we split the surface $S$ into little pieces of area $d\vec{A} = \hat{n} dA$ where $dA$ is the surface area of a little piece of surface and $\hat{n}$ is a vector that points perpendicular to the surface. We need this kind of vector to calculate the flux leaving through $dA$: \[ d\Phi_{dA} = \vec{E} \cdot \hat{n} dA, \] where the dot product is necessary to account for the relative orientation of the piece surface are and the direction of the electric field. For example if the piece-of-area-perpendicular vector $\hat{n}$ points outwards on the surface and an electric field of strength $|\vec{E}|$ is leaving the surface then the flux integral will be positive. If on the other hand electric field lines are entering the surface, the integral will come out negative since $\vec{E}$ and $d\vec{A}$ will point in opposite directions. Of particular importance are surfaces where the electric field lines are parallel to the surface: in that case $\vec{E} \cdot \hat{n} dA = 0$.
Have you ever wondered why the equation for the strength of the electric field $|\vec{E}|(r )$ at a function of the distance $r$ is given by the formula $|\vec{E}(r )|=\frac{kQ}{r^2}$? Why is it one-over-$r$-squared exactly? Why not one over $r$ to the third power or the seventh?
The one-over-$r$-squared comes from Gauss' law. The flux $\Phi$ is a conserved quantity in this situation. The field lines emanating from the charge $Q$ (assumed $Q$ is positive) flow outwards away from the charge and uniformly in all directions. Since we know that $\Phi = |\vec{E}|A_s$, then it must be that that $|\vec{E}| \propto 1/A_s$. The surface area of sphere is
Imagine now applying Gauss' law to a small surface which tightly wraps the charge (small $r$) and a larger spherical surface (big $r$). The total flux of electric field through both surfaces is the same. The flux near the charge is due to a very strong electric field that flows out of a small surface area. The flux far away from the charge is due to a very weak field over a very large surface area.
So what was this chapter all about? We started with crazy stuff like vector integrals (more specifically surface integrals) denoted by fancy Greek letters like $\Phi$, but in the end we derived only three results which we already knew. What is the point?
The point is that we have elevated our understanding from the formula level to a principle. Gauss' law is a super-formula: a formula that generates formulas. The understanding of such general principles that exist in Nature is what physics is all about.