Lagrangian and Hamiltonian of a two charged particle system in a electromagnetic field I am doing a tiny model of two charged particles in a electromagnetic field. The problem I get is how to write the Lagrangian and the Hamiltonian of the system only treating with electromagnetic potentials and ignoring other forces.
The problem comes about the term of the potential energy between the particle 1 and 2, if I write the potential expressions for each particle, both have that term, but at the time I want the potential energy of the complete system I don't know if I have to take twice this potential energy (the potential energy between particle 1 and 2) or just take that potential energy.
I think that I don't have to take twice this potential, but I don't really know how to prove that.
And finally, can I use the results of this 2 particle system to generalize a $n$-particle system?
 A: Let's consider $n$ particles with for the $i$-the particle: mass $m_i$, position $x_i$ (a 3-vector), charge $q_i$. The dynamics in the non-relativistic case can be derived from the following Lagrangian.
$$L = \sum_{i=1}^n\frac{1}{2}m_i\dot{x}_i^2 - \sum_{i=1}^{n-1}\sum_{j=i+1}^n \frac{1}{4\pi}\frac{q_iq_j}{\|x_i - x_j\|}$$
You can then get the Hamiltonian easily from the Lagrangian. Moreover, potential means interaction between two particles and has been defined in that way. So, you don't have to count it twice.
It should be noted that the effect of the magnetic field generated by one moving particle on another particle is proportional to $\frac{\dot{x}}{c}$ and it is therefore neglected in the non-relativistic limit I have adopted here. C.f. chapter 8 of [1] for example.
What about a completely relativistic treatment? In this case, we would need to write a Lagrangian for the both of the particles and the electromagnetic fields. Indeed, the accelerated charges will radiate electromagnetic waves, and loose energy in the process, so there is no Lagrangian formalism solely for the particles. But we can write the equations of motions. First, the momentum of the $i$-th particle is
$$p_i = \frac{m_i\dot{x}_i}{\sqrt{1-\dot{x}^2}}$$
Then
$$\dot{p}_i = \sum_{j \ne i} q_i\left(E_j(x_i) + B_j(x_i)\times\dot{x}_i\right)$$
where $E_j(x_i)$ and $B_j(x_i)$ are the electric and magnetic fields created by the $j$-th particle at position $x_i$. Expressions for those fields, based on the so-called Lienard-Wiechert potentials, can be found in [1], eq. (63.8) and (63.9). I am totally ignoring the issue of the Abrahams-Lorentz-Dirac force here, as there is no meaningful treatment of it anyway.
[1] Landau & Lifshitz, The classical theory of fields
