so I'm new to Mathematica but kind of fail to find the proper function. I read the documentation forr quite some time now.

So I have an electric field and it's potential and I'd like to plot both of them.

$\vec{E}(x,y,z)=\begin{pmatrix}x^2+z\\y\\x\end{pmatrix}$

$\phi = -\frac{1}{3}x^3-xz-\frac{1}{2}y^2$

With $\vec{E}=-\nabla \phi$

What I did in mathematica:

VectorPlot3D[{x^2 + z, y, x}, {x, -5, 5}, {y, -5, 5}, {z, -5, 5}, VectorScale -> small, PlotTheme -> "Marketing"]


That looks quiet okay - I think thats right. But I have no idea how to Plot the potential properly. Can anyone help me here please? :)

• $\phi$ is a function of 3 variables; please specify how do you want it to be plotted, e.g. a slice or sth else. – corey979 Oct 21 '16 at 13:36

It really depends on what your purpose is. Here are a few built-in options for visualizing such a function - you should read the docs for each to see what options are available.

You can make a 3D Image which is best for gaining intuition, or qualitative information in cases like these.

phi[x_,y_,z_]:=-1/3*x^3-x*z-1/2*y^2;
samples=Range[-5,5,0.1];
img3d = Image3D[Table[phi[x,y,z],{x,samples},{y,samples},{z,samples}]]


Or:

GraphicsGrid@Partition[Image3DSlices@img3d,4]


To see the slices from the 3D image

Or you can make a 3D slice contour plot:

SliceContourPlot3D[
phi[x, y, z], {x, -5, 5}, {y, -5, 5}, {z, -5, 5}
, Contours -> 10
]


Which I find hard to interpret

Or you can look at individual contour plots in 2D for a fixed plane e.g. z=0:

ContourPlot[phi[x, y, 0], {x, -5, 5}, {y, -5, 5}]


As Simon Woods points out, I forgot the most obvious answer, ContourPlot3D:

ContourPlot3D[
phi[x, y, z], {x, -5, 5}, {y, -5, 5}, {z, -5, 5}
, Contours -> 10
]


• I think ContourPlot3D would be a good addition to this answer – Simon Woods Oct 21 '16 at 19:19
• @Simon Woods, I knew I forgot something. Thanks! – N.J.Evans Oct 21 '16 at 20:23
• Thanks - I'll look into it and respond later properly. – xotix Oct 28 '16 at 9:56