# If photons mediate EM force? How can they tell to be attracting? [duplicate]

Like a photon is neutral, when a proton say feels a push from another proton, how does the proton know it was a proton pushing it and not an electron pulling it?

Im not asking how the details work of the force, just how the maths explains the different "type" of photons needed for attraction/repulsion

The concept of "mediation" depending on a photon comes from the use of Feynman diagrams. Feynman diagrams are the calculational tool of quantum electrodynamics because they give a prescription of how to calculate the integrals in each order of the pertubation series expansion for proton proton or proton electron scattering.

Lets make it simple, because the proton is a composite particle, and take the elementary electron and positron.

Electron positron scattering in first order feynman diagrams :

is given by two diagrams . These represent two integrals. The intermediate photon is virtual, i.e. it is under an integral and the value of its mass is off shell, i.e. not zero. It is a mnemonic symbol that carries the quantum numbers of the exchanged name , but not its mass.

For electron electron scattering only the gamma exchange is allowed by the quantum numbers, thus even qualitatively, it is seen that the results between like charges and unlike will be different, even in first order diagrams.

Higher order diagrams have to be summed up in order to get the functional dependence classically seen as attraction and repulsion. To see an example of the complexity of higher order diagrams please visit this link..

First, you have to realize this is the perturbation theory picture: all the "particles" are plane waves. Also, these are virtual particles (they are not eigensolutions of the free space wave equation and are transient, they only exist conditionally on the creation and annihilation event/vertex). Basically, you are developing the $1/r$ potential of a charged particle into a fourier series.

Now to the point. If you represent an EM wave as a particle (a photon), it's still true that it carries electric and magnetic field. In the perturbation theory, it's encoded in a vertex factor, where it's multiplied by a charge. But that's not the whole story. What you need to compute is a scattering probability for each outcome. For that to work, you must add together contributions of virtual photons of all possible wavelengths and directions (the propagator). This is where the true outcome becomes known: the probability of the outcome where two protons repel each other is larger than other outcomes due to a collective contribution of all possible mediating photons.

In summary, it's really misleading to consider an effect of a single mediating photon, because it's a perturbative construct (and so, only a partial contribution to what really happens).