The electromagnetic field is fully described by a vector field called the 4-potential . It has four components that we can label any way we want, the traditional way is to use:

where is called the electrostatic scalar potential, is called the vector potential and is the speed of light. The Lagrangian density for the free (noninteracting) field is:

The interaction between the charged particle (or in general any charged body) with some charge density and the electromagnetic field is given by the Lagrangian density:

There are several approaches how to obtain the above Lagrangians from some other assumptions, but ultimately the exact form of the Lagrangians has to be given by experiment. It is our only assumption and we derive everything else from it. All together, the Lagrangian of a charged particle and an electromagnetic field is:

The Euler-Lagrange equations for the electromagnetic field (in terms of and ) are:

The only way to measure the electric field is through its interaction with the charge particle. As such, the actual physical field (that can be measured) is , which is invariant under any gauge transformation:

So for any 4-potential we can find such that the transformed 4-potential obeys the Lorenz gauge condition .

In order to obtain a gauge invariant Lagrangian, we need to express it using using the following identity:

Which in Lorenz gauge simplifies to equation (2). In order to write equations of motion in terms of only, we need another equation for it:

We used the fact, that the partial derivatives are symmetric in the indices and while is antisymmetric.

The field strength tensor is antisymmetric, so it has 6 independent components (we use metric tensor with signature -2):

There is freedom in how we label the components. The standard way is to express them using physical fields and that are introduced by:

Using coordinate time and coordinates instead of the proper time and 4-vector , we need to rewrite the action:

where is the Lagrangian expressed in coordinates and (and thus is not Lorentz invariant):

For continuous case (current), the force due to the magnetic field is:

The system of equations was solved for using the code (in there , and ):

This tensor is not symmetric under the exchange of the indices. To make it symmetric, we add a total derivative term , where is antisymmetric in its first two indices. This guarantees that so that the new stress energy tensor is still conserved. We choose and get:

Another way to derive the stress energy tensor is from general relativity using the formula:

Assuming the vector potential is time independent, we get for the electric field:

If the charge distribution can be approximated by an infinitely-narrow wire with linear charge density , we get:

In order to calculate with , we need to regularize it first. Cutoff regularization is:

Here is the regulator and is the auxiliary scale. This regularization preserves the translational symmetry. Now we can renormalize the integral. The minimal subtraction (MS) renormalization is:

Once we choose a renormalization scheme, we can calculate the electric field as follows:

If the current can be approximated by an infinitely-narrow wire, we get:

In the last equation we used the fact, that is odd and is even on the interval . For we get:

For and turns we get the magnitude of the field as (we use SI units, so is in and in tesla):

So the electron is moving in a circle with a center , depends on the initial direction of the velocity and is the magnitude of the initial velocity. There can also be a possible movement in the direction, but for the following initial conditions there is none:

So the radius of the circle is . Let the electrons by accelerated by the electric potential :

The force on a wire 1 due to a magnetic field of a wire 2 is:

Where is the magnetic field produced by the wire 2. Combining these two equations we get:

As such, the direction of the force on the first wire (at coordinates going in the direction) will be to the left and the force per unit length is:

Because the second wire is at the coordinates and the force on the first wire is in the direction , the force between the wires is attractive, as long as and have the same sign (either both currents go up, or both down) and repulsive if and have opposite signs.

The integral is an odd functin of , so it is zero.