Activity: Visualizing Flux through a Cube

Static Fields 2023 (6 years)
Students explore the effects of putting a point charge at various places inside, outside, and on the surface of a cubical Gaussian surface. The Mathematica worksheet or Sage activity shows the electric field due to the charge, then plots the the flux integrand on the top surface of the box, calculates the flux through the top of the box, and the value of the flux through the whole cube.
What students learn
  • Students see that the integrand of the flux through a surface depends both on the distance of the charge from the surface and on the angle between the direction from the surface to the charge and the unit normal to the surface.
  • Students verify the integral form of Gauss's law for examples of charges inside the cube, on the edges or vertices of the cube, and outside the cube.
  • Media
    • activity_media/vffluxem.nb

Visualizing Flux through a Cube

Complete this Sage activity of this Mathematica worksheet to explore the flux of the electric field from a point charge through a cube.

Instructor's Guide


We usually walk/talk the students through the worksheet with the charge at the center of the box and then encourage small groups to try putting the charge in other places.

Student Conversations

  • Examining the integrand: With the charge at the center of the box, ask students why the value of the integrand is largest is the center of the top surface of the box. Bring out the fact that the charge is closer to that point of the surface and that the entire electric field vector is perpendicular to the surface there. Draw a picture showing these two aspects of the geometry.
  • Understanding more about how Mathematica works: When students are exploring putting the point charge at other places, point out that sometimes Mathematica can do the flux integrals exactly (often in terms of complicated expressions involving arctangents). (The evalf” command in Mathematica is useful in these cases.) At other times, Mathematica will do the integral numerically. Point out where the worksheet sets various constants to one, so that the integral can be done numerically. Also point out the round-off errors that occur.
  • When the charge is not in the center: When encouraged to explore the consequences of putting the point charge at a variety of positions, many groups will choose points on a face, edge, or vertex of the cube. The Mathematica code is robust enough to handle these situations, yielding \(q\over 2\epsilon_0\), \(q\over 4\epsilon_0\), and \(q\over 8\epsilon_0\), respectively. A few students can be bothered by the idea that an infinitesimal point charge can be partially inside the box and partially outside the box. For these students, returning to the idea of flux and drawing pictures of how much of the electric field points through a side of the box (or is parallel to a side of the box) can be helpful. Electric field lines can also be a helpful representation.


Discuss the relationship between electric flux and the charge enclosed by the surface (namely, Gauss's Law).


This activity is part of two sequences of activities: Geometry of Vector Fields Sequence and Flux Sequence.

  • assignment Cube Charge

    assignment Homework

    Cube Charge
    charge density

    Integration Sequence

    Static Fields 2023 (6 years)
    1. Charge is distributed throughout the volume of a dielectric cube with charge density \(\rho=\beta z^2\), where \(z\) is the height from the bottom of the cube, and where each side of the cube has length \(L\). What is the total charge inside the cube? Do this problem in two ways as both a single integral and as a triple integral.
    2. On a different cube: Charge is distributed on the surface of a cube with charge density \(\sigma=\alpha z\) where \(z\) is the height from the bottom of the cube, and where each side of the cube has length \(L\). What is the total charge on the cube? Don't forget about the top and bottom of the cube.
  • group Visualization of Divergence

    group Small Group Activity

    30 min.

    Visualization of Divergence
    Vector Calculus II 23 (12 years) Students predict from graphs of simple 2-d vector fields whether the divergence is positive, negative, or zero in various regions of the domain using the definition of the divergence of a vector field at a point: The divergence of a vector field at a point is flux per unit volume through an infinitesimal box surrounding that point. Optionally, students can use a Mathematica notebook to verify their predictions.
  • assignment Gauss's Law for a Rod inside a Cube

    assignment Homework

    Gauss's Law for a Rod inside a Cube
    Static Fields 2023 (4 years) Consider a thin charged rod of length \(L\) standing along the \(z\)-axis with the bottom end on the \(x,y\)-plane. The charge density \(\lambda_0\) is constant. Find the total flux of the electric field through a closed cubical surface with sides of length \(3L\) centered at the origin.
  • assignment Divergence through a Prism

    assignment Homework

    Divergence through a Prism
    Static Fields 2023 (6 years)

    Consider the vector field \(\vec F=(x+2)\hat{x} +(z+2)\hat{z}\).

    1. Calculate the divergence of \(\vec F\).
    2. In which direction does the vector field \(\vec F\) point on the plane \(z=x\)? What is the value of \(\vec F\cdot \hat n\) on this plane where \(\hat n\) is the unit normal to the plane?
    3. Verify the divergence theorem for this vector field where the volume involved is drawn below. (“Verify” means calculate both sides of the divergence theorem, separately, for this example and show that they are the same.)

  • assignment Divergence

    assignment Homework

    Static Fields 2023 (6 years)

    Shown above is a two-dimensional vector field.

    Determine whether the divergence at point A and at point C is positive, negative, or zero.

  • assignment Quantum concentration

    assignment Homework

    Quantum concentration
    bose-einstein gas statistical mechanics Thermal and Statistical Physics 2020 Consider one particle confined to a cube of side \(L\); the concentration in effect is \(n=L^{-3}\). Find the kinetic energy of the particle when in the ground state. There will be a value of the concentration for which this zero-point quantum kinetic energy is equal to the temperature \(kT\). (At this concentration the occupancy of the lowest orbital is of the order of unity; the lowest orbital always has a higher occupancy than any other orbital.) Show that the concentration \(n_0\) thus defined is equal to the quantum concentration \(n_Q\) defined by (63): \begin{equation} n_Q \equiv \left(\frac{MkT}{2\pi\hbar^2}\right)^{\frac32} \end{equation} within a factor of the order of unity.
  • group Flux through a Cone

    group Small Group Activity

    30 min.

    Flux through a Cone
    Static Fields 2021 (4 years)

    Integration Sequence

    Students calculate the flux from the vector field \(\vec{F} = C\, z\, \hat{z}\) through a right cone of height \(H\) and radius \(R\) .
  • assignment Flux through a Paraboloid

    assignment Homework

    Flux through a Paraboloid
    Static Fields 2021 (5 years)

    Find the upward pointing flux of the electric field \(\vec E =E_0\, z\, \hat z\) through the part of the surface \(z=-3 s^2 +12\) (cylindrical coordinates) that sits above the \((x, y)\)--plane.

  • assignment Cross Triangle

    assignment Homework

    Cross Triangle
    Static Fields 2023 (6 years)

    Use the cross product to find the components of the unit vector \(\mathbf{\boldsymbol{\hat n}}\) perpendicular to the plane shown in the figure below, i.e.  the plane joining the points \(\{(1,0,0),(0,1,0),(0,0,1)\}\).

  • group Acting Out Flux

    group Small Group Activity

    5 min.

    Acting Out Flux
    Static Fields 2023 (5 years)

    flux electrostatics vector fields

    Students hold rulers and meter sticks to represent a vector field. The instructor holds a hula hoop to represent a small area element. Students are asked to describe the flux of the vector field through the area element.

Author Information
Corinne Manogue
Learning Outcomes