## 1. 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 two-dimensional 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–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 zero-offset 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–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 free-electron 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 sinusoidal-type 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–20].

The wavelength

In a number of recent papers [22–24], electron trajectories in perfect sinusoidal three-dimensional 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–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–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.

## 2. Equations of electron motion in ideal planar undulator

Let

where

The time

We point out that the Eqs. (2), (3) are expressed in terms of the longitudinal coordinate

Here, the undulator with planar magnetic system and ideal three-dimensional sinusoidal magnetic field is considered; see **Figure 1**:

where

The parameter

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

The region occupied by the electron beam, that is, the small vicinity near the undulator axis, has relatively small transversal coordinates:

It is clear that on the undulator axis

Differential Eqs. (2), (3) are nonlinear and cannot be solved exactly. However, the functions

where

In the cases of our interest, the dimensionless undulator deflection parameter

Neglecting all small terms

The solutions of Eqs. (12), (13) are the following:

where

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:

## 3. Smoothed (focusing) approximation for electron trajectories

It is reasonable to generalise the Eqs. (14), (15) as follows. We replace the terms

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

where

Since the functions

It is significant that Eqs. (20)–(23) are linear in terms of the initial electron parameters

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.

## 4. 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

In the cases under consideration:

Eqs. (25)–(28) determine the electron trajectory in a short undulator which is defined by the inequality (24). Let us compare Eqs. (25), (26) which are derived in the framework of focusing approximation, with Eqs. (14), (15) obtained in the linear approximation. It is clear that all additional terms describing the focusing properties of the undulator have the cubic power for the small parameters

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

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

At the undulator end with the

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:

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–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)

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

## 5. 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

The functions

(45) |

(46) |

where

Eqs. (45), (46) completely determine the electron trajectory in three-dimensional undulator magnetic field, which is described by the Eqs. (4)–(6). Differentiating Eqs. (45), (46) with respect to the longitudinal coordinate

Eqs. (45), (46) include all terms that are linear and cubic in small values

The first three terms in Eq. (45) include Eq. (20) for trajectories, which were derived in the focusing approximation. However, the third term in brackets in Eq. (45) contains additional quadratic terms, which have a clear physical meaning. They correspond to a change in the undulator magnetic field amplitude during the electron motion along a straight line. This straight line is the electron trajectory averaged over fast horizontal oscillations. The first two terms of Eq. (46) coincide with Eq. (21) for the vertical component of the electron trajectory. We mention that formulas (45) and (46) are given in terms of reduced dimensionless coordinates and

Some terms in Eqs. (45), (46) include the factor

The parameter

## 6. 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–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

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

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

It is precisely these components that are responsible for the focusing properties of the undulator field.

**Figures 2** and **3** show the calculated transversal component (vertical and horizontal correspondently) of electron trajectory and its reduced velocity with the following initial conditions:

**Figure 2 (A)** shows the additions **Figure 2 (B)** shows the additions **Figure 2 (A)** and **(B)** both include the addition for the electron trajectory, which was initially shifted downward in the negative direction of **Figure 2 (A, B)**, the lower curves) acquires the negative velocity component, whose absolute value increases linearly with the longitudinal coordinate **Figure 2 (A, B)**, the upper curves) acquires the positive velocity component, whose value also increases linearly with the longitudinal coordinate

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 **Figure 2 (B)**. The largest absolute difference between numerically simulated function

**Figure 3 (A)** and **(B)** show the horizontal additions to the regular part of the reduced electron velocity **Figure 3 (A)** and **(B)**) is clear. The undulator deflection parameter **Figure 2 (B)**. The magnetic field in the plane of the electron motion **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 **Figure 3 (A)**, **(B)**) are of the same order in amplitude as the corresponding additions to the vertical components **Figure 2 (A)**, **(B)**:

Functions **Figure 3 (A)** and **(B)**.

**Figures 4** and **5** show the calculated transverse components of the electron trajectory and its reduced velocity

**Figure 4** shows the additions to the linear (main) part of the vertical component of the electron-reduced velocity **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 **Figure 4 (B)** the largest absolute difference between the numerically simulated function **Figure 4 (A)** and **(B)**.

**Figure 5** shows the additions to the linear (main) part of the horizontal component of the electron-reduced velocity **Figure 5 (A)**, the largest absolute difference between the numerically simulated function **Figure 5 (B)**, the largest absolute difference between the numerically simulated function **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.

## 7. 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.