# Three-Dimensional, Time-Dependent Analysis of High- and Low-\(Q\) Free-Electron Laser Oscillators
## 2 Numerical Formulation
### Analytical Models for Static Magnetic Fields  
The various types of undulators are modeled using three-dimensional analytical representations. Two models are available for the planar undulator, representing a flat-pole face and a parabolic-pole face with weak two-plane focusing, respectively. The flat-pole-face undulator with the magnetic field oscillating in the \(y\)-plane is described by  
\[\mathbf{B}_{u}(\mathbf{x})=B_{u}(z)\bigg{[}\bigg{(}\sin(k_{u}z)-\frac{\cos(k_ {u}z)}{k_{u}B_{u}(z)}\frac{dB_{u}}{dz}\bigg{)}\mathbf{\hat{e}}_{y}\cosh(k_{u}y )+\mathbf{\hat{e}}_{z}\sinh(k_{u}y)\cos(k_{u}z)\bigg{]}, \tag{17}\]  
where \(B_{u}\) is the amplitude of the undulator field, \(k_{u}=2\pi/\lambda_{u}\), \(\lambda_{u}\) is the undulator period and \(B_{u}(z)\) describes the entrance and exits taper at the ends of an undulator segment. The field described in Equation (17) is both curl- and divergence-free when the amplitude is constant. The analytic entrance and exit taper function \(B_{u}(z)\) is given by  
\[B_{u}(z)= \begin{cases}\quad B_{u0}\sin^{2}\left(\frac{k_{u}z}{4N_{tr}}\right) \quad\quad 0\leq z\leq N_{tr}\lambda_{u}\\ \quad B_{u0}\quad\quad\quad N_{tr}\lambda_{u}\leq z\leq L_{tr}\,,\\ B_{u0}\cos^{2}\left(\frac{k_{u}(L_{tr}-z)}{4N_{tr}}\right)\quad\quad L_{tr} \leq z\leq L_{u}\end{cases}  \tag{18}\]  
where \(B_{u0}\) is the undulator amplitude in the homogeneous part of the undulator, \(L_{\varpi}\) is the length of the undulator segment, \(N_{tr}\) is the number of undulator periods in the transition region and \(L_{tr}=L_{\varpi}-N_{tr}\lambda_{u}\) is the location of the start of the exit taper. The field in the taper regions has zero divergence, and the \(z\)-component of the curl also vanishes. The transverse components of the curl do not vanish, but are of the order of \(1/(k_{u}B_{u}(z))dB_{u}/dz\), which is usually small. A parabolic-pole-face undulator with the magnetic field orientation in the \(y\)-plane and weak focusing in the \(x\)- and \(y\)-planes is described by the analytical model  
\[\mathbf{B}_{u}(\mathbf{x})=B_{u}(z)\bigg{[}\bigg{(}\cos(k_{u}z)-\frac{\sin(k_ {u}z)}{k_{u}B_{u}(z)}\frac{dB_{u}}{dz}\bigg{)}\hat{\mathbf{e}}_{\perp}(x,y)- \sqrt{2}\hat{\mathbf{e}}_{z}\cosh\left(\frac{k_{u}x}{\sqrt{2}}\right)\sinh \left(\frac{k_{u}y}{\sqrt{2}}\right)\sin(k_{u}z)\bigg{]}, \tag{19}\]  
where  
\[\hat{\mathbf{e}}_{\perp}(x,y)=\hat{\mathbf{e}}_{x}\sinh\left(\frac{k_{u}x}{ \sqrt{2}}\right)\sinh\left(\frac{k_{u}y}{\sqrt{2}}\right)+\hat{\mathbf{e}}_{ y}\cosh\left(\frac{k_{u}x}{\sqrt{2}}\right)\cosh\left(\frac{k_{u}y}{\sqrt{2}}\right) \tag{20}\]  
and the taper function \(B_{u}(z)\) is again given by Equation (18). As in the case of the flat-pole-face model, Equation (19) is divergence free and the \(z\)-component of the curl also vanishes. Both, the flat-pole-face and parabolic-pole-face ideally produce linearly polarized light. Circular polarized light is produced by helical undulators that are described by  
\[ \begin{split}\mathbf{B}_{u}(\mathbf{x})=& 2B_{u}(z)\bigg{[}\bigg{(}\cos(\chi)-\frac{\sin(\chi)}{k_{u}B _{u}(z)}\frac{dB_{u}}{dz}\bigg{)}I_{1}^{\prime}(k_{u}r)\hat{\mathbf{e}}_{r}- \\ &\bigg{(}\sin(\chi)-\frac{\cos(\chi)}{k_{u}B_{u}(z)}\frac{dB_{u}}{ dz}\bigg{)}\frac{I_{1}(k_{u}r)}{k_{u}r}\hat{\mathbf{e}}_{\theta}+I_{1}(k_{u}r) \sin(\chi)\hat{\mathbf{e}}_{z}\bigg{]}\end{split}  \tag{21}\]  
in cylindrical coordinates \(r,\theta,z\), where \(\chi=k_{u}z-\theta\), \(I_{1}\) is the regular Bessel function of the first kind, the prime (\({}^{\prime}\)) indicates the derivative of the function with respect to its argument and \(B_{u}(z)\) is again given by Equation (18). Finally, a magnetic field with varying degrees of ellipticity is produced by an APPLE-II undulator, which can be approximated by a superposition of two flat-pole-face undulators that are oriented perpendicularly to each other, and one of which can be displaced with respect to the other along the axis of symmetry. As such, the field is represented by  
\[