## Section4.4Using Technology to Visualize Potentials

If a scalar field such as temperature or electrostatic potential or gravitational potential represents a scalar-valued physical quantity at each point in space, then, since space is three-dimensional, a scalar field is effectively a function of three variables. How can we graph such functions? For functions of one or two variables, if we use one or two dimensions to represent the domain of the scalar field, we have at least one physical dimension left to represent the value of the function. Thus, functions of one variable are plotted in two dimensions and functions of two variables are plotted in three dimensions, as shown in Figure Figure 4.4.1.

To plot a function of three variables in an analogous way, we would need to live in four physical dimensions.

### Activity4.4.1.

#### (a)

You should take some time to brainstorm some alternative methods of representing a function of three variables.

#### (b)

After you have brainstormed some ideas yourself, you can use the Sage code below to explore several different mechanisms for visualizing scalar fields in three dimensions for the particular case of electrostatic potentials for several discrete charges. Alternatively, if you have access to Mathematica, you can use this Mathematica notebook 1  for the same purpose.

The code in the first box defines the scalar potential $$V\text{.}$$

pretty_print_default(True)
x,y,z=var('x,y,z')
a,b,c=var('a,b,c')
cap(a,b)=max_symbolic(min_symbolic(a,b),-b)
D(a,b,c)=sqrt((x-a)^2+(y-b)^2+(z-c)^2)
V(x,y,z)=(1/D(1/2,1/2,0)+1/D(-1/2,1/2,0)
+1/D(1/2,-1/2,0)+1/D(-1/2,-1/2,0))
V(x,y,z)


This Sage code plots a contour diagram of the scalar potential $$V$$ (on a horizontal slice).

contour_plot(cap(V(x,y,0),10),(x,-1,1),(y,-1,1),
cmap='gray',colorbar=True)


This Sage code graphs the scalar potential $$V$$ on a horizontal slice.

plot3d(cap(V(x,y,0),10),(x,-1,1),(y,-1,1),


This Sage code plots a single, three-dimensional contour of the scalar potential $$V\text{.}$$

implicit_plot3d(V(x,y,z)==5.7,(x,-1,1),(y,-1,1),(z,-1,0))


One possibility to to plot an equipotential surface, i.e. the set of points in space for which the value of the electrostatic potential is some specific fixed number. In this case, you would need to make a different plot for each possible value of the electrostatic potential. Typically, a few different values are sufficient to convey the salient features. See Figure 4.4.2, for an example of the electrostatic potential due to four point charges.

Another possibility is to use color to represent the value of the electrostatic potential. Then the scalar field is represented by a color at each point in space. If we had a great virtual reality program, we could imagine moving through space, examining the colors as we moved around. While we are waiting for that technology to arrive in our classroom, we'll show a picture of some cross sections through space with colors on them. See Figure 4.4.3, for the same example of the electrostatic potential due to four point charges in this new graphical representation.

Because our perception of color is not very fine grained, it is difficult to read an accurate numerical value for the electrostatic potential from a colored graph. We would really like to use the vertical direction on the graph to represent the value of the scalar field, just as we would for functions of one or two variables. But then we cannot show all three spatial directions of the scalar field at once. Figure 4.4.4 shows yet another representation of the electrostatic potential due to four point charges.

math/vfvisv.nb