Wolfram Blog
Itai Seggev

Exploring Maxwell’s Equations with Mathematica 9

September 19, 2013 — Itai Seggev, Mathematica Algorithm R&D

I love Maxwell’s equations. As a freshman in college, while pondering whether to major in physics, computer science, or music, it was the beauty of these equations and the physical predictions that can be elegantly extracted from them that made me decide in favor of physics. On a more universal level, the hints in Maxwell’s equations led Einstein to write Zur Elektrodynamik bewegter Körper (“On the Electrodynamics of Moving Bodies”), more commonly known as Einstein’s first paper on the theory of relativity. The quantum version of the equations, quantum electrodynamics (QED), remains our most successful physical theory, with predictions verified to 12 decimal places. There are many reasons to love Maxwell’s equations. And with Mathematica 9′s new vector analysis functionality, exploring them has never been easier.

So what exactly are Maxwell’s equations? They are a set of four partial differential equations that describe how electric and magnetic fields respond to charges, currents, and each other. In 1861, James Clerk Maxwell corrected and combined four disparate equations that had been known in one form or another in order to create a comprehensive theory of electromagnetism. In natural Lorentz-Heaviside units, they take the following form.

Maxwell's Equations

In the above, ℰ is the electric field, ℬ is the magnetic field, ρ is the charge density, and j is the current density. The operation Divergence of v is called the divergence of v and is a measure of whether the field in a region is pointing away from a point (a positive number), in toward the point (a negative number), or uniformly across it (zero). Finally, Curl of v is the curl of v and is a measure of how quickly and in what direction the field is swirling about a particular point. Thus, while Maxwell’s equations look complicated—and have many interesting mathematical properties—they can be summarized as follows:

1) Electric fields point away from positive charges and toward negative charges.

2) Magnetic fields never point in or out of a single location, but only point uniformly in the same direction or form closed loops.

3) Electric fields swirl when there is a magnetic field changing in time.

4) Magnetic fields swirl when there is a time-varying electric field or when an electric current is flowing.

Perhaps the most famous solution of Maxwell’s equations is the Coulomb field, which is the electric field and magnetic field of a stationary point with charge q. In spherical coordinate {r,θ,φ} these have the form

Coulomb field

We can verify that these are in fact a solution to Maxwell’s equation using the new Div and Curl functions. These take the field to be differentiated, the coordinates, and (optionally) a coordinate system. Since these solutions are expressed in spherical coordinates, the syntax is

Div and Curl functions

Using the new function TransformedField, we can convert the electric field to Cartesian coordinates {x,y,z}.

TransformedField

There is no need to convert the other fields, since they are all zero and therefore will remain zero in all coordinate systems. Still, we can verify that &#8496Cartesian satisfies Maxwell’s equations in the new coordinate systems.

verify that ECartesian satisfies Maxwell's equations

Here is a visualization of the electric field in which the charge has been set to 4π. Since this charge is positive, the field is pointing away from the charge at the center. Also, the magnitude of the field decreases rapidly with distance from the center because it is proportional to one over r squared.

VectorPlot3D

Mathematica supports many more coordinate systems than just the basic spherical and Cartesian coordinates. All of them can be found using the function CoordinateChartData. In three dimensions, 14 coordinate systems are supported.

CoordinateChartData

One of the most important discoveries Maxwell made was that electric and magnetic fields can form wave configurations which travel from one place to another. The discovery of electromagnetic waves has led to radio, television, radar, and countless other technologies. The derivation is as elegant as it is short. Assuming we are in vacuum (ρ==0 and j==0), we take the curl of both sides of the third Maxwell equation, yielding

Maxwell's Third Equation

Using the following vector identity on the left-hand side

Vector identity

and interchanging the order of operations and substituting in the fourth Maxwell equation on the left-hand side yields

Maxwell's Fourth Equation

But by the first Maxwell equation, given the vacuum condition, the first term in the equation is also zero. Rearranging produces the famed wave equation for the electric field.

Maxwell's Wave Equation

Performing a similar analysis of the fourth Maxwell equation produces the same wave equation of ℬ.

One of the simplest solutions to these wave equations is the plane-wave solution given by

Plane-wave solution

This solution represents a uniform beam of light traveling in a single direction. Of course, the solution obeys Maxwell’s equations.

A uniform beam of light traveling in a single direction.

It also obeys the specific wave equations derived above.

It obeys

Plane wave solutions model electromagnetic waves that are far from the source, as compared with the wavelength of the wave or the size of the source, traveling over relatively short distances. If we plot intensity ℐ = |ℰxℬ| as a function of position and let time vary, we see a wave pattern moving to the right.

A wave pattern moving to the right.

Another simple but important approximate solution to Maxwell’s equation is the dipole radiation field, given in spherical coordinates by

Dipole radiation field

As these are approximate solutions, they do not exactly satisfy Maxwell’s equations. They do satisfy the second and third equations—the so-called homogeneous equations that have no charges or currents in them.

Homogeneous equations

However, because terms containing one over r squared have been dropped from the solutions, ℰdipole and ℬdipole only satisfy the other Maxwell equations if terms proportional to one over r squared are ignored.

Terms containing 1/r^2 have been dropped from the solutions

These approximate solutions are useful because they model the electric field far from a radiating source, for example a radio transmitter. Since r is assumed to be large, the terms proportional to one over r squared are negligible compared with the terms that are kept. Again, we use the intensity to visualize the field. In spherical coordinates, we have the intensity as

Intensity

Since the intensity does not depend on azimuthal angle φ, it does not matter which direction in the xy plane we consider. We therefore convert to Cartesian coordinates and restrict to the xz plane (y==0).

Convert to Cartesian coordinates

We can now make a density plot in the xz plane. Bright color corresponds to high intensity and dark color to low intensity. You can see that as the distance from the source increases, the intensity falls off. Moreover, as time increases, new crests of high intensity travel outward from the center and slowly decrease in intensity.

A density plot in the xz plane.

The solutions discussed above are some of the simplest known solutions of Maxwell’s equations. There is no completely general solution in terms of known functions, so a variety of different techniques for solving the equations in different applications have been developed. In the case of time-independent fields, it is common to use potential functions. For example, we can write ℰ = -∇V (which is always possible in this case, since ∇xℰ == 0 by the third Maxwell equation), and then focus on the first equation to get

Poisson Equation

This is Poisson’s equation, or, for ρ == 0, Laplace’s equation. In cylindrical coordinates, it takes the form

In cylindrical coordinates

In the case of cylindrical symmetry, when V and ρ depend only on r, DSolve can return an answer for any density function.

DSolve

For time-dependent situations, it is common to use Green’s functions, which are essentially solutions for a point particle in a form that can be integrated to give the solution for an arbitrary charge distribution. For more complicated situations, it may be necessary to use numerical methods as embodied by NDSolve. But whether exploring Maxwell’s equations symbolically, numerically, or visually, Mathematica has the tools for the job.

Download this post as a Computable Document Format (CDF) file.

Posted in: Mathematics
Leave a Comment

9 Comments


Carlo

If you’re a fan of Maxwell’s Equations, you can’t miss this great song about Ampère’s law

http://www.haverford.edu/physics/songs/ampere.htm

Posted by Carlo    September 20, 2013 at 4:38 am
Barrie Stokes

Hi Itai

I too think Maxwell’s equations are wonderful in many ways. In my Honours thesis I started with them in vector form, and rewrote them in tensor notation as a preliminary to looking at gravitational waves – I liked tensor calculus. I though that somewhere I once read that Einstein claimed that in solving a mathematics problem, a good notation is half the battle. That was tensor calculus for him, and the best way to express GR. Thanks for a great post.

Posted by Barrie Stokes    September 25, 2013 at 12:56 am
SteveofCaley

Sorry to be a bit of a stickler, but I really prefer that we refer to those four equations as Heaviside’s reformulation of Maxwell’s equations. I understand that Maxwell’s original equations numbered quite a bit more than four, and Oliver Heaviside used the div and curl operators (an innovation of his) to trim them down to something that fits on a tee-shirt. He was a sharp gent, and often overlooked. I’d like to mention him here.

Posted by SteveofCaley    October 30, 2013 at 5:43 am
    Itai Seggev

    I’m all for giving Heaviside his props. Among his many contributions is also the epynomous Heaviside step function. And you are of course correct that Maxwell never wrote his equations using vector notation; that was one of Heaviside’s advances. But I think it is perfectly acceptable to call these Maxwell’s equations, just as we often times call the tensor and differential form versions of these equations “Maxwell’s equations”. The mathematical and physical content is largely the same, even if the machinery has changed.

    Posted by Itai Seggev    October 31, 2013 at 1:57 pm
Saf

Hi Itai,
Thanks for sharing. I stumbled upon your blog a couple of days ago. I have a question regarding the wave equation you mentioned. This equation is listed in many books with (1/c^2) , which is missing in the equation you worked with, yet the results are all correct. The answer may be trivial, but it would be kind of you if you explain it to me.

Regards
Saf

Posted by Saf    March 19, 2014 at 9:18 am
    Itai Seggev

    Hi Saf. I’m glad you enjoyed it. The answer to your question is hidden in the sentence right above the equations, where it says they are in “natural, Lorentz-Heaviside units”. The word natural means I have used units in which the fundamental constant of the equations, in the case the speed of light c, is equal to one and is therefore omitted. Incidentally, the Lorentz-Heaviside part means that Gauss’s law takes the form div E = rho, rather than either either div E = rho / epsilon_0 (SI units) or div E = 4 Pi rho (CGS units).

    Posted by Itai Seggev    April 8, 2014 at 1:02 am
      saf

      Thanks for the answer.

      Posted by saf    June 25, 2014 at 2:25 am
Vladimir

Dear Itai:
I need your advice and help. I have some science idea which must be checked by numerical solution of Maxwell equations. I mean electromagnetic waves, laser beam which is very like to the picture (animation) presented in this your site.
a) I am interested in vector solutions (more simple problem state should be discussed).
b) It would be desirable to have 3D solution (more simple variant should be discussed)
c) Beam propagates in vacuum but meets some simple (in form) absorbed obstacle. It can be presented as boundary conditions (zero field on the obstacle surface).
d) This problem must be solved only by wave approach (Maxwell, wave equation…) but not by ray optics.
I am ready to buy the available program or pay for solving such problem.

Posted by Vladimir    October 4, 2014 at 2:31 pm


Leave a comment

Loading...

Or continue as a guest (your comment will be held for moderation):