Motion of Electrons in Planar Ideal Undulator

This chapter describes the motion of relativistic electrons in three-dimensional ideal undulator magnetic field. The undulator magnetic field satisfies the stationary Maxwell equations. Usually, the differential equations of electron motion in three-dimensional sinusoidal magnetic field are analysed by averaging over the fast electron oscillations. This averaging method was applied in a number of previously published papers. In this study, the nonlinear differential equations for electron motion were solved analytically by using the perturbation theory. The analytic expressions for trajectories obtained by this method describe the electron trajectories more accurately as compared with the formulas, which were obtained within the framework of the averaging method. An analysis of these expressions shows that the behaviour of electrons in such a three-dimensional field of the undulator is much more complicated than it follows from the equations obtained by the averaging method. In particular, it turns out that the electron trajectories in a planar undulator are cross-dependent. A comparison of the trajectories, calculated using these new analytical expressions with the numerically calculated trajectories using the RungeKutta method, demonstrated their high accuracy.


Introduction
Here, a theoretical analysis of electron motion in a planar undulator (or wiggler) with ideal three-dimensional magnetic field is carried out. In this case, the magnetic field on the undulator axis (Z-axis, see Figure 1) is directed strictly vertically upwards (Y-axis) and has a perfect sinusoidal dependence on the longitudinal coordinate Z. However, similarly as in the case of real planar undulators, the ideal magnetic field considered here is supposed to be nonuniform in the transverse plane, that is, in the XOY plane. In the case of standard geometry undulator (an undulator with a plane surface of poles), as shown in Figure 1, the amplitude of undulator magnetic field increases in the vertical direction on approaching its poles. As you move away from the axis in the undulator median plane in the horizontal direction (i.e. along X-axis), the amplitude of the vertical magnetic field decreases as you approach to the magnetic pole boundaries. The fact that the undulator magnetic field satisfies the stationary Maxwell equations imposes additional requirements on the functional dependence of the magnetic field components on the spatial coordinates. This also leads to the appearance of weak horizontal (along the X-axis) and longitudinal (along the Z-axis) components of the magnetic field in the region of the planar undulator median plane. Both these factors, that is, the presence of horizontal components of the magnetic field and the inhomogeneity of the field in the transverse plane produce the undulator focusing properties. This means that if two electrons enter the undulator magnetic field in parallel to each other though spaced apart from each other, then at the end of the undulator they will already have non-parallel velocities. This is because each of the electrons moves in its own, individual undulator magnetic field. A relativistic electron beam, in its passing through a planar undulator magnetic field, is focused in the vertical direction and is defocused in the horizontal direction, since the amplitude of the undulator field increases with distance from its axis in the vertical direction and, vice versa, decreases with distance from the axis of the undulator in the horizontal direction. These focusing and defocusing properties of the undulator magnetic field have a strong influence on the electron beam dynamics in the electron storage rings, since the undulator in this respect manifests itself as an additional quadrupole lens. This leads to a shift of radial and vertical betatron oscillation frequencies of electron beam in the electron storage ring and, respectively, to the displacement of its working point. It can dramatically decrease the electron beam lifetime, since the displaced working point may fall into the resonance region. Thus, accurate consideration of the undulator focusing properties is of great importance for understanding the electron beam dynamics in the electron storage rings.
As far as we know, the focusing properties of the planar undulator magnetic field were first theoretically predicted in [1], where the effects of the superconducting wiggler influence on the storage ring electron beam dynamics were analysed. The horizontal and vertical focal lengths were also calculated. It has been shown that these focusing properties have a detectable effect on the electron beam dynamics. For example, they shift vertical and horizontal betatron oscillation frequencies of the electron beam. Assuming a planar undulator with infinitely wide poles, its magnetic field is uniform along the horizontal X-axis ( Figure 1). It is evident that there is no horizontal focusing in this case, and such undulator focuses the electron beam vertically only. The motion of electrons in a planar undulator with plane infinitely wide poles was analysed in papers [2,3]. A clear physical explanation for vertical focusing effect in a twodimensional magnetic field of such undulator was also given in [2]. As a consequence of Maxwell equations, the undulator magnetic field outside its median plane also has a longitudinal component, directed along the undulator Z-axis. This longitudinal component has an alternating (sinusoidal) character, that is, it is either aligned with the Z-axis or opposing the undulator axis. The phase of this component is determined by the phase of the leading (vertical) undulator magnetic field. Likewise, this leading vertical field causes the electron to oscillate in the horizontal plane, resulting in the horizontal (along the X-axis) sinusoidal component of the electron velocity. The phase of this horizontal component of the electron velocity is also determined by the phase of the undulator leading field. The action of this longitudinal sinusoidal component of the undulator magnetic field on an electron, which proceeds along the horizontally oscillating trajectory, leads to the relatively small vertically directed Lorentz force. The mutual correlation of the longitudinal component of the undulator magnetic field (directed along the undulator axis) and the horizontal component of the electron velocity (directed along the X-axis) are such that the Lorentz force is always directed towards the median plane of the undulator, thus creating vertical focusing force [2]. Some general relationships between the vertical and horizontal focal lengths of the undulator were derived in papers [4][5][6][7][8]. The general expressions for calculating horizontal and vertical focal lengths are also derived in the case of an undulator with flat finite-width poles, which are alternately shifted in the horizontal direction (along X-axis) relative to each other (undulators with the poles offset) [4,5]. In the standard case of the undulator with zerooffset geometry, these formulas transform into the corresponding expressions given in paper [1]. Electron long-wave anharmonic betatron oscillations in very long undulator magnetic fields were considered in [9]. The action of the focusing properties of undulators on the operation of free-electron lasers was studied in [10][11][12]. In addition, a configuration of an undulator with a parabolic shape of the magnetic-pole surface was also proposed in [10]. Such geometry of a magnetic-pole surface leads to a rise in amplitude of the undulator magnetic field as the distance from the undulator axis in the median plane increased. As a result, both horizontal focal length and vertical focal length became positive. Therefore, this undulator focuses the electron beam in both directions, which is important for the freeelectron lasers operation. The papers [13,14] considered the influence of the inhomogeneities in the transverse plane of the electromagnetic wave and helical magnetic field of spiral undulator on the generation of X-ray radiation in free-electron lasers. The following mathematical method was used in all above-mentioned papers. The focal lengths of the undulator were calculated in the framework of a smoothed (focusing) approximation. The averaging procedure of the electron trajectory in the undulator sinusoidal magnetic field over the oscillation period plays an important role in such kind of calculation. The following section describes this approximation in more detail. It is generally accepted that this procedure of oscillation averaging is correct and corresponds to the physics of the process. If the influence of the undulator magnetic field on the electron beam dynamics is reduced in the undulator focusing properties, then it necessarily implies averaging over oscillations of the sinusoidaltype electron trajectory in the sign-changing undulator magnetic field. Paper [15] was one of the first papers that described this approach that was applied for the analysis of influence of nonuniformities of the undulators and wigglers magnetic fields on the electron beam dynamic. In succeeding years, it was extensively used in studies involving the influence of wigglers and undulators on the electron beam dynamic in electron storage rings [16][17][18][19][20].
The wavelength λ of the fundamental (first) harmonic along the undulator axis is λ ¼ λu Here, λ u is an undulator period, γ is the electron-reduced energy, and K is the undulator deflection parameter. In a free-electron laser, the value of the dimensionless Pierce parameter ρ determines the width of the spectral line of the coherent electromagnetic radiation. This means that the width of the spectral line Δλ of the fundamental harmonic must be known with accuracy determined by the condition Δλ=λ ≤ ρ. In the case of the European XFEL facility (Hamburg), we have γ ffi 35; 000, K ffi 4, and the value of the Pierce parameter is equal to 3•10 À4 for a radiation wavelength of 0.1 nm [21]. Some variations in magnetic field strength are manifested in correspondent changes of effective undulator deflection parameter K Variation of wavelength λ of the undulator radiation fundamental harmonic due to variation of the undulator deflection parameter is approximately equal to Δλ=λ ffi 2ΔK=K. Therefore, the absolute accuracy, with which the undulator deflection parameter K should be calculated, must satisfy the following condition: ΔK < 0:5Kρ. It follows from the general formula for the phase of spontaneous radiation that the deflection parameter K of planar undulator with periodic magnetic field is determined by the following relation: is the horizontal component of the reduced electron velocity, which has a sinusoidal form with the amplitude approximately equal to K=γ. Therefore, calculations of the transverse component of the electron velocity must be carried out with very high accuracy, which is determined by the relation Δβ x ¼ ΔK=γ < Kρ À Á = 2γ ð Þ≈ 2 Á 10 À0 . The relative accuracy in this case is of the order of 2•10 À4 . These requirements for the simulation accuracy show that the abovementioned focusing approximation, based on the method of averaging fast oscillations of the electron trajectory, in some cases may not have the sufficient accuracy. It is clear that for free-electron laser, we need to develop a more precise method for calculations of the electron trajectories in planar undulator three-dimensional magnetic fields.
In a number of recent papers [22][23][24], electron trajectories in perfect sinusoidal threedimensional magnetic field of a planar undulator were numerically simulated. The Runge-Kutta algorithm was employed for solving the set of differential equations for electron motion in the undulator field. It is correct to suppose that these numerically simulated trajectories are highly accurate results. The checking of these numerically simulated trajectories was made against analytically calculated trajectories, obtained by using the oscillation-averaging method (focusing approximation) [10][11][12]. This comparison has been demonstrated in a conclusive way that in most cases the numerically simulated trajectories differ significantly from those calculated by using the analytical formulas derived in focusing approximation. Therefore, more precise analytical formulas for electron trajectories in an ideal sinusoidal three-dimensional magnetic field of a planar undulator are critically important to properly understand electron beam dynamics.
Here, we derive new analytical expressions for trajectories of relativistic electrons in the ideal three-dimensional magnetic field of a planar undulator (or a wiggler). It means that the undulator magnetic field has only the vertical component at the undulator axis with pure sinusoidal form. However, outside the undulator axis, there are the horizontal and longitudinal components of the magnetic field. All three components of the magnetic field are related to each other functionally since the undulator magnetic field must satisfy the stationary Maxwell equations. The differential equations of motion for electrons in such a magnetic field were solved by using the perturbation theory, which is widely used in quantum mechanics rather than the focusing approximation which employs the averaging over transverse oscillations of the electron trajectory. The idea of this method for trajectory calculating was suggested in paper [25] for the first time. The formulas derived in this manner are very complicated since they include all terms of the cubic power of small quantities. However, these formulas give a higher approximation to electron trajectories in the undulator field than those derived in the smoothed (focusing) approximation [10][11][12]. Analysis of these highly accurate expressions shows that electron motion in undulator magnetic field is very sophisticated and cannot be reduced to the standard focusing effects. In particular, the electron motion in the vertical and horizontal directions is interrelated. This means that the change in the initial conditions of electrons in the vertical plane results in the correspondent changes of the horizontal component of the electron trajectory and vice versa. It is reasonable because the Maxwell equations for the stationary magnetic field interrelate all three components of the undulator field. However, this effect cannot be described within the framework of the smoothed (focusing) approximations.
Using the Runge-Kutta algorithm, a computer code was used to numerically solve differential equations for motion of an electron in the three-dimensional planar undulator magnetic field. Comparison of the numerically calculated trajectories with those derived from the analytical accurate formulas demonstrates a very high accuracy of these analytical expressions. However, it is clear that, in practical use, the analytical expressions are often vastly superior to numerical simulations., A step-by-step calculation with a small interval along all trajectories is required for purposes of the electron trajectory numerical simulations. This procedure takes a good deal of time. In the event that we know the highly accurate analytical expressions for describing electron trajectories in the planar undulator, we can calculate the final coordinates and velocity of the electron easily by simply substituting the final value of the magnetic field longitudinal coordinate into the analytical expressions. This greatly reduces the computation time.

Equations of electron motion in ideal planar undulator
Let B ! x; y; z ð Þbe a planar undulator or wiggler magnetic field produced by its magnetic system. The equation of electron motion in this field has the form: where e, m, β ! and γ are the electron charge, mass, reduced velocity and reduced energy, g are the electron trajectories. Let us recall that the electron energy and velocity modulus are constant in the magnetic field: The time t is an independent variable in equations of motion (1). At the same time, the undulator magnetic field in Eq. (1) is a function of the transversal spatial coordinates x, y and longitudinal coordinate z. Consequently, it is more convenient to use the new independent variable z (the longitudinal coordinate) instead of the independent variable t (time). With the equations of motion (1), it is possible to derive the following exact equations for the electron trajectory in an external magnetic field [26,27]: We point out that the Eqs. Here, the undulator with planar magnetic system and ideal three-dimensional sinusoidal magnetic field is considered; see Figure 1: where B 0 is the magnetic field amplitude on the undulator axis (Z-axis), λ u is the undulator The parameter a determines the magnetic field nonuniformity along the horizontal X-axis. It is of the order of the undulator pole width. In the case of undulator with infinitely wide poles, the parameter a ¼ ∞ and k x ¼ 0. It is easy to verify that the magnetic field, which is described by Eqs. (4)-(6), satisfies the Maxwell equations for a stationary magnetic field.
The system of precise Eqs. (2), (3) for the electron motion appears as cumbersome formulas. Nevertheless, it offers several advantages in analytical analysis and numerical simulations over the standard equations of motion (1). First, the undulator magnetic field is described by using the functions of the longitudinal coordinate z. Consequently, in this case, the functions sin k z z ð Þ and cos k z z ð Þ in Eqs. (4)-(6) are known exactly. When employing the standard equations of motion (1), the value of the electron's longitudinal coordinate z t ð Þ at every step is calculated with some finite precision and the resultant errors are accumulated. It is also significant that the system of Eqs. (1) includes three equations, while the system of Eqs. (2), (3) consists of two equations only. This also simplifies its analysis and yields a large dividend in accuracy.
The region occupied by the electron beam, that is, the small vicinity near the undulator axis, has relatively small transversal coordinates: k x x j j≪ 1, k y y ≪ 1. Expanding Eqs. (4)-(6) in terms of these small quantities, we have the following expressions: It is clear that on the undulator axis x ¼ 0 and y ¼ 0 only when vertical component of the magnetic field is nonzero: In this regard, the field is ideal because the magnetic field of the real undulator inevitably includes errors caused by manufacturing errors of the undulator magnetic system. There are also higher harmonics in the magnetic field generated by the real magnetic system. Their relative amplitudes depend on specific details of the undulator design. Differential Eqs. (2), (3) are nonlinear and cannot be solved exactly. However, the functions x 0 , y 0 , k x x and k y y in Eqs. (2), (3) are small in absolute value. Therefore, we can expand the nonlinear differential Eqs. (2), (3) in terms of these small quantities. Substituting the expressions (4-6) for the undulator magnetic field, as a result we have: where K ¼ ÀeB0λu 2πmc 2 is the undulator deflection parameter, e < 0 for electrons, w ¼ k z z, and e K ¼ K βγ .
In the cases of our interest, the dimensionless undulator deflection parameter K is of the order of several units, that is,~1-5, and the reduced electron energy γ is of the order of several thousands. So, γ ffi 5000 for the electron beam of the Sibiria-2 electron storage ring (Moscow) and γ ffi 35; 000 for the European XFEL facility (Hamburg). Because of this, e K is much less than unity: e K $ 10 À3 À 10 À4 .
Neglecting all small terms x 0 , y 0 , k x x and k y y in Eqs. (10), (11), we get the following equations in linear approximation: The solutions of Eqs. (12), (13) are the following: is the initial deviation of the electron velocity from its equilibrium value.
Eqs. (14), (15) correspond to rectilinear electron motion with additional sinusoidal oscillations in the horizontal plane. Obviously, Eqs. (14), (15) do not describe any focusing properties of the undulator magnetic field. They describe motion of an electron in the magnetic field with the following parameters: Clearly, these formulas describe the magnetic field at the undulator axis. To put it differently, they follow from more general Eqs. (4)-(6) if we neglect the magnetic field's nonuniformity in the transverse plane and the small magnetic field components B x and B z . This primitive magnetic field cannot be produced by real magnetic system because it does not satisfy the Maxwell equations. At the same time, it is often employed when characteristics of electromagnetic radiation from a planar undulator are analysed.

Smoothed (focusing) approximation for electron trajectories
It is reasonable to generalise the Eqs. (14), (15) as follows. We replace the terms x 0 þ θ 0 z and y 0 þ y 0 0 z in Eqs. (14), (15) by slowly varying functions of the general form x s z ð Þ and y s z ð Þ, respectively. So, we seek the electron trajectory in the following form: We substitute Eqs. (16), (17) into equations of motion (10,11) and average them over the undulator period. It makes all fast oscillating terms equal to zero. This means that odd powers of the functions sinw and cosw vanish, and the functions sin 2 w and cos 2 w are replaced by their average value 0.5. As a consequence, we obtain the following linear differential equations for the slowly varying functions x s z ð Þ and y s z ð Þ, see [10][11][12]: where ω x, y ¼ e Kk x, y = ffiffi ffi 2 p k z À Á are the dimensionless frequencies of betatron oscillations in the horizontal and vertical directions in units of the undulator period λ u , respectively. The quantities ω x, y have the same order in magnitude as the parameter e K and are also small. The quantity a is of the order of the pole width. Usually, the pole width is slightly larger than the undulator period length. Therefore, the following condition is usually true for undulators: > k x , and hence ω x < ω y . In the case of the undulator with infinitely wide poles, we have a ¼ ∞, k x ¼ 0 and ω x ¼ 0.
Since the functions x s z ð Þ and y s z ð Þ are solutions of the Eqs. (18), (19), they consist of the linear combinations of hyperbolic sines and cosines (for Eq. (18)) and trigonometric sines and cosines (for Eq. (19) correspondently). Taking Eqs. (16), (17) into account, thus we have in the smoothed (focusing) approximation the following expressions for the horizontal and vertical coordinates of the electron in the magnetic field given by expressions (4-6): It is significant that Eqs. Two linear equations for electron motion (18,19) are decoupled in the smoothed (focusing) approximation. It implies that the first Eq. (18) is dependent only on the parameters of the horizontal component of trajectory. Correspondingly, the second Eq. (19) is dependent on the vertical component parameters. In other words, these both equations of motion are completely independent of each other. Respectively, the Eqs. (20), (21) are also decoupled, that is, they are independent of each other. However, the more precise system of equations of motion (10, 11) is not decoupled. It means that each of these equations depends explicitly on the parameters of the horizontal and vertical alike components of the electron trajectory. As a result, every component of the electron trajectory, both horizontal and vertical, being the solutions of the system of equations (10,11), must also be dependent on both horizontal and vertical parameters of electron trajectory.

Trajectories in a short undulator
Magnetic fields of short planar undulators have focusing properties, that is, the influence of short undulator magnetic field on the electron beam dynamics can be described in terms of the undulator focal lengths. However, the ideal magnetic field deflects the propagating electron beam in the median plane. As a result, there is no straight electron trajectory (principal axis) in an undulator. The absence of axial symmetry leads to astigmatism, that is, the undulator horizontal and vertical focal lengths are different and even have different signs. The vertical focal length is positive, while the horizontal focal length is negative.
We consider relatively short undulators with the number of periods N so that the following condition is fulfilled: In the cases under consideration: e K ¼ K= γβ À Á $ 10 À1 À 10 À0 and standard number of undulator periods is about N $ 100. Therefore, the inequality (24) almost without exception is fulfilled. Since w ¼ 2πz=λ u ≤ 2πN, the quantity w increases linearly along the undulator length with the maximum value equal to 2πN. Quantities ω x, y have the same order as e K. It follows from inequality (24) that the conditions ω x, y w ≪ 1 are always true for any point of the electron trajectory in a short undulator. Therefore, we can expand Eqs. (20)- (23) in terms of these small quantities ω x, y w and retain terms to powers less or equal than 3. As a result, we have in terms of z: Eqs. Since we know the electron trajectories in the short undulator (which is specified by the inequality (24)), we can calculate its focal lengths. We first consider an electron moving along the equilibrium trajectory. This trajectory is defined by the following initial conditions x 0 ¼ y 0 ¼ θ 0 ¼ y 0 0 ¼ 0 and is described by the formulas: x 0 eq z ð Þ ¼ À e Kcos k z z ð Þ (30) y eq z ð Þ ¼ y 0 eq z ð Þ ¼ 0 Let us consider another electron, which enters the undulator in parallel to the first one but is shifted upward, that is, its initial conditions are x 0 ¼ θ 0 ¼ y 0 0 ¼ 0, y 0 > 0. Its trajectory is defined by the formulas: At the undulator end with the Z-coordinate z N ¼ Nλ u , the electron has the following vertical coordinate and velocity: Taking into account inequality (24) for short undulators, it is easy to see from Eq. (36) that we can neglect by the vertical shift of the electron inside the undulator: y 2 z N ð Þ ffi y 0 . It is also clear that, after exiting the undulator, two electrons with the trajectories described by Eqs. (29)-(31) and (32)-(35), respectively, intersect each other at the vertical undulator focus with the mutual angle y 2 z N ð Þ=f y ffi y 0 =f y , where f y is the vertical focal length of the undulator. On the other hand, the intersection angle is equal to Ày 0 2 z N ð Þ. As a result, with the help of Eq. (37), we get the expression for vertical focal length f y : Similarly, it is easy to derive the expression for the horizontal focal length: By applying slightly other methods, the expressions for vertical and horizontal focal lengths (38) and (39) were derived in the previous works [1,[4][5][6][7][8].
The foregoing shows that the solutions of the equations for electron motion in the ideal magnetic field of a short undulator, obtained with employing method of the averaging of trajectory of fast oscillations include the focusing properties of the magnetic field. That is why the smoothed approximation can also be called as focusing. The Eqs. (38), (39) show that the vertical focal length is positive (the electron beam is focused in vertical direction), while the horizontal focal length is negative (electron beam is defocused in horizontal direction). The focusing powers of the undulator (the quantities inverse to the focal lengths) 1=f x, y are proportional to the number of undulator periods N and to the squared undulator deflection parameter K 2 and are inversely proportional to the squared electron beam energy γ 2 .
By using Eqs. (38), (39), it is easy to derive the following general relation: The key feature of Eq. (40) is that it is independent, which determines the value of the magnetic-field decay of the magnetic field (see Eqs. (4)-6)) along the horizontal axis X. It is clear that in the case of infinitely wide magnetic poles, that is, at a ¼ ∞, the horizontal focal length also tends to infinity: f x ¼ ∞.

Electron trajectory calculation by methods of perturbation theory
It is possible to enhance considerably the accuracy of the solution to the equations of motion (20)-(23) as follows: Let us try to find the solution to Eqs. (10) and (11) in the form: We assume that the unknown functions Δx z ð Þ and Δy z ð Þ are far less than the leading terms x f z ð Þ and y f z ð Þ. We substitute Eqs. (41), (42) into Eqs. (10), (11) and ignore the functions Δx z ð Þ and Δy z ð Þ on the right-hand side of these two equations. As a result, we get two second-order differential equations, whose right-hand sides are well defined and expressed in terms of the products of trigonometric and hyperbolic functions: The functions x f , x 0 f , x 00 f , y f , y 0 f and y 00 f are well known and are expressed in elementary function by Eqs. (20), (21 xðzÞ ¼x 0 coshðω x wÞ þ ðθ 0 =ω x Þsinhðω x wÞ ÀK½1 À 0:5k 2 x ðx 0 þ θ 0 zÞ 2 þ 0:5k 2 y ðy 0 þ y 0 0 zÞ 2 Á sinw À ð0:5K=A 2 Þx 2 0 w À ð2K=A 2 Þθ 0 ðx 0 þ θ 0 wÞð1 À coswÞþ 1:5Kθ 2 0 ð1 þ 2=A 2 Þðw À sinwÞ þ ðω 2 y =KÞỹ 2 0 w þKy 0 0 ðỹ 0 þ y 0 0 wÞð1 þ 2=A 2 Þð1 À cos wÞ À0:5Kðy 0 0 Þ 2 ð1 þ 6=A 2 Þðw À sinwÞ À 0: Eqs. (45), (46) completely determine the electron trajectory in three-dimensional undulator magnetic field, which is described by the Eqs. Some terms in Eqs. (45), (46) include the factor w ¼ k z z, which linearly increases along the undulator with increasing of the longitudinal coordinate z. It has a maximum 2πN large in value at the final point of the undulator magnetic field at z N ¼ λ u N. It is clear that such terms make large contributions to the expressions for the electron trajectory. It is also easy to see from Eqs. (45), (46) that the majority of cubic terms oscillate. These terms clearly vanish with the averaging over fast oscillation procedure. However, in the case of the real electron beam, such oscillating terms can contribute to the electron trajectory and velocity since they are not less in values than that of terms responsible for the focusing properties of the undulator magnetic field. Indeed, in Eq. (25), the horizontal focusing effect is described by the term 0:25x 0 e K 2 z=a ð Þ 2 ¼ 0:25x 0 e K 2 w=A ð Þ 2 . Some terms in Eq. (45) are also proportional to w 2 . For trajectories with the initial conditions e x 0 $ e K, e y 0 $ e K, θ 0 $ e K and y 0 0 $ e K, these terms are recognised in the same order as the term 0:25e x 0 e K 2 w=A ð Þ 2 .
The parameter A ¼ k z a ¼ 2πa=λ u describes the degree of nonuniformity of undulator magnetic field along the horizontal axis, see Eqs. (4)- (6). For a planar undulator with infinitely wide poles, we have a ! ∞ and consequently A ! ∞. In this case, some terms in Eqs. (45), (46) become zero, and these formulas are simplified significantly.

Analysis of the obtained results
In the earlier sections, we have derived two sets of formulas which describe electron trajectories in the ideal field of a planar undulator. The first set, given by Eqs. (25)- (28), was derived within the framework of the well-known focusing approximation, and the second set (see Eqs. (45), (46)) was derived by means of the perturbation theory. The electron trajectories in the planar undulator magnetic field can also be simulated numerically by solving Eqs. (2), (3) together with Eqs. (7)-(9) for the three-dimensional undulator field by using the Runge-Kutta algorithm. These electron trajectories once simulated numerically with a small step (which provides high calculation accuracy) can be considered as a reference data for the analysis of the approximate analytical formula precision. In doing so, it is necessary to keep in mind that the numerical solutions of the differential equations of motion also contain some calculation errors. It was demonstrated in the papers [22][23][24] that numerically computed trajectories, on frequent occasions, differ considerably from the correspondent approximate solutions obtained through the focusing (averaging) approximation. We compare here the numerically simulated electron trajectories with those obtained by using the formulas, derived earlier by methods of perturbation theory, see Eqs. (45), (46) and also with those obtained within the framework of the focusing approximation in accordance with Eqs. (25)- (28).
As an example, we consider the electron trajectories in the undulator at the European XFEL facility (Hamburg, Germany): the reduced electron energy is equal to γ ¼ 35; 000, the undulator period length is λ u ¼ 40 mm, the number of undulator periods is N ¼ 124, the undulator deflection parameter is K ¼ 4, the parameter determining the undulator field nonuniformity along the horizontal axis X (about the pole width), and a ¼ 50 mm [28]. The focal lengths for this undulator can be easily found from Eqs. (41), (42): vertical focal length is equal to f y ¼ 1231234 mm and horizontal focal length is equal to f x ¼ -77179939 mm. The horizontal focal length is negative, and the electron beam is defocused by planar undulator along the horizontal direction.
The formulas for electron trajectories, derived in the framework of the focusing approximation (see Eqs. (20), (21), (25), (26)) and by the methods of perturbation theory (Eqs. (45), (46)), include the regular (main) parts of trajectory x 1 z ð Þ ¼ x 0 þ θ 0 z À e K=k z sinw for the horizontal component and y 1 z ð Þ ¼ y 0 þ y 0 0 z for the vertical component and plus the additional terms, describing the effects of the magnetic field inhomogeneity. Eqs. (25), (26) display it explicitly, while the Eqs. (20), (21), (45), (46) involve these regular parts implicitly, through the trigonometric and hyperbolic functions. Expanding these trigonometric and hyperbolic functions as a power Taylor series in small values ω x, y w, we can easily get the regular parts of trajectory x 1 z ð Þ and y 1 z ð Þ in explicit form. Clearly, the regular parts x 1 z ð Þ and y 1 z ð Þ do not describe any focusing properties of planar undulator magnetic field. At the same time, these parts are linear in terms of small parameters e K, x 0 , y 0 , θ 0 and y 0 0 , while the remaining terms in Eqs. (20), (21), (25), (26), (45), (46) have a cubic degree of smallness and hence are much less than the regular parts.
The regular terms, which are given by Eqs. (14) and (15), are the same for trajectories calculated in the framework of focusing approximation, see Eqs. (25)- (28), and for expressions, derived by the methods of perturbation theory, see Eqs. (45) and (46). For clarity, we consider here the differences ΔX x ð Þ and ΔY z ð Þ between the corresponding solutions and the regular terms: It is precisely these components that are responsible for the focusing properties of the undulator field.    Figure 2 (B) shows the additions ΔY z ð Þ to the vertical components of the electron trajectories y z ð Þ calculated at the listed above initial conditions. Vertical component of the electron trajectory is described by the formula y z ð Þ ¼ y 0 þ ΔY z ð Þ. Figure 2 (A) and (B) both include the addition for the electron trajectory, which was initially shifted downward in the negative direction of Y-axis, y 0 ¼ À0:1 mm (the upper curves) and for the electron trajectory, which was initially shifted upward in the positive direction of Y-axis, y 0 ¼ 0:1 mm (the lower curves correspondently). It is easy to see that in both cases the electrons in their propagations along the undulator axis deviate monotonically to the undulator median plane Y ¼ 0. Indeed, the electron initially located above the median plane (with y 0 ¼ 0:1 mm) and moving in parallel to the undulator axis (y 0 0 ¼ 0) (see Figure 2 (A, B), the lower curves) acquires the negative velocity component, whose absolute value increases linearly with the longitudinal coordinate z growths. Similarly, the electron initially located below the median electron plane (with y 0 ¼ À0:1 mm) and moving in parallel to the undulator axis (y 0 0 ¼ 0) (see Figure 2 (A, B), the upper curves) acquires the positive velocity component, whose value also increases linearly with the longitudinal coordinate z growths. The maximum value of the vertical reduced velocity component is achieved at the final point of the undulator magnetic field and is equal to ∓ 8:11648•10 À8 rad. Hence, we can calculate the vertical focal length f y ffi Ày 0 À Á = β y z ¼ λ u N ð Þ ffi 1232061 mm. This coincides with a very small relative error of about 10 À3 with the analytical value obtained earlier by using Eq. (38).
In fact, all three methods of calculation, namely focusing approximation, perturbation theory and numerical simulation, give just the same result in this case. All correspondent curves in Figure 2 are merged together. The largest absolute difference between numerically simulated function ΔY 0 z ð Þ by using the Runge-Kutta method and calculated in the focusing approximations is 6•10 À11 . In this case, the maximum value of the function ΔY 0 z ð Þ is equal to 8•10 À8 . Therefore, the relative error is about 8•10 À4 . The largest absolute difference between the numerically simulated function ΔY 0 z ð Þ and those using formula (46) is equal to 10 À11 . The relative error in this case is about 10 À4 . This is better by an order as compared with the case of focusing approximation, although it is not essential in this case. The maximum value of the function ΔY z ð Þ is equal to 2•10 À4 mm, see Figure 2 (B). The largest absolute difference between numerically simulated function ΔY z ð Þ by using the Runge-Kutta method and calculated in the focusing approximations is 2:5•10 À8 mm. The relative error in this case is about 10 À4 . Maximum absolute difference between the values of ΔY z ð Þ obtained by means of the numerical simulation and by using Eq. (46) is also equal to 2:5•10 À8 mm with the same relative error of about 10 À4 .

Figure 3 (A) and (B)
show the horizontal additions to the regular part of the reduced electron velocity ΔX 0 z ð Þ and electron trajectory ΔX z ð Þ, calculated at the mentioned earlier conditions x 0 ¼ 0 mm, θ 0 ¼ 0, y 0 ¼ AE0:1 mm and y 0 0 ¼ 0. The functions ΔX 0 z ð Þ and ΔX z ð Þ are the same for y 0 ¼ AE0:1 mm since the undulator magnetic field amplitude increases symmetrically with respect to its median plane. The focusing approximation gives zero results for this case: ΔX 0 z ð Þ ¼ 0 and ΔX z ð Þ ¼ 0. The zero result for ΔX 0 z ð Þ and ΔX z ð Þ, given by the focusing approximation, is clear because the equations of motion in the horizontal and vertical planes are independent in the framework of this approximation. Therefore, the shift of the electron in the vertical direction leads to a corresponding variation of the vertical component of its trajectory without changing its horizontal component. At the same time, the numerical simulations by using the Runge-Kutta method, as well as the analytical calculations by using a more exact formula, namely the derivative of Eq. (45), give distinctly nonzero result. In other words, more accurate numerical simulations and analytical calculations carried out with more precise Eq. (45) have clearly demonstrated that electron trajectories in undulators have the cross-coordinate influence effects. This means that changes in the initial electron parameters in the vertical plane lead to changes of the electron trajectory in the horizontal plane, and vice versa. Eqs. (45), (46) demonstrate it explicitly. Physics of the appearance of such nonzero oscillating behaviour of additions (curves (b) in Figure 3 (A) and (B)) is clear. The undulator deflection parameter K is calculated using the value of the magnetic-field amplitude B 0 on the undulator axis (Z-axis). The transverse electron velocity with zero initial conditions in its motion in the undulator median plane is described by the expression x 0 z ð Þ ¼ À e Kcosw. In the example under consideration, the electron moves at y 0 ¼ AE0:1 mm (the additional shift in the vertical direction acquired by the electron during its motion in the undulator field is small: $ 2•10 À4 mm and can be neglected, see Figure 2 (B). The magnetic field in the plane of the electron motion y 0 ¼ AE0:1 mm is slightly larger than it is in the undulator median plane. As a result, the amplitude of such an electron oscillation must be larger than that if it moves in the undulator median plane. The nonzero addition to the reduced velocity ΔX 0 z ð Þ shown in Figure 3 (A) describes the increase in the amplitude of the electron-velocity oscillations in the horizontal plane. We also note that in the case under consideration, the additions to the horizontal components of the electron-reduced velocity ΔX 0 z ð Þ and coordinate ΔX z ð Þ (see Figure 3  Functions ΔX 0 z ð Þ and ΔX z ð Þ, calculated through Eq. (45) and its derivative, are in excellent agreement with these numerically simulated functions. The function ΔX 0 z ð Þ, differently calculated (numerically and with the Eq. (45)), has maximum deviation about 6•10 À11 in its absolute value. The maximum value of X 0 z ð Þ function is about 3•10 À8 and the relative error is equal to 2•10 À3 . Similarly, the function ΔX z ð Þ, differently calculated, has maximum deviation about 10 À9 in its absolute value. The maximum value of ΔX z ð Þ function is about 7•10 À5 and the relative error is equal to 1:4•10 À5 . This means that these functions are merged together in Figure 3 (A) and (B). 5 show the calculated transverse components of the electron trajectory and its reduced velocity ΔX z ð Þ, ΔY z ð Þ, ΔX 0 z ð Þ and ΔY 0 z ð Þ with the following initial conditions:

Figures 4 and
x 0 ¼ 0:1 mm, θ 0 ¼ À5•10 À5 rad, y 0 ¼ 0:1 mm and y 0 0 ¼ À5•10 À5 rad.   Figure 4 shows the additions to the linear (main) part of the vertical component of the electronreduced velocity ΔY 0 z ð Þ and coordinate ΔY z ð Þ. It can be seen that both curves in Figure 4 (A), as well as in Figure 4 (B), namely computed in the framework of focusing approximation and by means of perturbation theory, are relatively close to each other. In most cases, the difference is not important. For completeness, we check here the precision of Eq. (46). For Figure 4 (A), the largest absolute difference between the numerically simulated function ΔY 0 z ð Þ and those using formula (46) is equal to 3•10 À12 . In this case, the maximum value of the function ΔY 0 z ð Þ is equal to 2•10 À8 . The relative error in this case is about 1:5•10 À4 . Similarly, for Figure 4 (B) the largest absolute difference between the numerically simulated function ΔY z ð Þ and those using formula (46) is equal to 4•10 À9 mm. In this case, the maximum value of the function ΔY z ð Þ is equal to 4•10 À5 mm. The relative error in this case is about 10 À4 . This means that these two couples of functions are merged together in Figure 4 (A) and (B). Figure 5 shows the additions to the linear (main) part of the horizontal component of the electron-reduced velocity ΔX 0 z ð Þ and coordinate ΔX z ð Þ. For Figure 5 (A), the largest absolute difference between the numerically simulated function ΔX 0 z ð Þ and those using formula (45) is equal to 1:5•10 À11 . In this case, the maximum value of the function ΔX 0 z ð Þ is equal to 4•10 À8 .
The relative error in this case is about 4•10 À4 . Similarly, for Figure 5 (B), the largest absolute difference between the numerically simulated function ΔX z ð Þ and those using formula (45) is equal to 9•10 À10 mm. In this case, the maximum value of the function ΔX z ð Þ is equal to 7•10 À5 mm. The relative error in this case is about 10 À5 . This means that these two couples of functions are merged together in Figure 5 (A) and (B). It is seen that, in this case, the focusing approximation describes the electron trajectory in the horizontal plane completely incorrectly, while formula (45) describes it with very good accuracy.

Conclusion
Here, electron beam dynamics in a planar undulator was analysed. Three methods of electron trajectory calculations were considered: smoothing (focusing) approximation, perturbation theory method and numerical simulations by using the Runge-Kutta algorithm. Within the framework of focusing approximation, trajectories were described by rather simple analytical expressions (20-23) which have a clear physical interpretation. However, the more detailed analysis of the electron trajectories in a three-dimensional magnetic field of a planar undulator showed that the focusing approximation does not always give the correct result, and it should be used with caution. Expressions (45, 46) give the correct result and their high accuracy was confirmed by numerical simulations. However, Eqs. (45), (46) are rather cumbersome, and they have no clear physical interpretation. Their cumbersomeness results from the fact that they include all terms of cubic power of smallness.
The examples used in this chapter show that the focusing approximation formulas (21,23), which describe the electron motion in the vertical plane of ideal undulator magnetic field, have quite admissible accuracy. However, in the general case, formulas (20,22) are hardly applicable to the description of the behaviour of an electron in the horizontal plane. The use of expression (46) gives a more reliable result. At the same time, the use of analytical expressions (45, 46) has significant advantages. Indeed, for numerical calculation (e.g. by using the Runge-Kutta algorithm) the spatial coordinates and velocity directions of an electron at the undulator end, it is necessary to calculate all its trajectories in the undulator successively, step by step, with a small interval. This requires considerable time. By using the analytical formulas, it is possible to immediately obtain the final result by substituting the ending coordinate of the undulator magnetic field into the analytical expressions. This dramatically reduces the computational time.