## Section11.7Flux 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

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

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?

### Activity11.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.

Hint.

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{.}$$

pretty_print_default(True)
x,y,z=var('x,y,z')
q=var('q')
eps=var('epsilon0')
L=1
xhat=vector([1,0,0])
yhat=vector([0,1,0])
zhat=vector([0,0,1])
P=(0,0,0)
a,b,c=P[0],P[1],P[2]
r=sqrt((x-a)^2+(y-b)^2+(z-c)^2)
V=1/r
E


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

Ftop=E.subs(z=L).dot_product(zhat)/4/pi
Ftop


... and plot the result.

Fg=plot3d(Ftop,(x,-L,L),(y,-L,L),adaptive=true)
show(Fg,aspect_ratio=[1,1,10])


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

from scipy import integrate
Ft=Ftop.function(x,y)  # avoid deprecated syntax in scipy
q/eps*numerical_approx(FF,digits=3)


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

Fbot=E.subs(z=-L).dot_product(-zhat)/4/pi
Frgt=E.subs(y=L).dot_product(yhat)/4/pi
Flft=E.subs(y=-L).dot_product(-yhat)/4/pi
Ffro=E.subs(x=L).dot_product(xhat)/4/pi
Fbac=E.subs(x=-L).dot_product(-xhat)/4/pi
Fb=Fbot.function(x,y)  # avoid deprecated syntax in scipy
Fr=Frgt.function(x,z)  # avoid deprecated syntax in scipy
Fl=Flft.function(x,z)  # avoid deprecated syntax in scipy
Ff=Ffro.function(y,z)  # avoid deprecated syntax in scipy
Fk=Fbac.function(y,z)  # avoid deprecated syntax in scipy

paradigms.oregonstate.edu/media/activity_media/vffluxem.nb
paradigms.oregonstate.edu/media/activity_media/vffluxem.nb