Cartoon of action of an RF cavity on an electron  

This animation is a cartoon of the action of an RF cavity on an electron, if the latter enters the cavity at the appropriate time in the RF cycle. The electron is accelerated by the E-field, which points in the opposite direction to the acceleration, on account of the electron’s negative charge. The cartoon is simplistic in many ways, not least the shape of the cavity, which is never a pillbox; plus the fact that the cartoon shows a clear increase in velocity of the electron. At the extremely relativistic velocities relevant here, the vast majority of the energy imparted by the cavity to the electron is invested in increasing the electron’s mass

Note that in addition to the main matlab code, there is the function mArrow3.m used to generate fancy 3D arrows, which I downloaded from MathWorks File Exchange, and for which I credit Georg Stillfried. I use this function in several of the matlab codes available here.