Gauss's Law relates the Electric Flux through a closed mathematical surface to the charge contained within that surface.

Electric Flux through a (small) section of areais defined by the scalar product , which depends upon the strength of the electric field, the size of the section of area and the relative orientation of the electric field and the section of area:

In general, the field (and flux) will depend upon the size and locations of the charges relative to the surface

This “derivation” of Gauss's Law hinges upon the symmetry of the electric field lines emanating from a point charge (uniformly, in 3 dimensions)

For a point charge, consider a patch on a variable radius sphere centered about the charge, where the patch always corresponds to the same solid angle. Then the patches for one radius will be the projection of the patch from any other radius sphere. Because the area is proportional to the square of the radius and the electric field strength (which is perpendicular to the patch) is inversely proportional to the square of the distance, the flux through the patch does not depend upon the sphere's radius. In terms of field lines: if a field line from the charge goes through the patch at one radius, it must go through any patch covering the same solid angle, and if the field line does not go through the patch at on radius, it necessarily misses any other patch covering the same solid angle.

Any (small) patch of area can be projected onto a sphere:

Picking a (small) patch of area from an arbitrary mathematical surface can be projected onto a sphere.

To calculate the total flux through a surface containing a point charge, take small patches which cover the surface, project those patches onto spheres centered on the charge which in turn are projected onto one common sphere. Each projection has the same contribution to the total flux.

The total flux through the arbitrary surface containing the charge is the same as the total flux through a sphere centered about the charge:

If the charge is outside the mathematical surface, then any field line which enters the surface must also exit the surface producing zero net contribuion to the total flux. If there are multiple charges inside the surface, then since the electric field is the superposition of the contributions of each point charge, the total flux through the surface will simply be the sum of the contributions of each individual point charge. Thus the net flux through an arbitray mathematical surface is given by: