Skip to main content

Section 11.7 Flux through a cube

The integral in Gauss' Law does not depend on the shape of the surface being used. So let's replace the sphere in the example in Section 11.6 with a cube. Suppose the charge is at the origin, and the length of each side of the cube is \(2\text{.}\) Start by computing the flux through one face. Using the relationship

\begin{equation} \rhat=\frac{x\,\xhat+y\,\yhat+z\,\zhat}{r}\tag{11.7.1} \end{equation}

we have

\begin{gather*} \hbox{flux} = \Int_{-1}^1\Int_{-1}^1 {1\over4\pi\epsilon_0} {q\,\rhat\over r^2} \cdot \kk\,dx\,dy = {q\over4\pi\epsilon_0} \Int_{-1}^1\Int_{-1}^1 \frac{dx\,dy}{\left(x^2+y^2+1\right)^{3/2}} \end{gather*}

One of the two integrals in this double integral can be computed using integral tables, but not the second one. As an alternative, you can use this Mathematica notebook 1  to compute the answer. Does the result agree with the computation for the sphere in Section 11.6?

Activity 11.7.1. Using technology to visualize the flux through a cube.

Use this Mathematica notebook 2  to explore the flux due to a point charge. The notebook will show you the integrand for the flux through the top of a cube, then the integral through the top, followed by the total integral through the entire cube.

Now suppose the charge is not at the origin. Mathematica or Maple can still approximate the integrals numerically to any precision that you want; try some examples. Finally, suppose the charge is on a face or an edge of the cube. What answer do you expect? Check and see.


This worksheet computes the flux of the electric field through the faces of a cube. As you examine the graph of the integrand, you will discover that the integrand is largest near the center of the face. Why? Yes, the center of the face is closest to the charge; is that the only reason? Don't forget that the direction of the electric field also affects the integral, not merely its magnitude.

When using technology to evaluate these integrals, it is worth noticing that some of the integrals can be evaluated exactly, but others only numerically — and that this process requires choosing values for the various constants.

Moving the charge away from the center of the cube changes the flux through each face, but not the total flux — at least so long as you keep the charge inside the cube. If the charge is outside the cube, the flux through each face will be nonzero, but now the total flux will be zero.

So what happens when the charge is located at a corner of the cube? If you imagine the charge as a small but finite sphere, then it is easy to see that an eighth of the charge is “inside” the cube, so that the flux is \(1/8\) of the flux due to a charge located at the center. Equivalently, how much of the electric field due to a charge at the corner of a cube points through the faces of the cube? Precisely \(1/8\text{.}\) Yet another way to describe this result is to consider electric field lines, not all of which pass through the cube.

The Sage code below can be used for the activity above. First, initialize and define the location \(P\) of the charge \(q\text{.}\)

Then, determine the flux of \(\EE=-\grad V\) through a point at the top of the cube...

... and plot the result.

Now do the integral, obtaining the total flux through the top of the cube.

Finally, add up the flux through each face to obtain the total flux out of the cube.