Assumptions in calculating potential energy of a system In calculating the gravitational potential energy of a system of two masses $m, M$, it is often assumed that $M\gg m$ in order to neglect motion of the larger mass $M$. As a result, the potential energy can be calculated to be 
$$U(r)=-W_g=-\int_{\infty}^{r}-\frac{GMm}{r^2}=-\frac{GMm}{r},$$
where we set $U(\infty)=0$.
In the case that $M$ and $m$ are of similar masses, as mass $m$ is brought from infinity to a distance $r$ (from a fixed origin, say the initial location of mass $M$), the gravitational force from $m$ on $M$ causes $M$ to move from its initial location, altering the gravitational force, causing the above derivation to be invalid. (The gravitational force from $M$ on $m$ is no longer simply $F(r)=-GMm/r$.) How do we find the potential energy of this system? Why can we take the larger mass to be fixed? Would we just consider the change in the position vector from $M$ to $m$? 
Similarly, how would one compute the potential energy of a system of two (or more) charges, when moving a charge in from infinity alters the configuration that has been constructed? Would we have to "hold" the previous charges in place?
It seems like my understanding of the definition of potential energy is flawed. Can someone explain the definition which involves doing work to put together a system?
 A: What matters in the calculation is the initial and final positions. If the masses move about while they are being put into place, this does not matter. It makes no difference whether $m$ moves towards $M$, or the other way round, or both move toward each other. The PE only depends on their initial and final separations.
Also, because gravity and electrostatic forces are conservative, it does not matter in what order you put the masses into position, or what route you take to get them there. You can choose whatever order and route are easiest for your calculation.
When there are more than 2 masses or charges, you can make use of the Superposition Principle : the potential energy of the system is the sum of the potential energies of each pair of objects considered in isolation.
Start with any one object (1). Then calculate the potential energy between it and each of the other objects (2, 3, 4, ...), getting $W_{21}, W_{31}, W_{41}, ...$. Then do the same for object 2, ignoring object 1, and getting $W_{32}, W_{42}, W_{52},...$ for the potential energies of each pair. Each time you ignore the objects numbered lower, so that you don't count any pair of objects more than once.
Finally add all the energies together to get the potential energy of the whole configuration of masses or charges :
$$W=W_{21}+W_{31}+W_{41}+... W_{32}+W_{42}+W_{52}+...W_{43}+W_{53}+W_{63}+...$$
For a system of $n$ objects there are $\frac12n(n-1)$ distinct pairs of objects, so there are this many terms to add together.
A: I think you are confused.
The potential will still be $-\frac{GMm}{r}$, but that changes when $M$ and $m$ are comparable in size in that the reduced (i.e., effective) mass $\mu=Mm/(M+m)$ will no longer be $\mu\approx m$, but would be as small as $\mu=m/2$. This will affect the time evolution of the gravitational system.
The same reasoning applies to a system of two electric charges (if we ignore dissipation through radiation).
A: Fixing a particle in place means applying a counter-force on it, but at the same time no work will be done by this counter-force (work = force x distance, so if distance is 0 than work is 0), hence no change in energy (work is equivalent to change in energy).
The only change in the system's energy will be caused by the external force that brings the 2nd particle closer to the first one. The system started with 0 energy, so the final energy (which is also the system's PE) must be equivalent to the work done in order to bring the second particle towards the first one.
you can look at the fixing as a constraint on the first particle, which "disables" its ability to transfer potential energy to kinetic energy (and it is ok to use it because it does not change the system's energy).
