1 Introduction
Understanding the magnetohydrostatics (MHS) equilibrium in magnetically confined devices is paramount. The theory of axisymmetric MHS equilibrium, applicable to tokamaks, is well-developed at this point. The axisymmetric problem can be reduced to solving a nonlinear elliptic partial differential equation (PDE) called the Grad–Shafranov equation (Grad Reference Grad1971; Freidberg Reference Freidberg1982). In contrast, the three-dimensional (3-D) theory cannot be reduced to a single elliptic PDE (Bauer, Betancourt & Garabedian Reference Bauer, Betancourt and Garabedian2012b; Helander Reference Helander2014; Weitzner Reference Weitzner2014). Analytical understanding is obstructed by the intrinsic nonlinearity of the MHS system, coupled with the 3-D nature of the 3-D equilibrium, which is generic for stellarators. These obstacles hinder an intuitive understanding of important physical effects, such as the deformations of the vacuum plasma surfaces due to pressure-driven currents or the dependence of magnetic shear on the geometry. Large-scale numerical computation has taught us much about stellarator equilibrium, but simulations can be expensive. Furthermore, the computational error can be significant, particularly near the magnetic axis (Panici et al. Reference Panici, Conlin, Dudt and Kolemen2022). Therefore, obtaining an analytical understanding of 3-D stellarator MHS equilibrium is beneficial for computational studies and their applications to experiments.
 In this work, we shall focus on an asymptotic expansion called the near-axis expansion (NAE) developed by several authors (Mercier Reference Mercier1964; Solov'ev & Shafranov Reference Solov'ev and Shafranov1970; Bernardin & Tataronis Reference Bernardin and Tataronis1985; Garren & Boozer Reference Garren and Boozer1991; Weitzner Reference Weitzner2016). The basic idea is to expand the MHS equilibrium equations in a power series in the distance from the magnetic axis. The small parameter is $\kappa a$ , where $\kappa$
, where $\kappa$ is the curvature of the magnetic axis, and $a$
 is the curvature of the magnetic axis, and $a$ is a typical length scale of the order of the minor radius in the direction normal to the magnetic axis. Recently, there has been a surge of interest in applying the NAE to study quasisymmetry (Landreman & Sengupta Reference Landreman and Sengupta2018, Reference Landreman and Sengupta2019; Jorge, Sengupta & Landreman Reference Jorge, Sengupta and Landreman2020a; Rodríguez, Sengupta & Bhattacharjee Reference Rodríguez, Sengupta and Bhattacharjee2023), quasiisodynamic stellarators (Plunk, Landreman & Helander Reference Plunk, Landreman and Helander2019; Mata, Plunk & Jorge Reference Mata, Plunk and Jorge2022; Mata & Plunk Reference Mata and Plunk2023; Rodríguez & Plunk Reference Rodríguez and Plunk2023), energetic particles (Figueiredo et al. Reference Figueiredo, Jorge, Ferreira and Rodrigues2023), MHS stability (Landreman & Jorge Reference Landreman and Jorge2020; Kim, Jorge & Dorland Reference Kim, Jorge and Dorland2021; Rodríguez Reference Rodríguez2023) and turbulence (Jorge & Landreman Reference Jorge and Landreman2020, Reference Jorge and Landreman2021; Rodríguez & Mackenbach Reference Rodríguez and Mackenbach2023).
 is a typical length scale of the order of the minor radius in the direction normal to the magnetic axis. Recently, there has been a surge of interest in applying the NAE to study quasisymmetry (Landreman & Sengupta Reference Landreman and Sengupta2018, Reference Landreman and Sengupta2019; Jorge, Sengupta & Landreman Reference Jorge, Sengupta and Landreman2020a; Rodríguez, Sengupta & Bhattacharjee Reference Rodríguez, Sengupta and Bhattacharjee2023), quasiisodynamic stellarators (Plunk, Landreman & Helander Reference Plunk, Landreman and Helander2019; Mata, Plunk & Jorge Reference Mata, Plunk and Jorge2022; Mata & Plunk Reference Mata and Plunk2023; Rodríguez & Plunk Reference Rodríguez and Plunk2023), energetic particles (Figueiredo et al. Reference Figueiredo, Jorge, Ferreira and Rodrigues2023), MHS stability (Landreman & Jorge Reference Landreman and Jorge2020; Kim, Jorge & Dorland Reference Kim, Jorge and Dorland2021; Rodríguez Reference Rodríguez2023) and turbulence (Jorge & Landreman Reference Jorge and Landreman2020, Reference Jorge and Landreman2021; Rodríguez & Mackenbach Reference Rodríguez and Mackenbach2023).
The development of the NAE theory has proceeded along two approaches: direct and indirect. In the direct approach (Mercier Reference Mercier1964; Solov'ev & Shafranov Reference Solov'ev and Shafranov1970; Bernardin & Tataronis Reference Bernardin and Tataronis1985; Jorge et al. Reference Jorge, Sengupta and Landreman2020a; Jorge, Sengupta & Landreman Reference Jorge, Sengupta and Landreman2020b; Duignan & Meiss Reference Duignan and Meiss2021), one uses a coordinate system pioneered by Mercier, and expands in the distance from the magnetic axis. In the inverse approach, one expands in the toroidal flux-surface label (Garren & Boozer Reference Garren and Boozer1991; Weitzner Reference Weitzner2016; Landreman & Sengupta Reference Landreman and Sengupta2018, Reference Landreman and Sengupta2019; Landreman, Sengupta & Plunk Reference Landreman, Sengupta and Plunk2019; Rodríguez & Bhattacharjee Reference Rodríguez and Bhattacharjee2021; Rodríguez, Sengupta & Bhattacharjee Reference Rodríguez, Sengupta and Bhattacharjee2021, Reference Rodríguez, Sengupta and Bhattacharjee2022).
Both the direct and the indirect approaches have distinct advantages and disadvantages. The inverse coordinate approach is best suited to address concepts such as quasisymmetry and omnigeneity, which impose constraints on the magnitude of the magnetic field. However, the direct approach offers better physical insight. This is mainly because the flux-surface shaping factors, such as ellipticity and triangularity, can be chosen independently in the direct approach but not in the indirect approach. Moreover, in the indirect approach, the lowest order involves the solution of a nonlinear Riccati equation. In the direct coordinate approach, we can avoid solving a nonlinear ordinary differential equation (ODE) by using Mercier's formula (Solov'ev & Shafranov Reference Solov'ev and Shafranov1970; Mercier Reference Mercier1974), which also follows from Floquet theory (Duignan & Meiss Reference Duignan and Meiss2021). The expressions for the rotational transform (Mercier Reference Mercier1964; Helander Reference Helander2014) and its derivatives are also physically more intuitive in the direct approach.
 An outstanding issue that arises while constructing NAE solutions order by order is the maintenance of the smoothness of the solutions of the MHS equilibrium. If we assume that the magnetic field satisfies MHS with smooth, nested toroidal pressure surfaces, it can be shown rigorously (Burby, Duignan & Meiss Reference Burby, Duignan and Meiss2021) that the NAE can be assured to be smooth. This rigorous result has been extended recently to smooth vacuum and force-free fields assuming smooth nested flux surfaces (Perrella, Duignan & Pfefferlé Reference Perrella, Duignan and Pfefferlé2023). These deep mathematical results hold even in the case that iota ($\iota$ ) is irrational. Although we are guaranteed that smooth NAE solutions will exist, several difficulties arise when constructing the NAE solution explicitly order by order.
) is irrational. Although we are guaranteed that smooth NAE solutions will exist, several difficulties arise when constructing the NAE solution explicitly order by order.
 The first problem we encounter is the classic problem of the occurrence of singular currents in stellarators on rational surfaces because of a lack of axisymmetry (Mercier Reference Mercier1964; Grad Reference Grad1967; Helander Reference Helander2014; Loizu et al. Reference Loizu, Hudson, Bhattacharjee, Lazerson and Helander2015; Weitzner Reference Weitzner2016). These singularities are fundamentally tied to the magnetic differential equations (MDE) (Newcomb Reference Newcomb1959), whose solution can be singular everywhere, $\iota$ , the rotational transform, is rational. Since rationals are dense, avoiding such singularities with non-constant $\iota$
, the rotational transform, is rational. Since rationals are dense, avoiding such singularities with non-constant $\iota$ is challenging (Grad Reference Grad1967; Boozer Reference Boozer1981b; Weitzner Reference Weitzner2014). In the NAE expansion, thankfully, the rational singularities are governed only by $\iota _0$
 is challenging (Grad Reference Grad1967; Boozer Reference Boozer1981b; Weitzner Reference Weitzner2014). In the NAE expansion, thankfully, the rational singularities are governed only by $\iota _0$ , the on-axis rotational transform (Mercier Reference Mercier1964; Solov'ev & Shafranov Reference Solov'ev and Shafranov1970; Duignan & Meiss Reference Duignan and Meiss2021). Choosing it to be sufficiently irrational helps with the practical implementation of lower-order NAE (Landreman & Sengupta Reference Landreman and Sengupta2019; Jorge et al. Reference Jorge, Sengupta and Landreman2020b). However, since any irrational number can be approximated closely by rationals, the problem of singular divisors appearing in higher orders can only be partially resolved mathematically in this approach. An alternative is to assume that $\iota _0$
, the on-axis rotational transform (Mercier Reference Mercier1964; Solov'ev & Shafranov Reference Solov'ev and Shafranov1970; Duignan & Meiss Reference Duignan and Meiss2021). Choosing it to be sufficiently irrational helps with the practical implementation of lower-order NAE (Landreman & Sengupta Reference Landreman and Sengupta2019; Jorge et al. Reference Jorge, Sengupta and Landreman2020b). However, since any irrational number can be approximated closely by rationals, the problem of singular divisors appearing in higher orders can only be partially resolved mathematically in this approach. An alternative is to assume that $\iota _0$ is close to a given rational number and construct special non-singular solutions (Weitzner Reference Weitzner2016; Jaquiery & Sengupta Reference Jaquiery and Sengupta2019) or use the near-resonant normal form theory (Duignan & Meiss Reference Duignan and Meiss2021).
 is close to a given rational number and construct special non-singular solutions (Weitzner Reference Weitzner2016; Jaquiery & Sengupta Reference Jaquiery and Sengupta2019) or use the near-resonant normal form theory (Duignan & Meiss Reference Duignan and Meiss2021).
 We remark that there could be other potential sources of non-smoothness as well. Even in the vacuum limit, the smoothness of the solution within the NAE framework is not obvious (Jorge et al. Reference Jorge, Sengupta and Landreman2020b). When currents are present, the situation is complicated by another factor: the possibility of occurrence of logarithmic terms of the form $\rho ^n (\log \rho )^m, n>m$ that, if present, make the equilibrium weakly singular near the axis ($\rho =0$
 that, if present, make the equilibrium weakly singular near the axis ($\rho =0$ ) (Weitzner Reference Weitzner2016). Perhaps the easiest way to understand the physical origin of these logarithmic terms is to think of the plasma in the large aspect ratio picture as a thin current-carrying loop (Freidberg Reference Freidberg1982; Jackson Reference Jackson1999). The logarithmic terms are then unavoidable in the poloidal flux function (Freidberg Reference Freidberg1982). However, this simplified description of plasma needs to be modified near the axis to avoid the singularities on the axis. As shown in Greene, Johnson & Weimer (Reference Greene, Johnson and Weimer1971), removing such weakly singular terms is tricky, even at lower orders. These issues are expected to worsen in stellarators where the currents interact with the 3-D geometry. In this work, we develop a systematic way to avoid such singular terms within the NAE formalism, showing that the assumption of smoothness of the NAE can be satisfied order by order.
) (Weitzner Reference Weitzner2016). Perhaps the easiest way to understand the physical origin of these logarithmic terms is to think of the plasma in the large aspect ratio picture as a thin current-carrying loop (Freidberg Reference Freidberg1982; Jackson Reference Jackson1999). The logarithmic terms are then unavoidable in the poloidal flux function (Freidberg Reference Freidberg1982). However, this simplified description of plasma needs to be modified near the axis to avoid the singularities on the axis. As shown in Greene, Johnson & Weimer (Reference Greene, Johnson and Weimer1971), removing such weakly singular terms is tricky, even at lower orders. These issues are expected to worsen in stellarators where the currents interact with the 3-D geometry. In this work, we develop a systematic way to avoid such singular terms within the NAE formalism, showing that the assumption of smoothness of the NAE can be satisfied order by order.
The current work generalizes the direct NAE approach of Jorge et al. (Reference Jorge, Sengupta and Landreman2020b) by including force-free and plasma-beta-driven currents, and by discussing both the structure of the flux surface and the field line label to all orders. The outline of the paper is as follows. In § 2, we introduce the basic formalisms developed by Mercier (Mercier Reference Mercier1964, Reference Mercier1974) and Weitzner (Weitzner Reference Weitzner2014, Reference Weitzner2016) and show how they can be combined into one, which we call the Mercier–Weitzner formalism. We assume the rotational transform to be sufficiently irrational. With this assumption, we can solve the MDEs order by order without encountering resonances on rational surfaces. We discuss the NAE of the vacuum fields in § 3, force-free fields in § 4 and finally, MHS fields with finite plasma beta in § 5.
Our strategy is to construct a new variable that mimics the vacuum scalar potential but fully incorporates the effects of currents. The NAE using this variable shows a structure very close to the vacuum problem. Under the assumption of smooth fields and currents near the axis, we can show that power-series solutions to ideal MHS can be constructed to all orders. We do not attempt to prove convergence of the series. We show that the NAE calculations are simplified to a great extent through the use of the leading-order Birkhoff–Gustavson Hamiltonian normal form variables (Bernardin & Tataronis Reference Bernardin and Tataronis1985; Duignan & Meiss Reference Duignan and Meiss2021). Normal forms in the present work show up as a basis that diagonalizes the magnetic differential operator (MDO), thereby simplifying the calculations of the solutions of MDEs ubiquitous in MHS.
In § 7, we present a numerical example that compares the higher-order finite-beta near-axis asymptotic expansions with a finite aspect-ratio equilibrium generated using the VMEC code (Hirshman & Whitson Reference Hirshman and Whitson1983). We present our conclusions and open questions in § 8. Finally, a variety of special cases are discussed in the appendices.
2 The Mercier–Weitzner near-axis formalism
Our goal in this work is to extend the direct approach to the near-axis formalism, as developed by Mercier (Mercier Reference Mercier1964) and Solov’ev & Shafranov (Solov'ev & Shafranov Reference Solov'ev and Shafranov1970), to include finite plasma beta. Mercier's original approach (Mercier Reference Mercier1974) indeed considers currents and finite beta. However, the methodology to calculate beyond the two lowest orders is not transparent. Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970) extend Mercier's work significantly but primarily for vacuum fields. Effects of plasma beta, such as on the flux surface shapes, are treated through expansion subsidiary to the NAE. Only recently, a complete description of NAE in direct coordinates that included both vacuum and force-free equilibria was obtained (Duignan & Meiss Reference Duignan and Meiss2021).
Here we provide a unified framework to include vacuum, force-free as well as finite beta ideal MHS. We shall use Weitzner's approach (Weitzner Reference Weitzner2014, Reference Weitzner2016) to obtain finite-beta MHS equilibrium equations. In this approach, currents are included through the current potential obtained through the solution of an MDE. In the following, we describe the NAE in direct coordinates using the current potential approach due to Weitzner.
2.1 The Weitzner formulation of ideal MHS with scalar pressure
 We begin with the discussion of the formalism developed in Weitzner (Reference Weitzner2014, Reference Weitzner2016) to study 3-D (non-symmetric) ideal MHS equilibria with scalar pressure. We assume throughout that the magnetic field $\boldsymbol {B}$ satisfies the ideal MHS equations
 satisfies the ideal MHS equations
 
where $\boldsymbol {J}$ represents the current, and $p$
 represents the current, and $p$ is the scalar pressure. We have used units such that $\mu _0$
 is the scalar pressure. We have used units such that $\mu _0$ is set to unity. We shall assume that the magnetic field possess a set of nested toroidal flux surfaces, denoted by the flux label $\psi$
 is set to unity. We shall assume that the magnetic field possess a set of nested toroidal flux surfaces, denoted by the flux label $\psi$ , which are also isosurfaces of the pressure. Furthermore, we assume that $\boldsymbol {\nabla } \psi$
, which are also isosurfaces of the pressure. Furthermore, we assume that $\boldsymbol {\nabla } \psi$ is non-zero everywhere except at the magnetic axis.
 is non-zero everywhere except at the magnetic axis.
To describe the magnetic field vector, we now use the following contravariant and covariant representation:
 
 
Equation (2.2a) is the standard Clebsch representation (D'haeseleer et al. Reference D'haeseleer, Hitchon, Callen and Shohet2012; Helander Reference Helander2014) of the magnetic field with $\psi$ and $\alpha$
 and $\alpha$ denoting the toroidal magnetic flux and field line label, respectively. The Clebsch form manifestly satisfies $\boldsymbol {\nabla }\boldsymbol {\cdot } \boldsymbol {B}=0$
 denoting the toroidal magnetic flux and field line label, respectively. The Clebsch form manifestly satisfies $\boldsymbol {\nabla }\boldsymbol {\cdot } \boldsymbol {B}=0$ and $\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla }\psi =0$
 and $\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla }\psi =0$ . The second representation of the magnetic field, (2.2b), is the so-called Boozer–Grad representation (see chapter 7.2 of D'haeseleer et al. (Reference D'haeseleer, Hitchon, Callen and Shohet2012)). We call $\varPhi$
. The second representation of the magnetic field, (2.2b), is the so-called Boozer–Grad representation (see chapter 7.2 of D'haeseleer et al. (Reference D'haeseleer, Hitchon, Callen and Shohet2012)). We call $\varPhi$ the magnetic scalar potential and $K$
 the magnetic scalar potential and $K$ the current potential, since, in the limit $K\to 0$
 the current potential, since, in the limit $K\to 0$ , or in the case of $K= K(\psi )$
, or in the case of $K= K(\psi )$ , the curl of $\boldsymbol {B}$
, the curl of $\boldsymbol {B}$ (2.2b) vanishes. The quantities $\varPhi, K,\alpha$
 (2.2b) vanishes. The quantities $\varPhi, K,\alpha$ need not be single-valued in a torus. Note also that the separation of $\varPhi,K$
 need not be single-valued in a torus. Note also that the separation of $\varPhi,K$ in the representation for $\boldsymbol {B}$
 in the representation for $\boldsymbol {B}$ in (2.2b) is not unique since a shift of $\varPhi \to \varPhi + \varphi (\psi )$
 in (2.2b) is not unique since a shift of $\varPhi \to \varPhi + \varphi (\psi )$ results in a shift $K\to K-\varphi '(\psi )$
 results in a shift $K\to K-\varphi '(\psi )$ without changing $\boldsymbol {B}$
 without changing $\boldsymbol {B}$ .
.
For the sake of comparison, we first look at the standard representation given by
 
 
Here, $(\psi,\theta _B,\phi _B)$ represents the standard Boozer coordinates (Boozer Reference Boozer1980, Reference Boozer1981a,Reference Boozerb) with $2{\rm \pi} \psi$
 represents the standard Boozer coordinates (Boozer Reference Boozer1980, Reference Boozer1981a,Reference Boozerb) with $2{\rm \pi} \psi$ equal to the toroidal flux, $\iota (\psi )$
 equal to the toroidal flux, $\iota (\psi )$ equal to the rotational transform and $(\theta _B,\varPhi _B)$
 equal to the rotational transform and $(\theta _B,\varPhi _B)$ represent the poloidal and toroidal Boozer angles. The quantities $I_B(\psi ),G_B(\psi )$
 represent the poloidal and toroidal Boozer angles. The quantities $I_B(\psi ),G_B(\psi )$ and $B_\psi$
 and $B_\psi$ are all single-valued functions. The Boozer representation is an important special case of (2.2) for the choice
 are all single-valued functions. The Boozer representation is an important special case of (2.2) for the choice
 
In this work, we use the Boozer–Grad coordinates instead of the usual Boozer coordinates.
 Returning to the covariant representation of the magnetic field as given in (2.2b), we find that the chief advantage of this form is that the current, $\boldsymbol {J}=\boldsymbol {\nabla } \times \boldsymbol {B}$ , has a Clebsch form
, has a Clebsch form
 
which manifestly satisfies
 
Furthermore, the ideal MHS force balance
 
takes a particularly simple form in terms of an MDE for $K$ :
:
 
The solution to (2.8) can be represented as
 
where $\bar {K}(\psi,\alpha )$ is the homogeneous solution of the MDE and hence only a function of $\psi$
 is the homogeneous solution of the MDE and hence only a function of $\psi$ and possibly $\alpha$
 and possibly $\alpha$ .
.
 Let us collect the basic equations in the Weitzner formalism. These are obtained by equating the contravariant and the covariant representations of $\boldsymbol {B}$ as given in (2.2), together with (2.8),
 as given in (2.2), together with (2.8),
 
 
Note that (2.10a), which we will call the basic MHS equations, is a set of three coupled nonlinear PDEs, while (2.10b) determines $K$ . Together, they form a complete set of equations for the variables $(\varPhi,\psi,\alpha,K)$
. Together, they form a complete set of equations for the variables $(\varPhi,\psi,\alpha,K)$ . We shall now discuss the boundary conditions that must be satisfied such that (2.10) has physically meaningful solutions in a torus.
. We shall now discuss the boundary conditions that must be satisfied such that (2.10) has physically meaningful solutions in a torus.
 In a torus, all physical quantities, such as magnetic fields and currents, must satisfy periodic boundary conditions in the two angles $(\theta,\phi )$ , where $\theta$
, where $\theta$ is a poloidal angle, and $\phi$
 is a poloidal angle, and $\phi$ is a toroidal angle. Unlike standard Boozer coordinates $(\theta _B,\phi _B)$
 is a toroidal angle. Unlike standard Boozer coordinates $(\theta _B,\phi _B)$ , we do not require $(\theta,\phi )$
, we do not require $(\theta,\phi )$ to be straight field line coordinates. This provides greater flexibility and freedom since we do not have any additional constraints on the angles. As mentioned, the functions $(\alpha,\varPhi,K)$
 to be straight field line coordinates. This provides greater flexibility and freedom since we do not have any additional constraints on the angles. As mentioned, the functions $(\alpha,\varPhi,K)$ in a toroidal domain are multivalued. However, the multivalued part of the $\{\varPhi,\alpha,K\}$
 in a toroidal domain are multivalued. However, the multivalued part of the $\{\varPhi,\alpha,K\}$ system is not arbitrary due to the physical requirement that the magnetic field and the current must be single-valued quantities.
 system is not arbitrary due to the physical requirement that the magnetic field and the current must be single-valued quantities.
 Following (Grad Reference Grad1971; Weitzner Reference Weitzner2016) we observe that in order for $\boldsymbol {B},\boldsymbol {J}$ (as given by (2.2a) and (2.5)) to be single-valued, only the $\boldsymbol {\nabla }\psi$
 (as given by (2.2a) and (2.5)) to be single-valued, only the $\boldsymbol {\nabla }\psi$ covariant components of $\boldsymbol {\nabla } \alpha$
 covariant components of $\boldsymbol {\nabla } \alpha$ and $\boldsymbol {\nabla } K$
 and $\boldsymbol {\nabla } K$ can be multivalued. Furthermore, from (2.2b) we find that the secular terms of $\varPhi$
 can be multivalued. Furthermore, from (2.2b) we find that the secular terms of $\varPhi$ and $K$
 and $K$ must be related to each other such that $\boldsymbol {B}$
 must be related to each other such that $\boldsymbol {B}$ is single-valued.
 is single-valued.
 As shown in Weitzner (Reference Weitzner2014), single valuedness of $\boldsymbol {B},\boldsymbol {J}$ in a torus implies that $\varPhi,\alpha$
 in a torus implies that $\varPhi,\alpha$ and $K$
 and $K$ must be of the form
 must be of the form
 
 
 
where, $(\tilde {\varPhi },\tilde {\alpha },\tilde {K})$ denotes functions periodic in both $\theta$
 denotes functions periodic in both $\theta$ and $\phi$
 and $\phi$ , and $\iota (\psi )$
, and $\iota (\psi )$ denotes the rotational transform of the magnetic field. The form (2.11) builds in the nestedness of flux surfaces. The single-valued flux functions $I(\psi ),G(\psi ),\iota (\psi )$
 denotes the rotational transform of the magnetic field. The form (2.11) builds in the nestedness of flux surfaces. The single-valued flux functions $I(\psi ),G(\psi ),\iota (\psi )$ denote the same quantities as in standard Boozer coordinates (2.4a–c). We briefly discuss the physical significance of these flux functions below.
 denote the same quantities as in standard Boozer coordinates (2.4a–c). We briefly discuss the physical significance of these flux functions below.
 Without loss of generality, we can choose $2{\rm \pi} \psi$ to be the toroidal flux, as is common in the stellarator literature. As shown in Appendix A, with this choice, we can normalize $\alpha$
 to be the toroidal flux, as is common in the stellarator literature. As shown in Appendix A, with this choice, we can normalize $\alpha$ such that $f(\psi )=1$
 such that $f(\psi )=1$ . The physical interpretation of $I(\psi ),G(\psi )$
. The physical interpretation of $I(\psi ),G(\psi )$ is obtained by considering the net current, $\oint \boldsymbol {J}\boldsymbol {\cdot } \boldsymbol {dS}$
 is obtained by considering the net current, $\oint \boldsymbol {J}\boldsymbol {\cdot } \boldsymbol {dS}$ , through a poloidal and a toroidal circuit. From (2.5) and (2.11c) it follows that $G'(\psi ),I'(\psi )$
, through a poloidal and a toroidal circuit. From (2.5) and (2.11c) it follows that $G'(\psi ),I'(\psi )$ are proportional to the net poloidal and toroidal current. In the vacuum limit ($K=0,p'=0$
 are proportional to the net poloidal and toroidal current. In the vacuum limit ($K=0,p'=0$ ), the net toroidal current is zero, while the net poloidal current is a constant due to external currents. Consequently, for vacuum fields, we have $I(\psi )=0$
), the net toroidal current is zero, while the net poloidal current is a constant due to external currents. Consequently, for vacuum fields, we have $I(\psi )=0$ and $G(\psi )=G_0$
 and $G(\psi )=G_0$ is a constant.
 is a constant.
Equations (2.10), subject to the conditions (2.11), constitute the Weitzner formalism. The MHS equations (2.10a), (2.10b) are highly nonlinear, and in a generic stellarator, analytical progress is severely hindered by lack of any apparent continuous symmetry. Furthermore, the periodicity constraint (2.11) imposes a non-trivial requirement. In order to gain valuable physical insight, one, therefore, resorts to asymptotic analysis in some small parameter.
2.2 Mercier's NAE
Mercier developed one such asymptotic expansion scheme to study the behaviour near the magnetic axis by utilizing the distance from the magnetic axis as the expansion parameter. In the following, we shall briefly describe Mercier's near-axis formalism and Mercier's coordinates (Mercier Reference Mercier1964), which are also known as the direct coordinates (Jorge et al. Reference Jorge, Sengupta and Landreman2020b).
2.2.1 Mercier coordinates
 The Mercier coordinates are defined with respect to the magnetic axis, which is a closed magnetic field line. Although the magnetic axis can be elliptic or hyperbolic (Solov'ev & Shafranov Reference Solov'ev and Shafranov1970; Duignan & Meiss Reference Duignan and Meiss2021), we will only treat the elliptic case here. We will assume that the magnetic axis is a 3-D smooth closed curve of total length $L$ , described by the Frenet–Serret frame
, described by the Frenet–Serret frame
 
where $\boldsymbol {r}_0$ is the position vector of the magnetic axis, $\ell$
 is the position vector of the magnetic axis, $\ell$ is the arclength along the axis, the functions $\kappa (\ell ),\tau (\ell )$
 is the arclength along the axis, the functions $\kappa (\ell ),\tau (\ell )$ are the curvature and torsion of the axis, and the vectors $(\boldsymbol {t},\boldsymbol {n},\boldsymbol {b})$
 are the curvature and torsion of the axis, and the vectors $(\boldsymbol {t},\boldsymbol {n},\boldsymbol {b})$ are the standard tangent, normal and binormal vectors in the Frenet–Serret frame. As is well known, Frenet frames are singular near points of $\kappa =0$
 are the standard tangent, normal and binormal vectors in the Frenet–Serret frame. As is well known, Frenet frames are singular near points of $\kappa =0$ . Since magnetic axes with vanishing curvatures are crucial for QI stellarators, signed Frenet frames are typically used to describe such curves (Plunk et al. Reference Plunk, Landreman and Helander2019; Mata & Plunk Reference Mata and Plunk2023). Here, for simplicity, we do not consider such cases. However, the extension to a signed Frenet frame is straightforward.
. Since magnetic axes with vanishing curvatures are crucial for QI stellarators, signed Frenet frames are typically used to describe such curves (Plunk et al. Reference Plunk, Landreman and Helander2019; Mata & Plunk Reference Mata and Plunk2023). Here, for simplicity, we do not consider such cases. However, the extension to a signed Frenet frame is straightforward.
 Now, let us consider a tube of radius $\rho$ with the magnetic axis as its axis. We can define a poloidal angle $\theta$
 with the magnetic axis as its axis. We can define a poloidal angle $\theta$ such that a point on the tube is described by
 such that a point on the tube is described by
 
The coordinate system $(\rho,\theta,\ell )$ is not orthogonal when the torsion of the axis, $\tau (\ell )$
 is not orthogonal when the torsion of the axis, $\tau (\ell )$ , is non-zero. To obtain an orthogonal coordinate system, Mercier (Reference Mercier1964) replaced $\theta$
, is non-zero. To obtain an orthogonal coordinate system, Mercier (Reference Mercier1964) replaced $\theta$ by
 by
 
The line and volume elements, $({\rm d}s^2,{\rm d}V)$ , of the Mercier coordinates are as follows:
, of the Mercier coordinates are as follows:
 
In other words, the $(\rho,\omega,\ell )$ coordinates are orthogonal with $(1,\rho,h)$
 coordinates are orthogonal with $(1,\rho,h)$ as the scale factors, and the metric tensor is given by
 as the scale factors, and the metric tensor is given by
 
Associated with the Mercier coordinates are the following orthonormal vectors $(\boldsymbol {\hat {\rho }},\boldsymbol {\hat {\omega }},\boldsymbol {\hat {\ell }})$ such that
 such that
 
 There is a certain freedom in choosing the poloidal and toroidal angles in the direct coordinates $(\rho,\omega,\ell )$ . While the toroidal angle follows from the arclength $\ell$
. While the toroidal angle follows from the arclength $\ell$ , one can generally add any arbitrary function $\delta (\ell )$
, one can generally add any arbitrary function $\delta (\ell )$ , where $\delta '(\ell )$
, where $\delta '(\ell )$ is single-valued, to $\theta$
 is single-valued, to $\theta$ to obtain another poloidal angle without changing the Jacobian of transformation. Besides $(\theta,\phi =2{\rm \pi} \ell /L)$
 to obtain another poloidal angle without changing the Jacobian of transformation. Besides $(\theta,\phi =2{\rm \pi} \ell /L)$ another possible choice is $(u,\phi )$
 another possible choice is $(u,\phi )$ , where
, where
 
 Let us now describe the Weitzner system described in § 2.1 using the Mercier coordinates. To connect to the contravariant form of $\boldsymbol {B}$ (2.2a) in the Weitzner formalism, we shall make a choice $(\theta,\phi )$
 (2.2a) in the Weitzner formalism, we shall make a choice $(\theta,\phi )$ for defining angular coordinates. To connect to the covariant form of $\boldsymbol {B}$
 for defining angular coordinates. To connect to the covariant form of $\boldsymbol {B}$ given by (2.2b) in the Weitzner formalism, we shall utilize the orthonormal vectors $(\boldsymbol {\hat {\rho }},\boldsymbol {\hat {\omega }},\boldsymbol {\hat {\ell }})$
 given by (2.2b) in the Weitzner formalism, we shall utilize the orthonormal vectors $(\boldsymbol {\hat {\rho }},\boldsymbol {\hat {\omega }},\boldsymbol {\hat {\ell }})$ . Using (2.15a–c), we can write the magnetic field in the following component form:
. Using (2.15a–c), we can write the magnetic field in the following component form:
 
 
Here and elsewhere, we shall use the notation $X_{,\ell }$ to denote the partial derivative of $X$
 to denote the partial derivative of $X$ with respect to $\ell$
 with respect to $\ell$ holding the other two Mercier coordinates $(\rho,\omega )$
 holding the other two Mercier coordinates $(\rho,\omega )$ fixed.
 fixed.
2.2.2 Near-axis expansions
 The fundamental idea underlying the NAE is to solve the MHS equations using perturbation theory, where the expansion parameter scales like the distance from the magnetic axis, $\rho$ . We can formally define the dimensionless expansion parameter $\epsilon \ll 1$
. We can formally define the dimensionless expansion parameter $\epsilon \ll 1$ as
 as
 
where $\kappa _{\text {max}}$ is the maximum axis curvature and $0\leq \rho < a$
 is the maximum axis curvature and $0\leq \rho < a$ . With this definition, we have $\kappa \rho <1$
. With this definition, we have $\kappa \rho <1$ throughout in the domain of validity of the NAE, which is necessary for the metric $\sqrt {g}=\rho h$
 throughout in the domain of validity of the NAE, which is necessary for the metric $\sqrt {g}=\rho h$ to be positive everywhere. Expanding the quantities $(\psi,\alpha,\varPhi,K)$
 to be positive everywhere. Expanding the quantities $(\psi,\alpha,\varPhi,K)$ in $\epsilon$
 in $\epsilon$ and substituting them in the basic equilibrium equations (2.10), one can solve the MHS equations order by order in $\epsilon \ll 1$
 and substituting them in the basic equilibrium equations (2.10), one can solve the MHS equations order by order in $\epsilon \ll 1$ .
.
 It is usually assumed (Kuo-Petravic & Boozer Reference Kuo-Petravic and Boozer1987; Garren & Boozer Reference Garren and Boozer1991) that the physical quantities are sufficiently regular near the magnetic axis such that one can carry out a regular power series expansion in positive powers of $\rho$ . Thus, any function of the form $\mathfrak {f}(\rho,\omega,\ell )$
. Thus, any function of the form $\mathfrak {f}(\rho,\omega,\ell )$ is expanded as follows:
 is expanded as follows:
 
The function $\mathfrak {f}^{(n)}(\omega,\ell )$ can be determined order by order by substituting (2.22) into the MHS equations (2.10). Moreover, if $\mathfrak {f}$
 can be determined order by order by substituting (2.22) into the MHS equations (2.10). Moreover, if $\mathfrak {f}$ has a well-defined Taylor series near the magnetic axis, we would expect $\mathfrak {f}^{(n)}$
 has a well-defined Taylor series near the magnetic axis, we would expect $\mathfrak {f}^{(n)}$ to be a polynomial of order $n$
 to be a polynomial of order $n$ in $(x,y)=\rho (\cos \theta,\sin \theta )$
 in $(x,y)=\rho (\cos \theta,\sin \theta )$ . In Jorge et al. (Reference Jorge, Sengupta and Landreman2020b) and Duignan & Meiss (Reference Duignan and Meiss2021), it has been demonstrated that for vacuum fields with nested surfaces, the functions $(\varPhi -G_0 \phi ),\psi$
. In Jorge et al. (Reference Jorge, Sengupta and Landreman2020b) and Duignan & Meiss (Reference Duignan and Meiss2021), it has been demonstrated that for vacuum fields with nested surfaces, the functions $(\varPhi -G_0 \phi ),\psi$ are of such form. Therefore, for such regular functions, we have
 are of such form. Therefore, for such regular functions, we have
 
where $\left ( \mathfrak {c}^{(n)}(\ell ),\mathfrak {f}^{(n)}_{mc}(\ell ),\mathfrak {f}^{(n)}_{ms}(\ell ),\delta _m(\ell ) \right )$ are functions of $\ell$
 are functions of $\ell$ that must be determined by substituting (2.23) into (2.10). We note that even though the series (2.23) looks like a regular Taylor series for $\mathfrak {f}(x,y,\ell )$
 that must be determined by substituting (2.23) into (2.10). We note that even though the series (2.23) looks like a regular Taylor series for $\mathfrak {f}(x,y,\ell )$ near the axis, the series may be divergent. The NAE, like many other perturbative expansions, is written formally here, with no claims regarding the convergence of the series.
 near the axis, the series may be divergent. The NAE, like many other perturbative expansions, is written formally here, with no claims regarding the convergence of the series.
 We shall substitute the formal series (2.23) into the basic MHS equations (2.10) and collect powers of $\rho$ and the poloidal harmonics $(\cos {m \ell },\sin {m \ell })$
 and the poloidal harmonics $(\cos {m \ell },\sin {m \ell })$ . This then reduces the nonlinear PDE system (2.10) to a nonlinear ODE system for $(\mathfrak {f}^{(n)}_{mc}(\ell ),\mathfrak {f}^{(n)}_{ms}(\ell ))$
. This then reduces the nonlinear PDE system (2.10) to a nonlinear ODE system for $(\mathfrak {f}^{(n)}_{mc}(\ell ),\mathfrak {f}^{(n)}_{ms}(\ell ))$ , which is a significant step forward. Moreover, (2.23) already includes periodicity in $\omega$
, which is a significant step forward. Moreover, (2.23) already includes periodicity in $\omega$ , and only the periodicity in $\ell$
, and only the periodicity in $\ell$ remains to be imposed on the ODEs.
 remains to be imposed on the ODEs.
 Before proceeding further, we should point out some issues that can lead to a lack of regularity of the NAE. Firstly, although the periodicity in $\ell$ can always be satisfied if the on-axis rotational transform is sufficiently irrational, the coefficients $(\mathfrak {f}^{(n)}_{mc}(\ell ),\mathfrak {f}^{(n)}_{ms}(\ell ))$
 can always be satisfied if the on-axis rotational transform is sufficiently irrational, the coefficients $(\mathfrak {f}^{(n)}_{mc}(\ell ),\mathfrak {f}^{(n)}_{ms}(\ell ))$ can formally exhibit singular behaviour when the on-axis rotational transform is close to a rational number. As shown in Mercier (Reference Mercier1964) and Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970), the form of the singularities on a $(m,n)$
 can formally exhibit singular behaviour when the on-axis rotational transform is close to a rational number. As shown in Mercier (Reference Mercier1964) and Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970), the form of the singularities on a $(m,n)$ rational surface is $(\iota _0-n/m)^{-1}$
 rational surface is $(\iota _0-n/m)^{-1}$ , where $\iota _0$
, where $\iota _0$ is the on-axis rotational transform. In this work, we shall assume that $\iota _0$
 is the on-axis rotational transform. In this work, we shall assume that $\iota _0$ is sufficiently irrational to formally avoid such resonances in the vicinity of the axis. Secondly, we note that the regular power series expansion (2.22) is not always guaranteed to be correct. The possibility of having weak logarithmic singularities on the axis in the form of $\rho ^n (\log \rho )^m, n>m>0$
 is sufficiently irrational to formally avoid such resonances in the vicinity of the axis. Secondly, we note that the regular power series expansion (2.22) is not always guaranteed to be correct. The possibility of having weak logarithmic singularities on the axis in the form of $\rho ^n (\log \rho )^m, n>m>0$ has been pointed out in Weitzner (Reference Weitzner2016). Furthermore, functions such as $\alpha$
 has been pointed out in Weitzner (Reference Weitzner2016). Furthermore, functions such as $\alpha$ can not be represented in the analytic power series given by (2.23). In this work, we demonstrate that for a large class of equilibria, one can still construct a power series in $\rho$
 can not be represented in the analytic power series given by (2.23). In this work, we demonstrate that for a large class of equilibria, one can still construct a power series in $\rho$ valid to all orders in $\rho$
 valid to all orders in $\rho$ without encountering logarithmically singular terms. We also pay special attention to the multivalued function $\alpha, K$
 without encountering logarithmically singular terms. We also pay special attention to the multivalued function $\alpha, K$ and discuss their structure.
 and discuss their structure.
In the following, we discuss various limits of ideal MHS: vacuum, force-free and, finally, finite beta MHS equilibrium. We start with the vacuum limit because its mathematical structure is fundamental and the easiest to analyse. Subsequently, we will show that the force-free and MHS fields can be formulated in a form very similar to the vacuum fields.
3 The NAE of vacuum fields in Mercier–Weitzner formalism
 The NAE of vacuum fields in direct coordinates has been treated extensively in Jorge et al. (Reference Jorge, Sengupta and Landreman2020b). In the Mercier–Weitzner formalism, $K=0$ corresponds to the vacuum limit, and the analysis is similar to Jorge et al. (Reference Jorge, Sengupta and Landreman2020b), which also uses direct coordinates. However, a key point of departure of our present work from all other previous developments of NAE is the treatment of the Clebsch variable, which represents the field line label, $\alpha$
 corresponds to the vacuum limit, and the analysis is similar to Jorge et al. (Reference Jorge, Sengupta and Landreman2020b), which also uses direct coordinates. However, a key point of departure of our present work from all other previous developments of NAE is the treatment of the Clebsch variable, which represents the field line label, $\alpha$ . The primary motivation for focusing on $\alpha$
. The primary motivation for focusing on $\alpha$ is that the rotational transform and its derivatives (which includes the magnetic shear) are related directly to the secular part of $\alpha$
 is that the rotational transform and its derivatives (which includes the magnetic shear) are related directly to the secular part of $\alpha$ (through (2.11b)). Thus, a systematic construction of $\alpha$
 (through (2.11b)). Thus, a systematic construction of $\alpha$ is crucial.
 is crucial.
 Our goal in this section is to study the structure of the Mercier–Weitzner equations in the vacuum limit. First, we show how the condition of nested flux surfaces leads to MDEs. We then explicitly employ the NAE and elucidate the properties of the solutions obtained, paying particular attention to the secular and periodic structure of the field line label, $\alpha$ .
.
3.1 Basic equations and the need for an alternative set of equations
In the vacuum limit, the basic equilibrium equations (2.10) reduce to
 
Projecting (3.1) onto the orthonormal vectors $(\boldsymbol {\hat {\rho }},\boldsymbol {\hat {\omega }},\boldsymbol {\hat {\ell }})$ defined in (2.17a–c), we get
 defined in (2.17a–c), we get
 
 
 
Equation (3.2) is a closed set of equations that, in principle, can be solved for the three unknowns $(\varPhi,\psi,\alpha )$ . However, the coupling between the various quantities makes the system (3.2) difficult to tackle analytically in the direct coordinate approach to NAE. Therefore, instead of (3.2), we examine alternative equations that decouple $(\varPhi,\psi,\alpha )$
. However, the coupling between the various quantities makes the system (3.2) difficult to tackle analytically in the direct coordinate approach to NAE. Therefore, instead of (3.2), we examine alternative equations that decouple $(\varPhi,\psi,\alpha )$ as much as possible.
 as much as possible.
 To arrive at an alternative set of equations, we now look at the consistency conditions that directly follow from (3.2). To derive the first consistency condition, we differentiate (3.2b) and (3.2c) with respect to $\omega$ and $\ell$
 and $\ell$ , respectively, and add them. Using the commutativity of the cross-derivatives for the functions $\psi$
, respectively, and add them. Using the commutativity of the cross-derivatives for the functions $\psi$ and $\alpha$
 and $\alpha$ , we get a consistency condition
, we get a consistency condition
 
It follows from (3.2a) that (3.3) is nothing but the Laplace equation for $\varPhi$ ,
,
 
which also follows from $\boldsymbol {\nabla } \boldsymbol {\cdot } \boldsymbol {B} = \boldsymbol {\nabla } \boldsymbol {\cdot } \boldsymbol {\nabla } \varPhi =0$ .
.
Two other consistency conditions directly follow from (3.1) and are given by
 
 
One might suppose that the complete set (3.2) could be replaced by the new set of (3.4) and (3.5), which are the MDEs for $\psi$ and $\alpha$
 and $\alpha$ . The Laplace equation only involves $\varPhi$
. The Laplace equation only involves $\varPhi$ and the scale factors and is ideally suited for determining $\varPhi$
 and the scale factors and is ideally suited for determining $\varPhi$ . Once $\varPhi$
. Once $\varPhi$ is known, we might determine the Clebsch variables $(\psi,\alpha )$
 is known, we might determine the Clebsch variables $(\psi,\alpha )$ through (3.5a) and (3.5b). The benefit of using the characteristic equations, (3.5), is that $\psi$
 through (3.5a) and (3.5b). The benefit of using the characteristic equations, (3.5), is that $\psi$ and $\alpha$
 and $\alpha$ can be decoupled. However, several mathematical intricacies need to be addressed before replacing the complete set (3.2), which we now highlight.
 can be decoupled. However, several mathematical intricacies need to be addressed before replacing the complete set (3.2), which we now highlight.
 Firstly, (3.2) is a third-order system because it has three first-order derivatives in $(\rho,\omega,\ell )$ , while the Laplace equation is second order and so is (3.5) because of the two first derivatives. Therefore, the replacement of (3.2) by (3.4) and (3.5) raises the order by one since we have taken an additional derivative of the equations, which might lead to the inclusion of spurious solutions. Furthermore, the conditions (3.4), (3.5a) and (3.5b) are not completely independent when the equations are solved order by order. To see this, let us assume that the equations that govern the angular derivatives of $\varPhi$
, while the Laplace equation is second order and so is (3.5) because of the two first derivatives. Therefore, the replacement of (3.2) by (3.4) and (3.5) raises the order by one since we have taken an additional derivative of the equations, which might lead to the inclusion of spurious solutions. Furthermore, the conditions (3.4), (3.5a) and (3.5b) are not completely independent when the equations are solved order by order. To see this, let us assume that the equations that govern the angular derivatives of $\varPhi$ , (3.2b) and (3.2c), have been solved. It is then straightforward to see that the radial derivative of $\varPhi$
, (3.2b) and (3.2c), have been solved. It is then straightforward to see that the radial derivative of $\varPhi$ given by (3.2a) and characteristic equations (3.5a) and (3.5b) are not independent but are related through
 given by (3.2a) and characteristic equations (3.5a) and (3.5b) are not independent but are related through
 
As discussed in Appendix B, in order to retain the correct vacuum and MHS characteristics (Friedrichs & Kranzer Reference Friedrichs and Kranzer1958; Goedbloed Reference Goedbloed1983; Courant & Hilbert Reference Courant and Hilbert2008; Weitzner Reference Weitzner2014) we cannot simply replace the complete set (3.2) by the consistency conditions (3.4), (3.5a) and (3.5b). Fortunately, a workaround is possible that allows a partial decoupling of the variables $\varPhi,\psi,\alpha$ . In the following sections, we will provide a recipe to carry out the finite-beta NAE efficiently and self-consistently to arbitrary orders by choosing the right set of fundamental equations. We will justify all the necessary mathematical steps below.
. In the following sections, we will provide a recipe to carry out the finite-beta NAE efficiently and self-consistently to arbitrary orders by choosing the right set of fundamental equations. We will justify all the necessary mathematical steps below.
3.2 Alternative set of basic equations
 We first observe that the consistency condition (3.3) implies that if the $\omega$ and $\ell$
 and $\ell$ components of the basic vacuum equations (3.1), i.e. (3.2b) and (3.2c), are satisfied, the solution of the Laplace equation satisfies the $\rho$
 components of the basic vacuum equations (3.1), i.e. (3.2b) and (3.2c), are satisfied, the solution of the Laplace equation satisfies the $\rho$ component, (3.2a), up to an arbitrary function of $(\omega,\ell )$
 component, (3.2a), up to an arbitrary function of $(\omega,\ell )$ . Therefore, (3.2a) needs to be imposed to eliminate this arbitrariness. As can be seen from (3.6) (and further discussed later on), the equation for the radial derivative of $\varPhi$
. Therefore, (3.2a) needs to be imposed to eliminate this arbitrariness. As can be seen from (3.6) (and further discussed later on), the equation for the radial derivative of $\varPhi$ (3.2a) is identical to the MDE for $\psi$
 (3.2a) is identical to the MDE for $\psi$ (3.5a) order by order in $\rho$
 (3.5a) order by order in $\rho$ . Furthermore, it will be shown later that once (3.4) and (3.5a) (equivalently (3.2a)) are satisfied, the (3.2b) and (3.2c) are compatible, in the sense that either can be used to solve for $\alpha$
. Furthermore, it will be shown later that once (3.4) and (3.5a) (equivalently (3.2a)) are satisfied, the (3.2b) and (3.2c) are compatible, in the sense that either can be used to solve for $\alpha$ . We will find it more straightforward to use (3.2b) to solve for $\alpha$
. We will find it more straightforward to use (3.2b) to solve for $\alpha$ up to a function of $\ell$
 up to a function of $\ell$ by integrating with respect to $\omega$
 by integrating with respect to $\omega$ . The reason behind choosing (3.2b) over (3.2c) is that the $\varPhi$
. The reason behind choosing (3.2b) over (3.2c) is that the $\varPhi$ and $\psi$
 and $\psi$ can be shown to have a finite number of poloidal harmonics which depend only on the order of expansion, whereas no such restriction exists for the toroidal harmonics.
 can be shown to have a finite number of poloidal harmonics which depend only on the order of expansion, whereas no such restriction exists for the toroidal harmonics.
 Finally, to determine $\alpha$ fully, we need only the poloidal average of either (3.2c) or (3.5b). We use the latter because of the relevance of the MDE to calculating rotational transform and its higher derivatives. Note that the only MDE we solve is the MDE for $\psi$
 fully, we need only the poloidal average of either (3.2c) or (3.5b). We use the latter because of the relevance of the MDE to calculating rotational transform and its higher derivatives. Note that the only MDE we solve is the MDE for $\psi$ , (3.5a). We are not solving the MDE for $\alpha$
, (3.5a). We are not solving the MDE for $\alpha$ ; we are simply fixing the $\ell$
; we are simply fixing the $\ell$ dependent part of $\alpha$
 dependent part of $\alpha$ that was left undetermined because of the partial integration with respect to $\omega$
 that was left undetermined because of the partial integration with respect to $\omega$ . The procedure will be explained in detail in §§ 3.3–3.6.
. The procedure will be explained in detail in §§ 3.3–3.6.
 In summary, we have seen that equating the covariant and the contravariant representations of $\boldsymbol {B}$ , (2.2), in the vacuum limit leads to a complete set of (3.2). However, the variables $(\varPhi,\psi,\alpha )$
, (2.2), in the vacuum limit leads to a complete set of (3.2). However, the variables $(\varPhi,\psi,\alpha )$ are coupled nonlinearly, making (3.2), not the best set of equations to start the NAE programme in direct coordinates. The alternative is to solve the Laplace equation for $\varPhi$
 are coupled nonlinearly, making (3.2), not the best set of equations to start the NAE programme in direct coordinates. The alternative is to solve the Laplace equation for $\varPhi$ (3.4) and the MDE for $\psi$
 (3.4) and the MDE for $\psi$ (3.5a). We use the $\varPhi _{,\omega }$
 (3.5a). We use the $\varPhi _{,\omega }$ equation, (3.2b), to obtain $\alpha$
 equation, (3.2b), to obtain $\alpha$ up to a function of $\ell$
 up to a function of $\ell$ , which is then determined from the poloidally averaged MDE for $\alpha$
, which is then determined from the poloidally averaged MDE for $\alpha$ (3.5b). The Laplace equation does not introduce extraneous solutions because we are solving the MDE for $\psi$
 (3.5b). The Laplace equation does not introduce extraneous solutions because we are solving the MDE for $\psi$ , which is equivalent to solving (3.2a), as can be seen from (3.6). Furthermore, the Laplace equation is also the necessary solvability condition for the function $\alpha$
, which is equivalent to solving (3.2a), as can be seen from (3.6). Furthermore, the Laplace equation is also the necessary solvability condition for the function $\alpha$ .
.
3.3 Derivation of the vacuum NAE equations: the lowest order
 We now expand the quantities $(\varPhi,\psi,\alpha )$ in power series of $\rho$
 in power series of $\rho$ in the general form
 in the general form
 
 
 
The analysis of the lowest-order quantities is important for the subsequent development of the analysis. Therefore, we now discuss in some detail the lowest-order structure. Firstly, note that the expansion of $\psi$ starts at $\rho ^2$
 starts at $\rho ^2$ since we need $\psi$
 since we need $\psi$ to be zero on the axis. We also need $\psi _{,\rho }$
 to be zero on the axis. We also need $\psi _{,\rho }$ to vanish on the axis to ensure that the poloidal field, $B_\omega =(1/\rho )\varPhi _\omega \approx \psi _{,\rho }\alpha _{,\ell }$
 to vanish on the axis to ensure that the poloidal field, $B_\omega =(1/\rho )\varPhi _\omega \approx \psi _{,\rho }\alpha _{,\ell }$ , is also zero on the magnetic axis. Furthermore, the vanishing of the poloidal field on the axis also leads to the $O(1/\rho ^2)$
, is also zero on the magnetic axis. Furthermore, the vanishing of the poloidal field on the axis also leads to the $O(1/\rho ^2)$ and $O(1/\rho )$
 and $O(1/\rho )$ of the vacuum system (3.2c) to be satisfied provided
 of the vacuum system (3.2c) to be satisfied provided
 
We assume that the strength of the magnetic field on the axis is positive and single-valued, i.e.
 
To make $B_0(\ell )$ single-valued, $\varPhi ^{(0)}$
 single-valued, $\varPhi ^{(0)}$ must be of the form
 must be of the form
 
where, $\tilde {\varPhi }_0(\ell )$ is periodic in $\ell$
 is periodic in $\ell$ .
.
 Expanding the vacuum system (3.2) to $O(1)$ , we obtain the following coupled equations for $(\varPhi ^{(2)},\psi ^{(2)},\alpha ^{(0)})$
, we obtain the following coupled equations for $(\varPhi ^{(2)},\psi ^{(2)},\alpha ^{(0)})$ :
:
 
 
 
Multiplying (3.11a) by $2\psi ^{(2)}$ and using ((3.11b), (3.11c)) we get the following linear homogeneous equation for $\psi ^{(2)}$
 and using ((3.11b), (3.11c)) we get the following linear homogeneous equation for $\psi ^{(2)}$ :
:
 
To solve (3.12) we need $\varPhi ^{(2)}$ . The compatibility condition $\partial _\ell \alpha _{,\omega }^{(0)}=\partial _\omega \alpha _{,\ell }^{(0)}$
. The compatibility condition $\partial _\ell \alpha _{,\omega }^{(0)}=\partial _\omega \alpha _{,\ell }^{(0)}$ with the use of ((3.11b), (3.11c)) leads to the following Poisson equation for $\varPhi ^{(2)}$
 with the use of ((3.11b), (3.11c)) leads to the following Poisson equation for $\varPhi ^{(2)}$ :
:
 
Since (3.13) is a simple harmonic oscillator, its solution can be easily seen to be of the form
 
where, $f^{(2)}_{c2}(\ell ),f^{(2)}_{s2}(\ell )$ are the ‘integration constants’ with respect to the $\partial _\omega$
 are the ‘integration constants’ with respect to the $\partial _\omega$ operator. We have also chosen $u$
 operator. We have also chosen $u$ , defined by (2.18a,b), as the helical angle. Note that from the form of $\varPhi ^{(0)}$
, defined by (2.18a,b), as the helical angle. Note that from the form of $\varPhi ^{(0)}$ as given in (3.10a,b), $\varPhi ^{(2)}$
 as given in (3.10a,b), $\varPhi ^{(2)}$ can be made single-valued in $\ell$
 can be made single-valued in $\ell$ by ensuring that the integration constants are periodic. The function $\varPhi ^{(2)}_{,\omega }$
 by ensuring that the integration constants are periodic. The function $\varPhi ^{(2)}_{,\omega }$ obtained from (3.14) is harmonic with zero net poloidal average.
 obtained from (3.14) is harmonic with zero net poloidal average.
 The solution of the equation for $\psi ^{(2)}$ , (3.12), is of the form
, (3.12), is of the form
 
which can be checked by substituting (3.15) in (3.12) and collecting the poloidal harmonics $1,\cos {2u},\sin {2u}$ . Equating the coefficients of the various poloidal harmonics to zero, we get
. Equating the coefficients of the various poloidal harmonics to zero, we get
 
together with
 
Here $\eta (\ell )$ is an arbitrary function of $\ell$
 is an arbitrary function of $\ell$ . We require that $\left ( f^{(2)}_{c2}(\ell ),f^{(2)}_{s2}(\ell ) \right )$
. We require that $\left ( f^{(2)}_{c2}(\ell ),f^{(2)}_{s2}(\ell ) \right )$ are single-valued functions by requiring $\eta (\ell ),\delta '(\ell )$
 are single-valued functions by requiring $\eta (\ell ),\delta '(\ell )$ to be single-valued and periodic in $\ell$
 to be single-valued and periodic in $\ell$ . With this choice, we make both $\varPhi ^{(2)}, \psi ^{(2)}$
. With this choice, we make both $\varPhi ^{(2)}, \psi ^{(2)}$ single-valued functions. Later, we determine the constant $c_0$
 single-valued functions. Later, we determine the constant $c_0$ by imposing the choice of $\psi$
 by imposing the choice of $\psi$ as the toroidal flux. To see that this is indeed the only solution, we can divide the equations for the $\omega,\ell$
 as the toroidal flux. To see that this is indeed the only solution, we can divide the equations for the $\omega,\ell$ derivatives of $\alpha ^{(0)}$
 derivatives of $\alpha ^{(0)}$ , (3.11b) and (3.11c), by $2\psi ^{(2)}$
, (3.11b) and (3.11c), by $2\psi ^{(2)}$ and eliminate $\alpha ^{(0)}$
 and eliminate $\alpha ^{(0)}$ through cross-differentiation. The resultant consistency condition
 through cross-differentiation. The resultant consistency condition
 
is a linear PDE for $(1/\psi ^{(2)})$ with periodic boundary conditions in $\omega,\ell$
 with periodic boundary conditions in $\omega,\ell$ . Since the expression for $\psi ^{(2)}$
. Since the expression for $\psi ^{(2)}$ satisfies (3.18) and the periodic boundary conditions, it must be the unique solution.
 satisfies (3.18) and the periodic boundary conditions, it must be the unique solution.
 For the physical interpretation of the various functions $\eta (\ell ),\delta (\ell )$ , we refer to the excellent review article, Helander (Reference Helander2014). In short, the flux-surface shape obtained from the equation for $\psi ^{(2)}$
, we refer to the excellent review article, Helander (Reference Helander2014). In short, the flux-surface shape obtained from the equation for $\psi ^{(2)}$ (3.15) is a rotating ellipse. The function $\eta (\ell )$
 (3.15) is a rotating ellipse. The function $\eta (\ell )$ controls the ellipticity, while $\delta (\ell )$
 controls the ellipticity, while $\delta (\ell )$ measures its angle of rotation respect to the Frenet frame. We note that the choices of the free-functions in $f^{(2)}_{c2},f^{(2)}_{s2}$
 measures its angle of rotation respect to the Frenet frame. We note that the choices of the free-functions in $f^{(2)}_{c2},f^{(2)}_{s2}$ in (3.17a,b) were made in terms of the shaping parameters of the lowest-order flux-surface. Later, we make choices such that the interpretation of higher-order free-functions $\varPhi ^{(n+2)}_{c},\varPhi ^{(n+2)}_{s}$
 in (3.17a,b) were made in terms of the shaping parameters of the lowest-order flux-surface. Later, we make choices such that the interpretation of higher-order free-functions $\varPhi ^{(n+2)}_{c},\varPhi ^{(n+2)}_{s}$ can be made in terms of higher-order flux surface shapes $\psi ^{(n+2)}_{c},\psi ^{(n+2)}_{s}$
 can be made in terms of higher-order flux surface shapes $\psi ^{(n+2)}_{c},\psi ^{(n+2)}_{s}$ .
.
 It is possible to find special coordinates such that $\psi ^{(2)}$ is a circle in these coordinates. Since $\varPhi _0'=B_0>0$
 is a circle in these coordinates. Since $\varPhi _0'=B_0>0$ and $a(\ell )>b(\ell )\geq 0$
 and $a(\ell )>b(\ell )\geq 0$ , it follows that $\psi ^{(2)}$
, it follows that $\psi ^{(2)}$ is non-vanishing. As a result, we can define ‘rotating coordinates’ (Solov'ev & Shafranov Reference Solov'ev and Shafranov1970) or the leading-order ‘normal form’ coordinates
 is non-vanishing. As a result, we can define ‘rotating coordinates’ (Solov'ev & Shafranov Reference Solov'ev and Shafranov1970) or the leading-order ‘normal form’ coordinates
 
such that $\psi ^{(2)}$ , given by
, given by
 
is a circle in the $(x_\mathcal {N}\equiv X_\mathcal {N}/\rho,y_\mathcal {N}\equiv Y_\mathcal {N}/\rho )$ coordinates. The benefits of using the ‘normal form’ coordinates have been noted in Duignan & Meiss (Reference Duignan and Meiss2021). As shown in Appendix F, these coordinates are particularly useful in solving the coupled ODEs that result from the MDE for higher-order flux-surface shapes.
 coordinates. The benefits of using the ‘normal form’ coordinates have been noted in Duignan & Meiss (Reference Duignan and Meiss2021). As shown in Appendix F, these coordinates are particularly useful in solving the coupled ODEs that result from the MDE for higher-order flux-surface shapes.
 With $\varPhi ^{(2)}$ and $\psi ^{(2)}$
 and $\psi ^{(2)}$ in hand let us focus on obtaining $\alpha ^{(0)}$
 in hand let us focus on obtaining $\alpha ^{(0)}$ . Substituting the expressions for $\psi ^{(2)}$
. Substituting the expressions for $\psi ^{(2)}$ , (3.15), together with the expressions for $a,b$
, (3.15), together with the expressions for $a,b$ , (3.16a,b), in the equation for $\alpha ^{(0)}$
, (3.16a,b), in the equation for $\alpha ^{(0)}$ , (3.11b), and integrating with respect to $\omega$
, (3.11b), and integrating with respect to $\omega$ we get
 we get
 
To determine the unknown function $\mathfrak {a}^{(0)}(\ell )$ we only need the poloidally averaged (3.11c). Since $\varPhi ^{(2)}_{,\omega }$
 we only need the poloidally averaged (3.11c). Since $\varPhi ^{(2)}_{,\omega }$ has zero average, the poloidally averaged $\alpha ^{(0)}_{,\ell }$
 has zero average, the poloidally averaged $\alpha ^{(0)}_{,\ell }$ equation (3.11c) reads
 equation (3.11c) reads
 
Using the expressions for $\alpha ^{(0)},\psi ^{(2)}$ as given in (3.21) and (3.15), we can show that (3.22) yields
 as given in (3.21) and (3.15), we can show that (3.22) yields
 
Therefore,
 
 Let us briefly summarize the findings of NAE up to $O(1)$ . From the requirement that the poloidal magnetic field and the flux surface label vanish on the axis, we can determine $\varPhi ^{(0)},\varPhi ^{(1)}$
. From the requirement that the poloidal magnetic field and the flux surface label vanish on the axis, we can determine $\varPhi ^{(0)},\varPhi ^{(1)}$ to be as given in (3.8a,b). The vacuum system to $O(1)$
 to be as given in (3.8a,b). The vacuum system to $O(1)$ gives three coupled equations for $\varPhi ^{(2)},\psi ^{(2)},\alpha ^{(0)}$
 gives three coupled equations for $\varPhi ^{(2)},\psi ^{(2)},\alpha ^{(0)}$ . We have shown that these equations can be decoupled to yield a Poisson equation for $\phi ^{(2)}$
. We have shown that these equations can be decoupled to yield a Poisson equation for $\phi ^{(2)}$ , (3.13) and an MDE for $\psi ^{(2)}$
, (3.13) and an MDE for $\psi ^{(2)}$ , (3.12). The solutions $\varPhi ^{(2)},\psi ^{(2)}$
, (3.12). The solutions $\varPhi ^{(2)},\psi ^{(2)}$ , given in (3.14) and (3.15), can then be used to determine $\alpha ^{(0)}$
, given in (3.14) and (3.15), can then be used to determine $\alpha ^{(0)}$ , which is given in (3.24) up to an overall constant. With the help of these lowest-order expressions, we now carry out the expansion to $O(n)$
, which is given in (3.24) up to an overall constant. With the help of these lowest-order expressions, we now carry out the expansion to $O(n)$ in the next section, where we demonstrate that at $O(\rho ^n)$
 in the next section, where we demonstrate that at $O(\rho ^n)$ , an analogous decoupling of the higher-order quantities $(\varPhi ^{(n+2)},\psi ^{(n+2)},\alpha ^{(n)})$
, an analogous decoupling of the higher-order quantities $(\varPhi ^{(n+2)},\psi ^{(n+2)},\alpha ^{(n)})$ is possible.
 is possible.
3.4 Derivation of the vacuum NAE equations: $n{\text {th}}$ order
 order
 The system (3.2) to $O(n)$ leads to the following closed set of equations:
 leads to the following closed set of equations:
 
 
 
where $\cdots$ refers to terms involving the lower-order known quantities.
 refers to terms involving the lower-order known quantities.
 Although (3.25) is linear in $(\varPhi ^{(n+2)},\psi ^{(n+2)},\alpha ^{(n)})$ , it still couples these functions in a complicated manner. As discussed in § 3.1, an alternate approach to solving the system (3.25) is the system comprising of the Poisson equation for $\varPhi ^{(n+2)}$
, it still couples these functions in a complicated manner. As discussed in § 3.1, an alternate approach to solving the system (3.25) is the system comprising of the Poisson equation for $\varPhi ^{(n+2)}$ , the MDE for $\psi ^{(n+2)}$
, the MDE for $\psi ^{(n+2)}$ , (3.25b), and finally, the averaged MDE for $\alpha ^{(n)}$
, (3.25b), and finally, the averaged MDE for $\alpha ^{(n)}$ to determine $\alpha ^{(n)}$
 to determine $\alpha ^{(n)}$ completely. In this section, we show how these alternative equations are equivalent to the complete set (3.25).
 completely. In this section, we show how these alternative equations are equivalent to the complete set (3.25).
 Expanding the equation relating the $\varPhi _{,\rho }$ equation and the MDEs for $\psi,\alpha$
 equation and the MDEs for $\psi,\alpha$ , (3.6), to $O(n)$
, (3.6), to $O(n)$ we observe that the equation for $\psi ^{(n+2)}$
 we observe that the equation for $\psi ^{(n+2)}$ as given in (3.25a) is equivalent to the $O(n)$
 as given in (3.25a) is equivalent to the $O(n)$ MDE for $\psi ^{(n+2)}$
 MDE for $\psi ^{(n+2)}$ . However, the solution of the MDE for $\psi ^{(n+2)}$
. However, the solution of the MDE for $\psi ^{(n+2)}$ does not uniquely determine $\psi ^{(n+2)}$
 does not uniquely determine $\psi ^{(n+2)}$ since a homogeneous solution that satisfies $\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla }\psi$
 since a homogeneous solution that satisfies $\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla }\psi$ to $O(n+2)$
 to $O(n+2)$ can always be added to it. We show later that imposing the choice of $2{\rm \pi} \psi$
 can always be added to it. We show later that imposing the choice of $2{\rm \pi} \psi$ to be the toroidal flux, order by order, determines the homogeneous piece of $\psi$
 to be the toroidal flux, order by order, determines the homogeneous piece of $\psi$ .
.
 To solve the MDE for $\psi ^{(n+2)}$ or equivalently (3.25a) we need $\varPhi ^{(n+2)}$
 or equivalently (3.25a) we need $\varPhi ^{(n+2)}$ as evident from the right-hand side of (3.25a). We have demonstrated in § 3.1 that the Laplace equation for $\varPhi$
 as evident from the right-hand side of (3.25a). We have demonstrated in § 3.1 that the Laplace equation for $\varPhi$ arises as an exact compatibility condition of (3.2b) and (3.2c), provided (3.2a) holds. The same procedure works in higher orders as well. To $O(n)$
 arises as an exact compatibility condition of (3.2b) and (3.2c), provided (3.2a) holds. The same procedure works in higher orders as well. To $O(n)$ , elimination of $\alpha ^{(n)}$
, elimination of $\alpha ^{(n)}$ from (3.25b) and (3.25c) through cross-differentiation, i.e. $\partial _\ell$
 from (3.25b) and (3.25c) through cross-differentiation, i.e. $\partial _\ell$ (3.25c)$+ \partial _\omega$
 (3.25c)$+ \partial _\omega$ (3.25b), followed by elimination of the derivatives of $\psi ^{(n+2)}$
 (3.25b), followed by elimination of the derivatives of $\psi ^{(n+2)}$ using (3.25a), leads to an equation for $\varPhi ^{(n+2)}$
 using (3.25a), leads to an equation for $\varPhi ^{(n+2)}$ of the form
 of the form
 
where $F^{(n+2)}_\varPhi$ denotes known inhomogeneous forcing terms from lower-order quantities. Note that (3.26) is simply the Laplace equation for $\varPhi$
 denotes known inhomogeneous forcing terms from lower-order quantities. Note that (3.26) is simply the Laplace equation for $\varPhi$ to $O(n+2)$
 to $O(n+2)$ that leads to a Poisson equation for $\varPhi ^{(n+2)}$
 that leads to a Poisson equation for $\varPhi ^{(n+2)}$ .
.
 Now that the equation for its angular derivatives (3.25b) and (3.25c) are compatible thanks to (3.26), we use (3.25b) to solve for $\left ( \alpha ^{(n)}\right )/\left ( 2\psi ^{(2)}\right )^{n/2}$ up to an arbitrary function of $\ell$
 up to an arbitrary function of $\ell$ say $\mathfrak {\bar {a}}^{(n)}(\ell )$
 say $\mathfrak {\bar {a}}^{(n)}(\ell )$ . To determine $\mathfrak {\bar {a}}^{(n)}(\ell )$
. To determine $\mathfrak {\bar {a}}^{(n)}(\ell )$ we need the poloidally averaged MDE for $\alpha ^{(n)}$
 we need the poloidally averaged MDE for $\alpha ^{(n)}$ . The MDE for $\alpha ^{(n)}$
. The MDE for $\alpha ^{(n)}$ can be obtained through an algebraic combination of (3.25b) and (3.25c) that eliminates $\psi ^{(n+2)}$
 can be obtained through an algebraic combination of (3.25b) and (3.25c) that eliminates $\psi ^{(n+2)}$ . It reads
. It reads
 
Thus, we have derived an alternate set of equations which decouples $\varPhi ^{(n+2)},\psi ^{(n+2)},\alpha ^{(n)}$ . The next step is to impose the periodicity constraint (2.11). To understand the nature of the constraints (2.11) in a torus, it turns out that inverse coordinates, where $\psi$
. The next step is to impose the periodicity constraint (2.11). To understand the nature of the constraints (2.11) in a torus, it turns out that inverse coordinates, where $\psi$ is used as the radial coordinate, are ideally suited. Connecting the direct and the inverse coordinates enables us to establish a direct relation between higher derivatives of the rotational transform, $\iota$
 is used as the radial coordinate, are ideally suited. Connecting the direct and the inverse coordinates enables us to establish a direct relation between higher derivatives of the rotational transform, $\iota$ , and the secular pieces of $\alpha ^{(n)}$
, and the secular pieces of $\alpha ^{(n)}$ . Therefore, in § 3.5, we discuss the map between the direct and the inverse to understand the periodicity constraints better.
. Therefore, in § 3.5, we discuss the map between the direct and the inverse to understand the periodicity constraints better.
 In what follows, our strategy would be to solve the following equations for $(\varPhi ^{(n+2)},\psi ^{(n+2)},\alpha ^{(n)})$ :
:
- (I) the Poisson equation (3.26) for $\varPhi ^{(n+2)}$  ; ;
- (II) the MDE for $\psi ^{(n+2)}$  (3.25a); (3.25a);
- (III) the $\alpha _{,\omega }$  equation (3.25b) to solve for $\alpha ^{(n)}$ equation (3.25b) to solve for $\alpha ^{(n)}$ up to a function $\mathfrak {\bar {a}}^{(n)}(\ell )$ up to a function $\mathfrak {\bar {a}}^{(n)}(\ell )$ ; ;
- (IV) the poloidal $\omega$  average of the MDE for $\alpha$ average of the MDE for $\alpha$ (3.27) to determine $\mathfrak {\bar {a}}^{(n)}(\ell )$ (3.27) to determine $\mathfrak {\bar {a}}^{(n)}(\ell )$ . .
Adding currents and plasma beta does not appreciably change the overall structure, as we show later. Therefore, a thorough understanding of the mathematical structure of the vacuum system (I–IV) and its solution is of merit and will be discussed in detail in the next few sections.
 We discuss boundary conditions for Steps I–IV, derived from the periodicity requirements of physical quantities in the poloidal and toroidal angles, in § 3.5. Then we discuss the solutions to the Poisson equation (3.26) in § 3.6.1, the MDE for $\psi ^{(n+2)}$ in § 3.6.3 and in § 3.6.5 we provide the details of obtaining $\alpha$
 in § 3.6.3 and in § 3.6.5 we provide the details of obtaining $\alpha$ following Steps III and IV.
 following Steps III and IV.
3.5 Derivation of the vacuum NAE equations: boundary conditions in toroidal geometry and periodicity constraints
 To obtain solutions of the equations (Steps I–IV) in a torus, we need to impose double periodicity in the two angles and regularity in the radial coordinate near the axis. In § 2, we presented the secular and periodic pieces of $\varPhi,\alpha$ in (2.11) in the inverse coordinates. The structure of the functions of $\varPhi,\psi,\alpha$
 in (2.11) in the inverse coordinates. The structure of the functions of $\varPhi,\psi,\alpha$ follows from the physical requirement that $\boldsymbol {J},\boldsymbol {B}$
 follows from the physical requirement that $\boldsymbol {J},\boldsymbol {B}$ be periodic in a torus. Since the Mercier direct coordinates do not use the flux-surface label as a coordinate, separating secular and periodic parts of the multivalued functions $\varPhi,\alpha$
 be periodic in a torus. Since the Mercier direct coordinates do not use the flux-surface label as a coordinate, separating secular and periodic parts of the multivalued functions $\varPhi,\alpha$ is challenging. In particular, the form of $\alpha$
 is challenging. In particular, the form of $\alpha$ is crucial for understanding the MDEs. Hence, before discussing how to solve the equations, we need to understand the periodicity constraints in the direct coordinates.
 is crucial for understanding the MDEs. Hence, before discussing how to solve the equations, we need to understand the periodicity constraints in the direct coordinates.
 With the choice of $2{\rm \pi} \psi$ to be the toroidal flux, we get the following expression for vacuum $(\alpha,\varPhi )$
 to be the toroidal flux, we get the following expression for vacuum $(\alpha,\varPhi )$ from (2.11):
 from (2.11):
 
To work out the NAE in inverse Mercier coordinates $(\psi,\omega,\phi =\ell / L)$ one needs to invert the function $\psi (\rho,\omega,\ell )$
 one needs to invert the function $\psi (\rho,\omega,\ell )$ to obtain $\rho (\psi,\omega,\ell )$
 to obtain $\rho (\psi,\omega,\ell )$ . Equivalently one needs to invert the NAE for $\psi$
. Equivalently one needs to invert the NAE for $\psi$ (3.7c) to obtain an expression for $\rho$
 (3.7c) to obtain an expression for $\rho$ as a power series in $\sqrt {2\psi }$
 as a power series in $\sqrt {2\psi }$ . We can asymptotically invert the power series of $\psi$
. We can asymptotically invert the power series of $\psi$ in $\rho$
 in $\rho$ to obtain
 to obtain
 
Let us first focus on the field-line label $\alpha$ . The NAE of $\alpha$
. The NAE of $\alpha$ in the inverse (denoted by subscripts) and the direct (denoted by superscripts) coordinates,
 in the inverse (denoted by subscripts) and the direct (denoted by superscripts) coordinates,
 
 
are, therefore, connected through the relations
 
where, $\mathcal {P}_{m(n-1)}$ is a polynomial of order $(n-1)$
 is a polynomial of order $(n-1)$ whose arguments are $\left ( \psi ^{(j)}/\left ( \psi ^{(2)}\right )^{j/2} \right )$
 whose arguments are $\left ( \psi ^{(j)}/\left ( \psi ^{(2)}\right )^{j/2} \right )$ with $2\leq j\leq m+1$
 with $2\leq j\leq m+1$ . Expanding $\iota (\psi )$
. Expanding $\iota (\psi )$ in a Taylor series in $\psi$
 in a Taylor series in $\psi$ near the axis,
 near the axis,
 
and using the form of $\alpha$ in the inverse coordinates as given in (2.11), we find that
 in the inverse coordinates as given in (2.11), we find that
 
where $\tilde {\alpha }_k, k=0,1,2$ denotes functions periodic in the angles. Averaging the $\omega,\ell$
 denotes functions periodic in the angles. Averaging the $\omega,\ell$ derivatives of $\alpha _{2k}$
 derivatives of $\alpha _{2k}$ from (3.33a–d) over $\omega$
 from (3.33a–d) over $\omega$ and $\ell$
 and $\ell$ , and exploiting the periodicity of $\tilde {\alpha }_k$
, and exploiting the periodicity of $\tilde {\alpha }_k$ , we find that
, we find that
 
where, $\delta _{2k}=0$ for $k>0$
 for $k>0$ and $1$
 and $1$ for $k=0$
 for $k=0$ .
.
 We are now in a position to determine the constant $c_0$ in (3.16a,b). To do so, we impose the choice of $2{\rm \pi} \psi$
 in (3.16a,b). To do so, we impose the choice of $2{\rm \pi} \psi$ as the toroidal flux (equivalently $f(\psi )=1$
 as the toroidal flux (equivalently $f(\psi )=1$ in (2.11b)), order by order, by insisting that the secular $\theta$
 in (2.11b)), order by order, by insisting that the secular $\theta$ piece only appears in $\alpha ^{(0)}$
 piece only appears in $\alpha ^{(0)}$ as shown in (3.33a–d). Here, we note that (3.33a–d) implies that the average of $\alpha _{,\omega }^{(0)}$
 as shown in (3.33a–d). Here, we note that (3.33a–d) implies that the average of $\alpha _{,\omega }^{(0)}$ must be unity.
 must be unity.
 Using the form of $\alpha ^{(0)}$ obtained in (3.24) and averaging over $\omega$
 obtained in (3.24) and averaging over $\omega$ , we obtain the average $\alpha _{,\omega }^{(0)}$
, we obtain the average $\alpha _{,\omega }^{(0)}$ in the following form:
 in the following form:
 
Here, we have used (3.11b) for $\alpha ^{(0)}_{,\omega }$ , (3.15) for the functional form of $\psi ^{(2)}$
, (3.15) for the functional form of $\psi ^{(2)}$ , and (3.16a,b) to define
, and (3.16a,b) to define
 
Replacing the $\omega$ integral by a $u$
 integral by a $u$ integral, using the identity
 integral, using the identity
 
and finally imposing the condition that the average of $\alpha _{,\omega }^{(0)}$ must be unity, we find that
 must be unity, we find that
 
Therefore, the expression for $\alpha ^{(0)}$ , (3.24), now reads
, (3.24), now reads
 
The on-axis rotational transform can be obtained from (3.39) by utilizing
 
where we have defined
 
The extra integer $N$ comes from the rotation of the Frenet frame (Helander Reference Helander2014).
 comes from the rotation of the Frenet frame (Helander Reference Helander2014).
 We now explicitly derive the periodicity conditions in the direct coordinates. Firstly, every $\psi ^{(m+2)}, m=0,1,2,\ldots$ needs to be single-valued so that the flux-surface label $\psi$
 needs to be single-valued so that the flux-surface label $\psi$ is single-valued. Secondly, by substituting the relation between the components of $\alpha$
 is single-valued. Secondly, by substituting the relation between the components of $\alpha$ in the inverse representation $\alpha _n$
 in the inverse representation $\alpha _n$ and the direct representation $\alpha ^{(n)}$
 and the direct representation $\alpha ^{(n)}$ as given in (3.33a–d) into the identities (3.34a,b), we get
 as given in (3.33a–d) into the identities (3.34a,b), we get
 
Returning to the discussion of the multivalued structure of $\varPhi$ , we note that the analysis is almost identical to that of $\alpha$
, we note that the analysis is almost identical to that of $\alpha$ . The analogues of the relation between inverse and direct components (3.30), and the order by order form in inverse-coordinates (3.31) for $\varPhi$
. The analogues of the relation between inverse and direct components (3.30), and the order by order form in inverse-coordinates (3.31) for $\varPhi$ are obtained by simply replacing $\alpha$
 are obtained by simply replacing $\alpha$ by $\varPhi$
 by $\varPhi$ . An important difference between $\varPhi$
. An important difference between $\varPhi$ and $\alpha$
 and $\alpha$ occurs because in vacuum $G_0$
 occurs because in vacuum $G_0$ in (3.28a,b) is a constant. Therefore, we have
 in (3.28a,b) is a constant. Therefore, we have
 
which implies that except for $\varPhi ^{(0)}$ , all other $\varPhi ^{(n)}$
, all other $\varPhi ^{(n)}$ are periodic since $\psi ^{(2)}$
 are periodic since $\psi ^{(2)}$ is periodic. Single valuedness of $\varPhi ^{(n)}, n>0$
 is periodic. Single valuedness of $\varPhi ^{(n)}, n>0$ follows from the Laplace equation as will be shown in § 3.6.1.
 follows from the Laplace equation as will be shown in § 3.6.1.
 To summarize, we have deduced the periodicity constraints on $(\varPhi ^{(n+2)},\psi ^{(n+2)},\alpha ^{(n)})$ in this section by connecting to the inverse coordinates. The flux label $\psi ^{(n+2)}$
 in this section by connecting to the inverse coordinates. The flux label $\psi ^{(n+2)}$ must be periodic in both angles on a torus. In the inverse coordinates, the general periodicity requirement on $\varPhi,\alpha$
 must be periodic in both angles on a torus. In the inverse coordinates, the general periodicity requirement on $\varPhi,\alpha$ is given by (3.28a,b) and order by order the requirement is (3.33a–d) together with (3.43). In the direct coordinates, the periodicity constraints are given by (3.42) and single valuedness of $\varPhi ^{(n+2)}$
 is given by (3.28a,b) and order by order the requirement is (3.33a–d) together with (3.43). In the direct coordinates, the periodicity constraints are given by (3.42) and single valuedness of $\varPhi ^{(n+2)}$ for all $n>0$
 for all $n>0$ .
.
3.6 Solutions of the vacuum NAE equations to $O(n)$
 Our goal now is to analyse the harmonic contents of $(\varPhi ^{(n+2)},\psi ^{(n+2)},\alpha ^{(n)})$ . The structure of the vacuum potential $\varPhi$
. The structure of the vacuum potential $\varPhi$ was analysed in detail in Jorge et al. (Reference Jorge, Sengupta and Landreman2020b). We briefly summarize some of the relevant results here. To analyse the harmonic content of $\psi ^{(n+2)}$
 was analysed in detail in Jorge et al. (Reference Jorge, Sengupta and Landreman2020b). We briefly summarize some of the relevant results here. To analyse the harmonic content of $\psi ^{(n+2)}$ and $\alpha ^{(n)}$
 and $\alpha ^{(n)}$ , we study the structure and properties of MDEs in the next sections.
, we study the structure and properties of MDEs in the next sections.
3.6.1 Solution of Step I: the Poisson equation for $\varPhi ^{(n+2)}$
 The Laplace equation to $O(n)$ is
 is
 
As shown in Jorge et al. (Reference Jorge, Sengupta and Landreman2020b), the right-hand side of (3.44) has at most harmonic terms of order $(n)$ . If the $(n+2)$
. If the $(n+2)$ th poloidal harmonics were present in the forcing term of (3.44), the inversion of (3.44) would lead to linear (hence secular) $\omega$
th poloidal harmonics were present in the forcing term of (3.44), the inversion of (3.44) would lead to linear (hence secular) $\omega$ terms in $\varPhi ^{(n+2)}$
 terms in $\varPhi ^{(n+2)}$ . Absence of $(n+2)$
. Absence of $(n+2)$ forcing poloidal harmonics implies that $\varPhi ^{(n+2)}$
 forcing poloidal harmonics implies that $\varPhi ^{(n+2)}$ has poloidal up to $n+2$
 has poloidal up to $n+2$ , with the coefficients of $(n+2){\textrm {th}}$
, with the coefficients of $(n+2){\textrm {th}}$ harmonics being free.
 harmonics being free.
 Therefore, we can write down the solution of $\varPhi ^{(n+2)}$ as
 as
 
where, $u$ is defined by (2.18a,b). For even $n$
 is defined by (2.18a,b). For even $n$ , $j=2r$
, $j=2r$ and $r$
 and $r$ varies from $0$
 varies from $0$ to $(n/2+1)$
 to $(n/2+1)$ . For odd $n$
. For odd $n$ , $j=2r+1$
, $j=2r+1$ and $r$
 and $r$ varies from $0$
 varies from $0$ to $(n+1)/2$
 to $(n+1)/2$ . The functions $\varPhi ^{(n+2)}_{c(n+2)}(\ell ),\varPhi ^{(n+2)}_{s(n+2)}(\ell )$
. The functions $\varPhi ^{(n+2)}_{c(n+2)}(\ell ),\varPhi ^{(n+2)}_{s(n+2)}(\ell )$ are the ‘free functions’, and the rest are completely determined by the lower-order quantities.
 are the ‘free functions’, and the rest are completely determined by the lower-order quantities.
 We now ensure that derivatives of $\varPhi ^{(n+2)}$ are single-valued since they are physically related directly to the components of the magnetic field. The right-hand side is manifestly periodic in the poloidal angle. Therefore, periodicity in the poloidal angle is maintained order by order. Let us now check for periodicity in $\ell$
 are single-valued since they are physically related directly to the components of the magnetic field. The right-hand side is manifestly periodic in the poloidal angle. Therefore, periodicity in the poloidal angle is maintained order by order. Let us now check for periodicity in $\ell$ . The presence of $\varPhi ^{(n-m+1)}$
. The presence of $\varPhi ^{(n-m+1)}$ without derivatives in the forcing term on the right-hand side of (3.45) might suggest that $\varPhi ^{(n+2)}$
 without derivatives in the forcing term on the right-hand side of (3.45) might suggest that $\varPhi ^{(n+2)}$ is not periodic since $\varPhi ^{(0)}$
 is not periodic since $\varPhi ^{(0)}$ is multivalued in $\ell$
 is multivalued in $\ell$ after all. However, $\varPhi ^{(0)}$
 after all. However, $\varPhi ^{(0)}$ never appears without any derivative in the forcing term. To have $\varPhi ^{(0)}$
 never appears without any derivative in the forcing term. To have $\varPhi ^{(0)}$ , we must have $m=n+1$
, we must have $m=n+1$ , which is outside the summation range. Furthermore, $\varPhi ^{(1)}=0$
, which is outside the summation range. Furthermore, $\varPhi ^{(1)}=0$ implies that for any $n$
 implies that for any $n$ , the lowest non-trivial term of the form $\varPhi ^{(n-m+1)}$
, the lowest non-trivial term of the form $\varPhi ^{(n-m+1)}$ is $\varPhi ^{(2)}$
 is $\varPhi ^{(2)}$ for $m=n-1$
 for $m=n-1$ , which is periodic. Therefore, the forcing term in (3.44) is a linear superposition of derivatives of $(\varPhi ^{(0)},\varPhi ^{(2)},\ldots,\varPhi ^{(m)})$
, which is periodic. Therefore, the forcing term in (3.44) is a linear superposition of derivatives of $(\varPhi ^{(0)},\varPhi ^{(2)},\ldots,\varPhi ^{(m)})$ and $\varPhi ^{m}$
 and $\varPhi ^{m}$ terms with $m>0$
 terms with $m>0$ . By induction $\varPhi ^{(n+2)}$
. By induction $\varPhi ^{(n+2)}$ must be single-valued for all $n>0$
 must be single-valued for all $n>0$ as required by (3.43).
 as required by (3.43).
This completes our solution of Step I. The solution of Step II is more involved and will be developed over the next few sections.
3.6.2 Solution of Step II: analysis of the general MDE
 To solve the MDE for $\psi$ in Step II, we need to discuss some properties of the MDE. In this section, we shall derive these properties for a general vacuum MDE.
 in Step II, we need to discuss some properties of the MDE. In this section, we shall derive these properties for a general vacuum MDE.
 The MDE (Newcomb Reference Newcomb1959) for a quantity $\chi$ takes the general form
 takes the general form
 
where $F_\chi$ is the forcing (or the inhomogeneous) term. Expressing the components of $\boldsymbol {B}$
 is the forcing (or the inhomogeneous) term. Expressing the components of $\boldsymbol {B}$ in (3.46) in terms of derivatives of the scalar potential $\varPhi$
 in (3.46) in terms of derivatives of the scalar potential $\varPhi$ , the MDO can be written as
, the MDO can be written as
 
Expanding in powers of $\rho$ and using the expressions for $\varPhi ^{(0)}, \varPhi ^{(1)}$
 and using the expressions for $\varPhi ^{(0)}, \varPhi ^{(1)}$ from (3.8a,b), we find that (3.46) takes the form
 from (3.8a,b), we find that (3.46) takes the form
 
where
 
The term $\mathfrak {f}^{(n)}_\chi$ consists of $\chi ^{(n-1)}$
 consists of $\chi ^{(n-1)}$ and other lower-order quantities obtained from both $F_\chi$
 and other lower-order quantities obtained from both $F_\chi$ and $\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla } \chi$
 and $\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla } \chi$ expanded to $O(n)$
 expanded to $O(n)$ . Note also that the definition of the lowest order MDO depends on the order $n$
. Note also that the definition of the lowest order MDO depends on the order $n$ due to the $\partial _\rho$
 due to the $\partial _\rho$ operator in (3.47). Clearly, for $n=2$
 operator in (3.47). Clearly, for $n=2$ , $\psi ^{(2)}$
, $\psi ^{(2)}$ is a homogeneous solution of (3.48), as claimed earlier.
 is a homogeneous solution of (3.48), as claimed earlier.
Unsurprisingly, we will find the MDO (3.49) repeatedly in this work. We shall therefore record a few essential properties of the MDO before we continue with the analysis of the MDE (3.48).
The first important property to note is that an alternate form of the MDO is given by
 
where, $\{f,g\}_{(\omega,\ell )}$ denotes a standard Poisson bracket of functions $f$
 denotes a standard Poisson bracket of functions $f$ and $g$
 and $g$ with respect to $(\omega,\ell )$
 with respect to $(\omega,\ell )$ . The form (3.50) follows from the definition of MDO (3.49), the equation for $\psi ^{(2)}$
. The form (3.50) follows from the definition of MDO (3.49), the equation for $\psi ^{(2)}$ (3.12) and the relations (3.11) that are satisfied by $(\varPhi ^{(2)},\alpha ^{(0)},\psi ^{(2)})$
 (3.12) and the relations (3.11) that are satisfied by $(\varPhi ^{(2)},\alpha ^{(0)},\psi ^{(2)})$ .
.
 The Poisson-bracket form of the MDO, (3.50), allows us to readily find the homogeneous solutions of the MDE (3.48). Thus, if $\chi ^{(n)}_h$ is a homogeneous solution of (3.48), it must be of the form
 is a homogeneous solution of (3.48), it must be of the form
 
When the rotational transform is irrational, $\mathcal {C}_h$ must be a constant if $\chi ^{(n)}_h$
 must be a constant if $\chi ^{(n)}_h$ represents a physical quantity.
 represents a physical quantity.
 The next important property of the MDO (3.50) is that it possesses an annihilator (an operator to whose kernel $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(n)}_0$ belongs). To obtain the annihilator, we use the following property of the Poisson bracket
 belongs). To obtain the annihilator, we use the following property of the Poisson bracket
 
Here we have used the fact that $\alpha _{,\omega }^{(0)},\alpha _{,\ell }^{(0)}$ are single-valued in order to commute the partial derivatives $\partial _\ell,\partial _\omega$
 are single-valued in order to commute the partial derivatives $\partial _\ell,\partial _\omega$ acting on $\alpha ^{(0)}$
 acting on $\alpha ^{(0)}$ in (3.52). Averaging (3.52) over $(\omega,\ell )$
 in (3.52). Averaging (3.52) over $(\omega,\ell )$ we get
 we get
 
provided $\chi$ is single-valued. Therefore, the operator
 is single-valued. Therefore, the operator
 
is an annihilator for the MDO (3.50). Note that the factor of $2{\rm \pi}$ below $\textrm {d}\ell$
 below $\textrm {d}\ell$ is because (3.50) has a derivative with respect to $\ell$
 is because (3.50) has a derivative with respect to $\ell$ . When written in terms of $\phi =2{\rm \pi} \ell /L$
. When written in terms of $\phi =2{\rm \pi} \ell /L$ , the factor of $2{\rm \pi}$
, the factor of $2{\rm \pi}$ turns out to be the usual measure.
 turns out to be the usual measure.
 Finally, we must discuss the poloidal harmonics generated when the MDO acts on the $n{\textrm {th}}$ harmonics. This property is essential in order to solve the MDE order by order. In the inverse coordinate approach, one can use analyticity to show that there is an upper bound on the poloidal harmonics at each order. In the direct coordinate approach, the upper bound on the poloidal harmonics is not evident since various powers of $\left ( \psi ^{(2)}\right )$
 harmonics. This property is essential in order to solve the MDE order by order. In the inverse coordinate approach, one can use analyticity to show that there is an upper bound on the poloidal harmonics at each order. In the direct coordinate approach, the upper bound on the poloidal harmonics is not evident since various powers of $\left ( \psi ^{(2)}\right )$ appear in the MDO (3.50) and its annihilator (3.54).
 appear in the MDO (3.50) and its annihilator (3.54).
 To deduce the poloidal harmonic content of $\chi ^{(n)}$ that satisfies the MDE (3.48), we will need another important property of the MDO (3.49). Let us consider a generic periodic function $\chi ^{(n)}_j$
 that satisfies the MDE (3.48), we will need another important property of the MDO (3.49). Let us consider a generic periodic function $\chi ^{(n)}_j$ of the form
 of the form
 
with $u(\omega,\ell )$ defined in (2.18a,b). The integer $j$
 defined in (2.18a,b). The integer $j$ such that $2\leq j \leq n$
 such that $2\leq j \leq n$ , is even (odd) if n is even (odd). Using (3.14) and (3.15) we can show that
, is even (odd) if n is even (odd). Using (3.14) and (3.15) we can show that
 
 
 
 
 
 We note, in particular, that for $j=n$ , there are no terms with $(n+2)$
, there are no terms with $(n+2)$ poloidal harmonics. Thus, for a function of the form (3.55), i.e. with $j{\textrm {th}}$
 poloidal harmonics. Thus, for a function of the form (3.55), i.e. with $j{\textrm {th}}$ poloidal harmonics in $u$
 poloidal harmonics in $u$ , where $j$
, where $j$ has the same parity as $n$
 has the same parity as $n$ and $0\leq j\leq n$
 and $0\leq j\leq n$ , $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(n)}_0 \chi ^{(n)}_j$
, $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(n)}_0 \chi ^{(n)}_j$ is a function with poloidal harmonics strictly between $j-2$
 is a function with poloidal harmonics strictly between $j-2$ and $\min {(j+2,n)}$
 and $\min {(j+2,n)}$ .
.
 Now let us define a function $\chi ^{(n)}=\sum _j \chi ^{(n)}_j$ such that
 such that
 
where, $\chi ^{(n)}_j$ 's for all $j,n$
's for all $j,n$ are of the form (3.55), $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(n)}_0\chi ^{(n)}$
 are of the form (3.55), $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(n)}_0\chi ^{(n)}$ will have even (odd) poloidal harmonics only up to $n$
 will have even (odd) poloidal harmonics only up to $n$ for even (odd) values of $n$
 for even (odd) values of $n$ . If we are given a function $\mathfrak {f}^{(n)}_\chi$
. If we are given a function $\mathfrak {f}^{(n)}_\chi$ , such that
, such that
 
the solution of
 
is obtained by solving the coupled ODEs obtained by equating to zero the sum of the $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(n)}_0 \chi ^{(n)}$ terms given in (3.56) and the $\mathfrak {f}^{(n)}_\chi$
 terms given in (3.56) and the $\mathfrak {f}^{(n)}_\chi$ terms given in (3.58).
 terms given in (3.58).
 We want to emphasize that without the property that no $(n+2)$ poloidal harmonics are generated when the MDO acts on the $n{\textrm {th}}$
 poloidal harmonics are generated when the MDO acts on the $n{\textrm {th}}$ harmonics, there would be no guarantee of an upper bound on the number of poloidal harmonics in $u$
 harmonics, there would be no guarantee of an upper bound on the number of poloidal harmonics in $u$ . Thanks to this property, a forcing term $\mathfrak {f}^{(n)}_\chi$
. Thanks to this property, a forcing term $\mathfrak {f}^{(n)}_\chi$ that has $n$
 that has $n$ poloidal harmonics will lead to a solution $\chi ^{(n)}$
 poloidal harmonics will lead to a solution $\chi ^{(n)}$ , which also has at most $n$
, which also has at most $n$ poloidal harmonics.
 poloidal harmonics.
3.6.3 Solution of Step II: solution of the MDE for $\psi ^{(n+2)}$
 As we discussed in § 3.4, equation (3.25a) can be rewritten as a MDE for $\psi ^{(n+2)}$ by eliminating $\alpha ^{(n)}$
 by eliminating $\alpha ^{(n)}$ algebraically using (3.25b) and (3.25c). To show that explicitly, we need the following identity obtained from the $n{\textrm {th}}$
 algebraically using (3.25b) and (3.25c). To show that explicitly, we need the following identity obtained from the $n{\textrm {th}}$ order NAE vacuum equations (3.25b), (3.25c):
 order NAE vacuum equations (3.25b), (3.25c):
 
where, in the last step, we have used the $O(1)$ relation (3.11) that gives the Poisson bracket of $\alpha ^{(0)},\psi ^{(2)}$
 relation (3.11) that gives the Poisson bracket of $\alpha ^{(0)},\psi ^{(2)}$ in terms of $\varPhi ^{(2)}$
 in terms of $\varPhi ^{(2)}$ .
.
 Multiplying (3.25a) by $2\psi ^{(2)}$ , using (3.11) and (3.60), we now rewrite (3.25a) as
, using (3.11) and (3.60), we now rewrite (3.25a) as
 
which is clearly of the form
 
where, $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(n+2)}_0$ is defined by (3.49).
 is defined by (3.49).
 Firstly, following the discussion in § 3.6.2, we note that (3.62) determines $\psi ^{(n+2)}$ only up to the homogeneous solution,
 only up to the homogeneous solution,
 
For irrational rotational transform, $\mathcal {Y}_H^{(n+2)}$ must be a constant. The value of the constant will be determined in a subsequent section by imposing the constraint that $2{\rm \pi} \psi$
 must be a constant. The value of the constant will be determined in a subsequent section by imposing the constraint that $2{\rm \pi} \psi$ is the net toroidal flux.
 is the net toroidal flux.
 To determine the particular solution, $\psi _P^{(n+2)}$ , of the MDE (3.62), we first need to investigate the harmonic structure of the forcing term $F^{(n+2)}_\psi$
, of the MDE (3.62), we first need to investigate the harmonic structure of the forcing term $F^{(n+2)}_\psi$ . Let us convince ourselves that $F^{(n+2)}_\psi$
. Let us convince ourselves that $F^{(n+2)}_\psi$ does not have any harmonics higher than $(n+2)$
 does not have any harmonics higher than $(n+2)$ . We will start with the highest harmonics of $\varPhi ^{(n+2)}$
. We will start with the highest harmonics of $\varPhi ^{(n+2)}$ beating with $\psi ^{(2)}$
 beating with $\psi ^{(2)}$ according to (3.62). Straightforward algebra using (3.15) shows that
 according to (3.62). Straightforward algebra using (3.15) shows that
 
The rest of the terms are similar, as shown inductively in Appendix D. Given this form for the forcing term, the solution of $\psi ^{(n+2)}$ can then be deduced from the solution of $\chi ^{(n)}$
 can then be deduced from the solution of $\chi ^{(n)}$ as given in (3.57) with $n$
 as given in (3.57) with $n$ replaced by $(n+2)$
 replaced by $(n+2)$ .
.
 We shall now briefly analyse the coupled ODEs that result from equating the poloidal harmonics of the MDE (3.62). A more complete description will be presented in the next section. Our goal in the remainder of this section is to motivate a choice for the free-functions, $\varPhi ^{(n+2)}_{c(n+2)}, \varPhi ^{(n+2)}_{s(n+2)}$ , that appear in the forcing term (3.64), in terms of the $O(n+2)$
, that appear in the forcing term (3.64), in terms of the $O(n+2)$ flux-surface shaping functions $\psi ^{(n+2)}_{c(n+2)}, \psi ^{(n+2)}_{s(n+2)}$
 flux-surface shaping functions $\psi ^{(n+2)}_{c(n+2)}, \psi ^{(n+2)}_{s(n+2)}$ .
.
 We first note that using the expressions for $\varPhi ^{(2)}$ as given in (3.14) together with the definitions (3.17a,b), the MDO $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(n+2)}_0$
 as given in (3.14) together with the definitions (3.17a,b), the MDO $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(n+2)}_0$ defined in (3.49) can be explicitly written out as follows:
 defined in (3.49) can be explicitly written out as follows:
 
Here,
 
and the operators $\mathcal {L}_1,\mathcal {L}_2$ are given by
 are given by
 
Using (3.65) to solve the MDE (3.62), we note that the $\varPhi _0''$ term in (3.65) can be removed by defining $Y^{(n+2)}$
 term in (3.65) can be removed by defining $Y^{(n+2)}$ such that
 such that
 
 The lower limit on the sum is zero (one) for even (odd) orders. It is straightforward to show that the operators $\mathcal {L}_1,\mathcal {L}_2$ , in general, couple the $m{\textrm {th}}$
 , in general, couple the $m{\textrm {th}}$ harmonics to $m\pm 2$
 harmonics to $m\pm 2$ harmonics. This leads to a complicated set of coupled linear ODEs for the variables $Y^{(n+2)}_{c m},Y^{(n+2)}_{s m}$
 harmonics. This leads to a complicated set of coupled linear ODEs for the variables $Y^{(n+2)}_{c m},Y^{(n+2)}_{s m}$ . However, $\mathcal {L}_1,\mathcal {L}_2$
. However, $\mathcal {L}_1,\mathcal {L}_2$ acting on the $(n+2)$
 acting on the $(n+2)$ harmonics of $\psi ^{(n+2)}$
 harmonics of $\psi ^{(n+2)}$ yields only harmonics of order $n$
 yields only harmonics of order $n$ . From (3.45) we can deduce that the free-functions $\varPhi ^{(n+2)}_{c(n+2)}, \varPhi ^{(n+2)}_{s(n+2)}$
. From (3.45) we can deduce that the free-functions $\varPhi ^{(n+2)}_{c(n+2)}, \varPhi ^{(n+2)}_{s(n+2)}$ also appear with the $(n+2)$
 also appear with the $(n+2)$ harmonics. We shall now focus only on the $\varPhi ^{(n+2)}_{c(n+2)}, \varPhi ^{(n+2)}_{s(n+2)}$
 harmonics. We shall now focus only on the $\varPhi ^{(n+2)}_{c(n+2)}, \varPhi ^{(n+2)}_{s(n+2)}$ equations. Substituting the forms of $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(n+2)}_0$
 equations. Substituting the forms of $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(n+2)}_0$ and $\psi ^{(n+2)}$
 and $\psi ^{(n+2)}$ , (3.65) and (3.68) we find that
 , (3.65) and (3.68) we find that
 
where ‘$\cdots$ ’ represent the rest of the terms including the $(n+2)$
’ represent the rest of the terms including the $(n+2)$ harmonics that are generated by $\mathcal {L}_1,\mathcal {L}_2$
 harmonics that are generated by $\mathcal {L}_1,\mathcal {L}_2$ acting on $\varPhi ^{(n+2)}_{c n}, \varPhi ^{(n+2)}_{s n}$
 acting on $\varPhi ^{(n+2)}_{c n}, \varPhi ^{(n+2)}_{s n}$ . The forcing terms with $(n+2)$
. The forcing terms with $(n+2)$ harmonics are of the form (3.64). We shall now make a choice for the free-functions $\varPhi ^{(n+2)}_{c(n+2)}, \varPhi ^{(n+2)}_{s(n+2)}$
 harmonics are of the form (3.64). We shall now make a choice for the free-functions $\varPhi ^{(n+2)}_{c(n+2)}, \varPhi ^{(n+2)}_{s(n+2)}$ that would allow us to solve the MDE (3.62) partially to obtain $Y^{(n+2)}_{c(n+2)}, Y^{(n+2)}_{s(n+2)}$
 that would allow us to solve the MDE (3.62) partially to obtain $Y^{(n+2)}_{c(n+2)}, Y^{(n+2)}_{s(n+2)}$ . (The solution is partial because the coupling to $\varPhi ^{(n+2)}_{c n}, \varPhi ^{(n+2)}_{s n}$
. (The solution is partial because the coupling to $\varPhi ^{(n+2)}_{c n}, \varPhi ^{(n+2)}_{s n}$ is not included.)
 is not included.)
Motivated by the particular choice for the free functions in Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970), we now choose the free function as
 
Note that our choice differs from Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970) by an extra factor of ${\varPhi _0'}^{n/2}/2a(\ell )$ .
.
 The MDE for $\psi ^{(n+2)}$ (3.62) upon using the expressions (3.69) and (3.70) then leads to
 (3.62) upon using the expressions (3.69) and (3.70) then leads to
 
where ‘$\cdots$ ’ represent the terms obtained from $Y^{(n+2)}_{c n},Y^{(n+2)}_{s n}$
’ represent the terms obtained from $Y^{(n+2)}_{c n},Y^{(n+2)}_{s n}$ that we have ignored. Thus, at each order, $(n+2)$
 that we have ignored. Thus, at each order, $(n+2)$ , the choice of free function (3.70) corresponds to a choice of the $(n+2){\textrm {th}}$
, the choice of free function (3.70) corresponds to a choice of the $(n+2){\textrm {th}}$ poloidal of the flux-surface shape.
 poloidal of the flux-surface shape.
3.6.4 Solution of Step II: decoupling the ODEs obtained from the MDE for $\psi ^{(n+2)}$
 In the last section, we showed how the MDE for $\psi ^{(n+2)}$ can be expanded in a finite number of poloidal Fourier harmonics, given in (3.68). Collecting the various harmonics, the MDE for $\psi ^{(n+2)}$
 can be expanded in a finite number of poloidal Fourier harmonics, given in (3.68). Collecting the various harmonics, the MDE for $\psi ^{(n+2)}$ , which is a PDE, can be reduced to a coupled set of ODEs for the amplitudes, $Y^{(n+2)}_{c m},Y^{(n+2)}_{s m}$
, which is a PDE, can be reduced to a coupled set of ODEs for the amplitudes, $Y^{(n+2)}_{c m},Y^{(n+2)}_{s m}$ , where $0\leq m \leq n+2$
, where $0\leq m \leq n+2$ . The coupling between $m$
. The coupling between $m$ and $m\pm 2$
 and $m\pm 2$ harmonics can be seen from (3.56) to involve the quantities $f^{(2)}_{c2},f^{(2)}_{s2}$
 harmonics can be seen from (3.56) to involve the quantities $f^{(2)}_{c2},f^{(2)}_{s2}$ . We now address how to decouple these ODEs. To do so, we need to discuss the leading-order normal form representation of $\psi ^{(n+2)}$
. We now address how to decouple these ODEs. To do so, we need to discuss the leading-order normal form representation of $\psi ^{(n+2)}$ instead of the poloidal harmonic representation.
 instead of the poloidal harmonic representation.
 The poloidal harmonic structure of $\varPhi ^{(n+2)}$ and $\psi ^{(n+2)}$
 and $\psi ^{(n+2)}$ are the same order by order, both having a maximum poloidal frequency of $(n+2)$
 are the same order by order, both having a maximum poloidal frequency of $(n+2)$ at order $(n+2)$
 at order $(n+2)$ . This observation is directly related to the ‘analyticity’ (in the sense of regularity near the axis) of vacuum magnetic fields assumed by Mercier and others. Rigorous proof of the analyticity condition for $\varPhi,\psi$
. This observation is directly related to the ‘analyticity’ (in the sense of regularity near the axis) of vacuum magnetic fields assumed by Mercier and others. Rigorous proof of the analyticity condition for $\varPhi,\psi$ can be found in Duignan & Meiss (Reference Duignan and Meiss2021) and Jorge et al. (Reference Jorge, Sengupta and Landreman2020b). More concretely, ‘analyticity’ implies (Duignan & Meiss Reference Duignan and Meiss2021; Solov'ev & Shafranov Reference Solov'ev and Shafranov1970)
 can be found in Duignan & Meiss (Reference Duignan and Meiss2021) and Jorge et al. (Reference Jorge, Sengupta and Landreman2020b). More concretely, ‘analyticity’ implies (Duignan & Meiss Reference Duignan and Meiss2021; Solov'ev & Shafranov Reference Solov'ev and Shafranov1970)
 
where, $\mathcal {P}_{(n+2)}$ is a homogeneous polynomial of order $(n+2)$
 is a homogeneous polynomial of order $(n+2)$ in $(X_\mathcal {N},Y_\mathcal {N})$
 in $(X_\mathcal {N},Y_\mathcal {N})$ with coefficients that are functions of $\ell$
 with coefficients that are functions of $\ell$ . Here, the leading-order normal form variables $(X_\mathcal {N},Y_\mathcal {N})$
. Here, the leading-order normal form variables $(X_\mathcal {N},Y_\mathcal {N})$ satisfy (3.19a,b). At $O(n)$
 satisfy (3.19a,b). At $O(n)$ , the polynomial $\mathcal {P}_{(n+2)}$
, the polynomial $\mathcal {P}_{(n+2)}$ can have at most $(n+2)$
 can have at most $(n+2)$ poloidal harmonics since the leading-order normal form variables only have first harmonics.
 poloidal harmonics since the leading-order normal form variables only have first harmonics.
 In the following, we use the following variables obtained from the leading-order normal form variables $(X_\mathcal {N},Y_\mathcal {N})$ :
:
 
From the expression of $\psi ^{(2)}$ in the leading-order normal form variables (3.20), we find that
 in the leading-order normal form variables (3.20), we find that
 
Following Duignan & Meiss (Reference Duignan and Meiss2021), we now employ complex variables
 
to rewrite the expression of $\psi ^{(n+2)}$ in the complex leading-order normal form coordinates (3.72) as
 in the complex leading-order normal form coordinates (3.72) as
 
The connection between the amplitudes $\varPsi ^{(n+2)}_{m r}(\ell )$ and the amplitudes $\psi ^{(n+2)}_{cm},\psi ^{(n+2)}_{sm}$
 and the amplitudes $\psi ^{(n+2)}_{cm},\psi ^{(n+2)}_{sm}$ follows from the definitions (3.73a,b) and (3.75a,b). Note that the reality condition of $\psi ^{(n+2)}$
 follows from the definitions (3.73a,b) and (3.75a,b). Note that the reality condition of $\psi ^{(n+2)}$ implies that $\varPsi ^{(n+2)}_{m (n+2-m)}= {\bar {\varPsi }}^{(n+2)}_{(n+2-m) m}$
 implies that $\varPsi ^{(n+2)}_{m (n+2-m)}= {\bar {\varPsi }}^{(n+2)}_{(n+2-m) m}$ .
.
 We now substitute the complex leading-order normal form expression for $\psi ^{(n+2)}$ (3.76) into the MDE for $\psi ^{(n+2)}$
 (3.76) into the MDE for $\psi ^{(n+2)}$ (3.62). For that we first need to evaluate $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(n+2)}_0 \psi ^{(n+2)}$
 (3.62). For that we first need to evaluate $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(n+2)}_0 \psi ^{(n+2)}$ .
.
In Appendix C, we prove the following identities:
 
 
which show that the complex leading-order normal form basis diagonalizes the MDO. As before, we get rid of the $\varPhi _0''$ term by defining $Y^{(n+2)}={\varPhi _0'}^{-(n+2)/2}\psi ^{(n+2)}$
 term by defining $Y^{(n+2)}={\varPhi _0'}^{-(n+2)/2}\psi ^{(n+2)}$ , equivalently by $\mathcal {Z}_m\to \mathcal {Z}_m {\varPhi _0'}^{(n+2)/2}$
, equivalently by $\mathcal {Z}_m\to \mathcal {Z}_m {\varPhi _0'}^{(n+2)/2}$ in (3.77).
 in (3.77).
 Therefore, the substitution of the following form of $\psi ^{(n+2)}$ :
:
 
into the MDE (3.62) leads to a system of $(n+1)$ decoupled complex ODEs of the form
 decoupled complex ODEs of the form
 
where $\mathcal {F}^{(n+2)}_{\mathcal {Z}_m}$ is an appropriate forcing term. We refer to (3.79) as a reduced MDE. The above results also holds for $m=0,(n+2)=1$
 is an appropriate forcing term. We refer to (3.79) as a reduced MDE. The above results also holds for $m=0,(n+2)=1$ as shown in Appendix C.
 as shown in Appendix C.
 The complex leading-order normal form (3.72) for $\psi ^{(n+2)}$ is, therefore, of great help in systematically solving the MDE for $\psi$
 is, therefore, of great help in systematically solving the MDE for $\psi$ by reducing it to a system of decoupled ODEs (3.79). In Appendix F we have shown explicitly how the MDE for $\psi ^{(3)}$
 by reducing it to a system of decoupled ODEs (3.79). In Appendix F we have shown explicitly how the MDE for $\psi ^{(3)}$ can be solved by leveraging the leading-order normal form structure.
 can be solved by leveraging the leading-order normal form structure.
3.6.5 Solutions of Steps III and IV: determination of $\alpha$
 Our main goal here is to calculate $\alpha ^{(n)}$ given the solutions of $\varPhi ^{(n+2)},\psi ^{(n+2)}$
 given the solutions of $\varPhi ^{(n+2)},\psi ^{(n+2)}$ , combining Steps III and IV, outlined in § 3.4. Step III consists of integrating the equation for $\alpha _{,\omega }$
, combining Steps III and IV, outlined in § 3.4. Step III consists of integrating the equation for $\alpha _{,\omega }$ with respect to $\omega$
 with respect to $\omega$ to determine $\alpha ^{(n)}$
 to determine $\alpha ^{(n)}$ up to a function $\mathfrak {a}(\ell )$
 up to a function $\mathfrak {a}(\ell )$ . Step IV involves poloidally averaging the MDE for $\alpha ^{(n)}$
. Step IV involves poloidally averaging the MDE for $\alpha ^{(n)}$ to get an equation for $\mathfrak {a}(\ell )$
 to get an equation for $\mathfrak {a}(\ell )$ .
.
We start with Step III. A power series expansion of (3.2c), rewritten as
 
at each order, $n$ , leads to
, leads to
 
The function $1/h=(1-\kappa \cos \theta )^{-1}$ has been expanded in powers of $\rho$
 has been expanded in powers of $\rho$ as well.
 as well.
 We shall now split $\psi ^{(n+2)}$ into the homogeneous $\psi ^{(n+2)}_H$
 into the homogeneous $\psi ^{(n+2)}_H$ solution and the particular solution $\psi ^{(n+2)}_P$
 solution and the particular solution $\psi ^{(n+2)}_P$ ,
,
 
Here, we assume that the on-axis rotational transform is irrational, so $\mathcal {Y}^{(n+2)}_H$ is a constant. Separating the $m=0$
 is a constant. Separating the $m=0$ and $m=n$
 and $m=n$ terms in (3.80) from the rest and using the lowest-order relation (3.11) we obtain
 terms in (3.80) from the rest and using the lowest-order relation (3.11) we obtain
 
where $\left ( \varSigma ^{(n)}_1-(\kappa \cos \theta )^n\varPhi _0'\right )$ is the sum of terms in (3.80) from $m=1$
 is the sum of terms in (3.80) from $m=1$ to $(n-1)$
 to $(n-1)$ . Imposing the poloidal integral constraint on $\alpha ^{(n)}$
. Imposing the poloidal integral constraint on $\alpha ^{(n)}$ as given in (3.42) and equating the average of $\alpha _{,\omega }^{(0)}$
 as given in (3.42) and equating the average of $\alpha _{,\omega }^{(0)}$ to unity, as shown in (3.35), we find that
 to unity, as shown in (3.35), we find that
 
We can now integrate (3.82) with respect to $\omega$ to obtain
 to obtain
 
where,
 
Note that the average of $\tilde {\mathfrak {a}}$ is zero because of the condition (3.83) that determines the homogeneous solution $\psi ^{(n+2)}_H$
 is zero because of the condition (3.83) that determines the homogeneous solution $\psi ^{(n+2)}_H$ . This completes Step III.
. This completes Step III.
 We now proceed with Step IV. To determine $\bar {\mathfrak {a}}^{(n)}(\ell )$ , we use the Poisson bracket form of the MDO (3.50)
, we use the Poisson bracket form of the MDO (3.50)
 
which was derived earlier in (3.27).
 Writing (3.86) in the form (3.52) and integrating with respect to $\omega$ between $(0,2{\rm \pi} )$
 between $(0,2{\rm \pi} )$ we obtain the poloidally averaged MDE
 we obtain the poloidally averaged MDE
 
We note here that the derivative in $\omega$ vanished because both $\alpha _{,\omega }^{(0)}$
 vanished because both $\alpha _{,\omega }^{(0)}$ and $\left ( \alpha ^{(n)}/\left ( 2\psi ^{(2)}\right )^{n/2}\right )$
 and $\left ( \alpha ^{(n)}/\left ( 2\psi ^{(2)}\right )^{n/2}\right )$ are single-valued in $\omega$
 are single-valued in $\omega$ .
.
 From (3.84) and (3.35) we then obtain the following equation for $\bar {\mathfrak {a}}^{(n)}(\ell )$ :
:
 
The solution of (3.88) can be obtained through direct integration with respect to $\ell$ . Note that ${\bar {\mathfrak {a}}^{(n)}}{}'(\ell )$
. Note that ${\bar {\mathfrak {a}}^{(n)}}{}'(\ell )$ is not periodic in general since its average is related to the higher-order magnetic-shear as given in (3.42).
 is not periodic in general since its average is related to the higher-order magnetic-shear as given in (3.42).
 We reiterate that the form of $\alpha$ in inverse coordinates, as given in (3.28a,b), is well known. In particular, the secular terms $\theta -\iota (\psi )\phi$
 in inverse coordinates, as given in (3.28a,b), is well known. In particular, the secular terms $\theta -\iota (\psi )\phi$ remain separate from the periodic components of $\alpha$
 remain separate from the periodic components of $\alpha$ . However, in direct coordinates, the secular and the periodic terms are mixed because the $\iota (\psi )\phi$
. However, in direct coordinates, the secular and the periodic terms are mixed because the $\iota (\psi )\phi$ term is now expanded in a power series of $\rho$
 term is now expanded in a power series of $\rho$ . This explains the need to take special care in order to obtain $\alpha$
. This explains the need to take special care in order to obtain $\alpha$ in direct coordinates.
 in direct coordinates.
3.6.6 Summary of Steps I–IV
 We now briefly summarize the main results obtained in § 3.6. We have individually analysed the structure of $(\varPhi,\psi,\alpha )$ , proving that the necessary periodicity conditions (3.28a,b) for obtaining physically meaningful solutions can be satisfied order by order. In § 3.6.1 we have discussed the $O(n+2)$
, proving that the necessary periodicity conditions (3.28a,b) for obtaining physically meaningful solutions can be satisfied order by order. In § 3.6.1 we have discussed the $O(n+2)$ Laplace equation and the structure of its solution $\varPhi ^{(n+2)}$
 Laplace equation and the structure of its solution $\varPhi ^{(n+2)}$ . We have also given a prescription, (3.70), with which the free functions (the homogeneous solution to the Poisson equation) can be expressed in terms of the flux-surface shaping given by (3.71a,b).
. We have also given a prescription, (3.70), with which the free functions (the homogeneous solution to the Poisson equation) can be expressed in terms of the flux-surface shaping given by (3.71a,b).
 In § 3.6.2, we study the general MDE and obtain some of its fundamental properties. These properties allow one to construct homogeneous solutions of the MDEs and annihilators for the MDEs. Later, we use the homogeneous solution for $\psi ^{(n+2)}$ and the annihilator to enforce the periodicity constraint (3.42). The last important property is that the poloidal harmonics of the solution of the MDE truncate if the forcing term has finite poloidal harmonics. Using these properties we found that at $O(n)$
 and the annihilator to enforce the periodicity constraint (3.42). The last important property is that the poloidal harmonics of the solution of the MDE truncate if the forcing term has finite poloidal harmonics. Using these properties we found that at $O(n)$ , $\varPhi ^{(n+2)}$
, $\varPhi ^{(n+2)}$ will have at most $(n+2)$
 will have at most $(n+2)$ harmonics. The structure of $\alpha ^{(n)}$
 harmonics. The structure of $\alpha ^{(n)}$ is more complicated, and solving the MDE for $\alpha$
 is more complicated, and solving the MDE for $\alpha$ (3.27) is far more involved than MDE for $\psi$
 (3.27) is far more involved than MDE for $\psi$ given by (3.61). Fortunately, we do not have to solve the MDE for $\alpha$
 given by (3.61). Fortunately, we do not have to solve the MDE for $\alpha$ .
.
 Finally, in § 3.6.5, we demonstrate how one can obtain $\alpha ^{(n)}$ once $\varPhi ^{(n+2)},\psi ^{(n+2)}$
 once $\varPhi ^{(n+2)},\psi ^{(n+2)}$ has been constructed. This brings us to the end of the analysis of the structure of vacuum equations in the Mercier–Weitzner formalism. In § 6.1 and Appendix H, we discuss analytically tractable and physically interesting limits of 3-D vacuum fields that possess nested surfaces. We can obtain explicit solutions order by order using the NAE formalism we have developed thus far.
 has been constructed. This brings us to the end of the analysis of the structure of vacuum equations in the Mercier–Weitzner formalism. In § 6.1 and Appendix H, we discuss analytically tractable and physically interesting limits of 3-D vacuum fields that possess nested surfaces. We can obtain explicit solutions order by order using the NAE formalism we have developed thus far.
4 The NAE of force-free fields
 For force-free systems, the current $\boldsymbol {J}$ and magnetic field $\boldsymbol {B}$
 and magnetic field $\boldsymbol {B}$ are colinear, i.e.
 are colinear, i.e.
 
Since the divergence of $\boldsymbol {J}$ is zero, we have
 is zero, we have
 
We further assume that the force-free fields possess nested flux surfaces. Therefore, (4.2) implies that $\lambda$ must be a function of only $\psi$
 must be a function of only $\psi$ and $\alpha$
 and $\alpha$ . Physically, the $\alpha$
. Physically, the $\alpha$ dependence of $\lambda$
 dependence of $\lambda$ is special. It is only possible if the rotational transform is a constant rational number. Any amount of magnetic shear will lead to
 is special. It is only possible if the rotational transform is a constant rational number. Any amount of magnetic shear will lead to
 
which we assume from now on.
4.1 Basic formalism for the force-free fields
In the Mercier–Weitzner formalism, force-free fields that possess nested flux surfaces can be seen to be of the form
 
since the current takes the form
 
Comparing (4.1) with (4.5) we find that
 
Note that a homogeneous solution $\bar {K}'_0(\psi )$ could be added to (4.6). However, from (4.4) we find that the $\bar {K}'_0(\psi )$
 could be added to (4.6). However, from (4.4) we find that the $\bar {K}'_0(\psi )$ term can be absorbed by redefining $\varPhi \to \varPhi -\bar {K}_0(\psi )$
 term can be absorbed by redefining $\varPhi \to \varPhi -\bar {K}_0(\psi )$ . Hence, we can set $\bar {K}_0$
. Hence, we can set $\bar {K}_0$ to zero without loss of generality.
 to zero without loss of generality.
 To carry out the NAE, we assume that $\lambda (\psi )$ is sufficiently smooth that we can expand $\lambda$
 is sufficiently smooth that we can expand $\lambda$ as
 as
 
where, $\lambda _i, i=0,2,4,\ldots$ are constants. However, the usual NAE in direct coordinates (3.7) needs to be checked carefully. From the condition $\boldsymbol {\nabla }\boldsymbol {\cdot } \boldsymbol {B}=0$
 are constants. However, the usual NAE in direct coordinates (3.7) needs to be checked carefully. From the condition $\boldsymbol {\nabla }\boldsymbol {\cdot } \boldsymbol {B}=0$ we have
 we have
 
We need to show that the solution of (4.8) can be expressed as a regular power series near the axis. In the vacuum limit, we obtained (3.44), where the right-hand side did not have any harmonics that would beat with the operator on the left-hand side. However, it is not guaranteed that at each $O(\rho ^{n})$ , the term $\boldsymbol {\nabla }\boldsymbol {\cdot } (\bar {K} \boldsymbol {\nabla } \psi )$
, the term $\boldsymbol {\nabla }\boldsymbol {\cdot } (\bar {K} \boldsymbol {\nabla } \psi )$ will not generate such resonant harmonics.
 will not generate such resonant harmonics.
 To further illustrate this point, let us consider the case when $\lambda =$ constant, i.e. $K=-\lambda \alpha$
 constant, i.e. $K=-\lambda \alpha$ . The $\boldsymbol {\nabla }\boldsymbol {\cdot }\boldsymbol {B}=0$
. The $\boldsymbol {\nabla }\boldsymbol {\cdot }\boldsymbol {B}=0$ condition now reads
 condition now reads
 
Expanding as in (3.7), we get
 
Using the Fourier representations, $\psi ^{(n+2-i)}\sim \sum \psi ^{(n+2-i)}_m \textrm {e}^{\textrm {i} m u},\alpha ^{(i)}\sim \sum \alpha ^{(i)}_p \textrm {e}^{\textrm {i} p u}$ ,
,
 
where, $c_{ni}(\ell )$ is some overall constant factor. Clearly, resonance can occur when $m+p=n+2$
 is some overall constant factor. Clearly, resonance can occur when $m+p=n+2$ . If such a $(n+2)$
. If such a $(n+2)$ harmonic is generated then we cannot invert
 harmonic is generated then we cannot invert
 
to solve for a periodic $\varPhi ^{(n+2)}$ . As shown in Weitzner (Reference Weitzner2016), if such a resonance occurs, then the regular power series will fail, and weakly singular terms like $\rho ^n(\log {\rho })^m$
. As shown in Weitzner (Reference Weitzner2016), if such a resonance occurs, then the regular power series will fail, and weakly singular terms like $\rho ^n(\log {\rho })^m$ will appear in the Mercier expansion.
 will appear in the Mercier expansion.
In the following section, we prove that such logarithmically singular terms can indeed be avoided under reasonable assumptions. However, the boundary cannot be arbitrarily specified and must be self-consistent with the NAE.
4.2 Definition of new variables
 Equating $\boldsymbol {B} = \boldsymbol {\nabla }\varPhi -\lambda \alpha \boldsymbol {\nabla } \psi = \boldsymbol {\nabla } \psi \times \boldsymbol {\nabla } \alpha$ , we get the following system of equations for the force-free magnetic fields with flux surfaces in the Mercier–Weitzner formalism:
, we get the following system of equations for the force-free magnetic fields with flux surfaces in the Mercier–Weitzner formalism:
 
 
 
As discussed in the last section, unlike the vacuum limit, it is not immediately evident that resonances can be avoided in the system (4.13).
 Our goal is, therefore, to bring the force-free system of (4.13) as close as possible to the vacuum system given by (3.2). We now try to define a new variable $\xi$ that will play the role analogous to $\varPhi$
 that will play the role analogous to $\varPhi$ in the vacuum limit. It is useful to define a variable $\varLambda$
 in the vacuum limit. It is useful to define a variable $\varLambda$ such that
 such that
 
Now, we define $\xi$ such that
 such that
 
Integrating with respect to $\rho$ we get
 we get
 
Note that $\xi,\varPhi$ and $\alpha$
 and $\alpha$ have similar secular terms linear in the angles. Therefore, imposing the form (2.11) order by order on $\alpha$
 have similar secular terms linear in the angles. Therefore, imposing the form (2.11) order by order on $\alpha$ is enough to impose the right secular structure of $\xi$
 is enough to impose the right secular structure of $\xi$ .
.
 Since, ultimately, we hope to be able to expand in power series of $\rho$ , the integral $\mathcal {I}$
, the integral $\mathcal {I}$ in (4.16), amounts to simply reshuffling the terms and multiplying the coefficients by fractions. With this definition in mind we now rewrite (4.13) in terms of $\xi$
 in (4.16), amounts to simply reshuffling the terms and multiplying the coefficients by fractions. With this definition in mind we now rewrite (4.13) in terms of $\xi$ and its derivatives as
 and its derivatives as
 
 
 
The $\boldsymbol {\nabla }\boldsymbol {\cdot }\boldsymbol {B}=0$ condition in terms of $\xi$
 condition in terms of $\xi$ reads
 reads
 
Comparing (4.17), (4.18) with the vacuum limit given by (3.2) and (3.4), we find that the two differ because of the $(\varLambda _{,\omega } \alpha +\mathcal {I}_{,\omega })$ term, which is an $O(1)$
 term, which is an $O(1)$ term in the $\rho$
 term in the $\rho$ expansion. All other deviations from the vacuum limit are higher order in $\rho$
 expansion. All other deviations from the vacuum limit are higher order in $\rho$ . Fortunately, a workaround is possible by noting that
. Fortunately, a workaround is possible by noting that
 
Integrating once again in $\rho$ , using (4.17c) and simplifying, we get
, using (4.17c) and simplifying, we get
 
With these new definitions, we can write down the force-free equations as
 
 
 
where
 
Finally, the Poisson equation for $\xi$ reads
 reads
 
In Appendix E, we show in detail that just like in the vacuum limit, (4.23) can be solved order by order without encountering any resonances. In short, the basic idea of the proof is to note that while the first term in (4.23) is $O(1)$ and of the form $(\partial ^2_{\omega }+(n+2)^2)\xi ^{(n+2)}$
 and of the form $(\partial ^2_{\omega }+(n+2)^2)\xi ^{(n+2)}$ , the second and the third terms both are $O(\rho ^2)$
, the second and the third terms both are $O(\rho ^2)$ smaller than the first term. Hence, the second and third terms have at most $n\textrm {th}$
 smaller than the first term. Hence, the second and third terms have at most $n\textrm {th}$ harmonics, thereby avoiding any resonance with the first term. Thus, the logarithmic terms are avoided. Once $\xi$
 harmonics, thereby avoiding any resonance with the first term. Thus, the logarithmic terms are avoided. Once $\xi$ has been obtained to $O(\rho ^n)$
 has been obtained to $O(\rho ^n)$ , we can use (4.16) to determine $\varPhi$
, we can use (4.16) to determine $\varPhi$ to the same order of accuracy.
 to the same order of accuracy.
4.3 The NAE equations for force-free equilibrium
 We shall now discuss the lowest-order NAE equations for the force-free equilibrium using the variables defined in the last section. Finally, we shall discuss the lowest two orders before discussing the general $O(\rho ^n)$ system of equations.
 system of equations.
 Substituting the near-axis power series expansion into the definitions of $\mathcal {I},\varXi$ given in (4.22), we find that
 given in (4.22), we find that
 
We are now in a position to investigate the Poisson equation for $\xi$ , (4.23). First, we note from (4.24) that the contribution of $\varXi$
, (4.23). First, we note from (4.24) that the contribution of $\varXi$ to (4.21b) starts at $O(\rho ^4)$
 to (4.21b) starts at $O(\rho ^4)$ . Next, we find from (4.24) that the Poisson equation (4.23) matches the vacuum case exactly to $O(\rho ^{-2}), O(\rho ^{-1})$
. Next, we find from (4.24) that the Poisson equation (4.23) matches the vacuum case exactly to $O(\rho ^{-2}), O(\rho ^{-1})$ . Thus, $\xi$
. Thus, $\xi$ and $\varPhi$
 and $\varPhi$ differ only from the second-order onward, i.e.
 differ only from the second-order onward, i.e.
 
Consequently, we note that even though $\mathcal {W}\sim O(\rho ^2)$ its contribution to (4.23) through the $\partial \omega (h \mathcal {W})$
 its contribution to (4.23) through the $\partial \omega (h \mathcal {W})$ term is $O(\rho ^3)$
 term is $O(\rho ^3)$ since it is a function of $\ell$
 since it is a function of $\ell$ to lowest order. Therefore, even the $O(1)$
 to lowest order. Therefore, even the $O(1)$ Poisson equation assumes the same form as in the vacuum case, namely,
 Poisson equation assumes the same form as in the vacuum case, namely,
 
whose solution is given by
 
The components of the magnetic field are given by
 
which implies that
 
Another implication of (4.28) is that the $O(\rho ^2)$ NAE equations are
 NAE equations are
 
 
The lowest-order flux surface and field line label can be shown to be the one obtained by Mercier (Mercier Reference Mercier1964)
 
 
 
 
As in the vacuum case, we choose $2{\rm \pi} \psi$ as the toroidal flux. A comparison with the vacuum solutions given in § 3.3 shows minimal changes from vacuum solutions. The main difference arises because of the extra $\lambda _0/2$
 as the toroidal flux. A comparison with the vacuum solutions given in § 3.3 shows minimal changes from vacuum solutions. The main difference arises because of the extra $\lambda _0/2$ factor in the expression for $\alpha _{,\ell }^{(0)}$
 factor in the expression for $\alpha _{,\ell }^{(0)}$ in (4.30a). While the structure of the equations stays the same, the forcing functions, $F_\phi,F_\psi, F_\alpha$
 in (4.30a). While the structure of the equations stays the same, the forcing functions, $F_\phi,F_\psi, F_\alpha$ , get modified to include the effects of force-free currents.
, get modified to include the effects of force-free currents.
The on-axis rotational transform for the force-free case is given by
 
As shown by Mercier (Reference Mercier1974), pressure does not affect the on-axis rotational transform. Therefore, the on-axis rotational transform given in (4.32) also applies to the general MHS case.
 We now proceed to describe the structure of the $O(\rho ^{(n+2)})$ equations. We note that just like in the vacuum case, (4.21a) gives us an MDE for $\psi ^{(n+2)}$
 equations. We note that just like in the vacuum case, (4.21a) gives us an MDE for $\psi ^{(n+2)}$ . To obtain the MDE for $\alpha ^{(n)}$
. To obtain the MDE for $\alpha ^{(n)}$ we proceed exactly as in the vacuum limit by eliminating $\psi ^{(n+2)}$
 we proceed exactly as in the vacuum limit by eliminating $\psi ^{(n+2)}$ from (4.21b) and (4.21c). Therefore, following the vacuum case, we can write down the steps involved in solving the force-free equations $(\xi ^{(n+2)},\psi ^{(n+2)},\alpha ^{(n)})$
 from (4.21b) and (4.21c). Therefore, following the vacuum case, we can write down the steps involved in solving the force-free equations $(\xi ^{(n+2)},\psi ^{(n+2)},\alpha ^{(n)})$ . The steps are precisely the ones we discussed in the vacuum limit:
. The steps are precisely the ones we discussed in the vacuum limit:
- (I) the Poisson equation (4.23) for $\xi ^{(n+2)}$  ; ;
- (II) the MDE for $\psi ^{(n+2)}$  from (4.21a); from (4.21a);
- (III) the $\alpha _{,\omega }$  equation from (4.21c) to solve for $\alpha ^{(n)}$ equation from (4.21c) to solve for $\alpha ^{(n)}$ up to a function $\mathfrak {\bar {a}}^{(n)}(\ell )$ up to a function $\mathfrak {\bar {a}}^{(n)}(\ell )$ ; ;
- (IV) the poloidal $\omega$  average of the MDE for $\alpha$ average of the MDE for $\alpha$ to determine $\mathfrak {\bar {a}}^{(n)}(\ell )$ to determine $\mathfrak {\bar {a}}^{(n)}(\ell )$ . .
 We present a detailed demonstration of the above steps for $n=1$ in Appendix G.
 in Appendix G.
5 The MHS equilibrium with finite $\beta \sim p'/B^2$
5.1 Basic formalism for the MHS fields: current potentials
In the Mercier–Weitzner formalism, as mentioned in § 2, we have an inhomogeneous MDE of the form
 
that must be solved to obtain the current potential $K$ . In the force-free limit, we obtained the homogeneous solution $K=\bar {K}=-\lambda (\psi )\alpha$
. In the force-free limit, we obtained the homogeneous solution $K=\bar {K}=-\lambda (\psi )\alpha$ . In the presence of finite pressure gradients, in addition to $\bar {K}$
. In the presence of finite pressure gradients, in addition to $\bar {K}$ , we also need to solve for the inhomogeneous solution, $G$
, we also need to solve for the inhomogeneous solution, $G$ , such that
, such that
 
Equation (5.1) implies
 
Thus, the quantity $G$ is the pressure-driven part of the current potential. Note that, in general, the function $\lambda$
 is the pressure-driven part of the current potential. Note that, in general, the function $\lambda$ is not the parallel current ($j_{\|}$
 is not the parallel current ($j_{\|}$ ) since
) since
 
Only in the force-free limit ($p'=0, G=0$ ) i $j_{\|}$
) i $j_{\|}$ equal to $\lambda$
 equal to $\lambda$ . Also, note that $G$
. Also, note that $G$ is not single-valued. However, the secular parts of $G$
 is not single-valued. However, the secular parts of $G$ need to be of the same form as $K$
 need to be of the same form as $K$ and $\alpha$
 and $\alpha$ in (2.11).
 in (2.11).
 Let us first look at the axisymmetric limit to understand better the relation between $\lambda,G$ and the parallel current. The axisymmetric magnetic field and the current in a tokamak are given by (Freidberg Reference Freidberg1982)
 and the parallel current. The axisymmetric magnetic field and the current in a tokamak are given by (Freidberg Reference Freidberg1982)
 
where, $(R,\zeta,z)$ denotes the standard cylindrical coordinate system, $F(\varPsi )$
 denotes the standard cylindrical coordinate system, $F(\varPsi )$ is the poloidal current and $\varPsi$
 is the poloidal current and $\varPsi$ is the poloidal flux function that satisfies $\textrm {d}\varPsi /\textrm {d}\psi =\iota (\psi )$
 is the poloidal flux function that satisfies $\textrm {d}\varPsi /\textrm {d}\psi =\iota (\psi )$ together the Grad–Shafranov equation
 together the Grad–Shafranov equation
 
Furthermore, in axisymmetry, the toroidal angle dependence can only be through secular terms. Thus,
 
Using the following axisymmetric relations (Freidberg Reference Freidberg1982; Helander Reference Helander2014):
 
and (5.6), the pressure driven terms in the equation for $\lambda$ , (5.3), cancel resulting in
, (5.3), cancel resulting in
 
Equation (5.8) shows that in the force-free limit $-\lambda (\psi )= F'(\varPsi )$ , but for finite beta, the pressure-driven current also contributes to $\lambda$
, but for finite beta, the pressure-driven current also contributes to $\lambda$ through the secular term.
 through the secular term.
5.2 The NAE of MHS fields
 We now discuss the NAE of MHS fields. We postulate that $\bar {K},G$ have the following expansions:
 have the following expansions:
 
 
where each quantity is finite and non-singular. By allowing power-series expansions of $\bar {K},G$ , we are explicitly excluding current profiles that are singular near the axis. It is beyond the scope of this work to account for the effects of near-axis current singularities and will be left for future publications.
, we are explicitly excluding current profiles that are singular near the axis. It is beyond the scope of this work to account for the effects of near-axis current singularities and will be left for future publications.
 Carrying out the NAE assuming power series expansion in $\rho$ , we get the following coupled PDE system at each order, $n$
, we get the following coupled PDE system at each order, $n$ :
:
 
 
 
We have precisely two MDE for $G$ and $\psi$
 and $\psi$ and one elliptic equation for $\varPhi$
 and one elliptic equation for $\varPhi$ . The function $\alpha$
. The function $\alpha$ is obtained from $\varPhi,\psi$
 is obtained from $\varPhi,\psi$ without solving an MDE for $\alpha$
 without solving an MDE for $\alpha$ . Therefore, the PDE is of mixed elliptic–hyperbolic type as is well known (Bauer, Betancourt & Garabedian Reference Bauer, Betancourt and Garabedian2012a; Weitzner Reference Weitzner2014). However, as discussed in § 4, it is not immediately obvious that (5.10c) can be solved for $\varPhi$
. Therefore, the PDE is of mixed elliptic–hyperbolic type as is well known (Bauer, Betancourt & Garabedian Reference Bauer, Betancourt and Garabedian2012a; Weitzner Reference Weitzner2014). However, as discussed in § 4, it is not immediately obvious that (5.10c) can be solved for $\varPhi$ without encountering logarithmic singularities. In principle, the logarithmic singularities can still arise even if the current profiles are chosen to be smooth near the axis by imposing (5.9).
 without encountering logarithmic singularities. In principle, the logarithmic singularities can still arise even if the current profiles are chosen to be smooth near the axis by imposing (5.9).
5.3 Definitions of new variables
 The change of variables is the same as in the force-free case, with additional terms from $G$ . We shall have first the covariant and the contravariant forms of $\boldsymbol {B}$
. We shall have first the covariant and the contravariant forms of $\boldsymbol {B}$ :
:
 
Then we define the new variable $\xi$ , such that
, such that
 
Integrating (5.13) with respect to $\rho$ we get
 we get
 
The $(\rho,\omega,\ell )$ components of (5.11) then yield
 components of (5.11) then yield
 
 
 
While the $B_\rho$ and $B_\ell$
 and $B_\ell$ equations above show minimal change when we go to the vacuum limit, the $B_\omega$
 equations above show minimal change when we go to the vacuum limit, the $B_\omega$ equation needs modifications similar to the force-free case. Utilizing the same trick, (4.19), that we used before in the force-free case, we find that
 equation needs modifications similar to the force-free case. Utilizing the same trick, (4.19), that we used before in the force-free case, we find that
 
Therefore, the final set of MHS equations has the form
 
 
 
where
 
The Poisson equation for $\xi$ is now given by
 is now given by
 
As in the force-free case, $\xi$ plays the analogous role of $\varPhi$
 plays the analogous role of $\varPhi$ in the vacuum limit, and it can be shown (see Appendix E) that the Poisson equation for $\xi$
 in the vacuum limit, and it can be shown (see Appendix E) that the Poisson equation for $\xi$ is free of any resonances.
 is free of any resonances.
5.4 The NAE of MHS equations
 The expansions of the quantities $\mathcal {I}, \varXi$ that appear in (5.16) have already been discussed in (4.24). From the NAE, (5.9) and (2.22) we find that the quantities $\mathcal {G},\mathcal {Y},\mathcal {X},\mathcal {I},\varXi$
 that appear in (5.16) have already been discussed in (4.24). From the NAE, (5.9) and (2.22) we find that the quantities $\mathcal {G},\mathcal {Y},\mathcal {X},\mathcal {I},\varXi$ , as defined in (5.16d), have the following forms:
, as defined in (5.16d), have the following forms:
 
Therefore, the deviation of the MHS system (5.16) from the vacuum system (3.2) is zero to $O(\rho ^{-2}),O(\rho ^{-1})$ , just like the force-free equations (4.21). Moreover, (5.18) also implies that the expressions for the lowest-order components of $\boldsymbol {B}$
, just like the force-free equations (4.21). Moreover, (5.18) also implies that the expressions for the lowest-order components of $\boldsymbol {B}$ are the same as in the force-free case (4.28). As a result, MHS and force-free both have the same form of MDO given by (4.28). Consequently, the basic framework is analogous to the vacuum system and the effects of currents and pressure show up mostly through the forcing terms $F_\phi,F_\psi,F_\alpha$
 are the same as in the force-free case (4.28). As a result, MHS and force-free both have the same form of MDO given by (4.28). Consequently, the basic framework is analogous to the vacuum system and the effects of currents and pressure show up mostly through the forcing terms $F_\phi,F_\psi,F_\alpha$ .
.
 The only additional step in MHS is Step 0, which involves solving the MDE for $G$ order by order. Step 0 follows the same procedure that we have discussed for the solution of the generic MDE in § 3.6.2. To $O(\rho ^0)$
 order by order. Step 0 follows the same procedure that we have discussed for the solution of the generic MDE in § 3.6.2. To $O(\rho ^0)$ , the MDE for $G$
, the MDE for $G$ is given by
 is given by
 
which can be easily solved to obtain the following:
 
The details of the general first-order solutions are given in Appendix G. Due to the similarities between the force-free and the vacuum problem, we do not explicitly show Steps I–IV.
6 Construction of analytical solutions in the Mercier–Weitzner formalism
We have completed the development of the Mercier–Weitzner formalism of the direct NAEs. In this section, we shall provide explicit analytical solutions to low orders for vacuum, force-free and MHS fields that can be obtained within the Mercier–Weitzner formalism.
6.1 Examples of vacuum fields
 We now discuss the next to leading order, $n=1$ , solutions to illustrate some of the key features of the NAE for the vacuum case. Our goal is also to clarify some of the steps in the Mercier–Weitzner formalism discussed earlier. We begin with the straightforward case where the lowest order flux-surface $\psi ^{(2)}$
, solutions to illustrate some of the key features of the NAE for the vacuum case. Our goal is also to clarify some of the steps in the Mercier–Weitzner formalism discussed earlier. We begin with the straightforward case where the lowest order flux-surface $\psi ^{(2)}$ has a circular cross-section. The general case (with rotating ellipse, triangularity, etc.) is described in Appendix F.
 has a circular cross-section. The general case (with rotating ellipse, triangularity, etc.) is described in Appendix F.
 We consider the case where $a(\ell )=1/2, b(\ell )=0$ in (3.16a,b), which corresponds to a circular cross-section to the lowest order. For this case, the NAE equations to $O(1)$
 in (3.16a,b), which corresponds to a circular cross-section to the lowest order. For this case, the NAE equations to $O(1)$ (3.11) imply that
 (3.11) imply that
 
To $O(\rho )$ the relevant equations for the variables $(\varPhi ^{(3)},\alpha ^{(1)},\psi ^{(3)})$
 the relevant equations for the variables $(\varPhi ^{(3)},\alpha ^{(1)},\psi ^{(3)})$ takes the form
 takes the form
 
 
 
Equation (6.2a) is the Poisson equation for $\varPhi ^{(3)}$ whose solution can be readily seen to be
 whose solution can be readily seen to be
 
Here, $u=\theta$ , and we have used (3.70), the Soloviev form of the free function, in representing $\varPhi ^{(3)}$
, and we have used (3.70), the Soloviev form of the free function, in representing $\varPhi ^{(3)}$ .
.
 Next, we solve (6.2b), which is the MDE for $\psi ^{(3)}$ . The first step is to eliminate the linear term in $\psi ^{(3)}$
. The first step is to eliminate the linear term in $\psi ^{(3)}$ through a change of variables,
 through a change of variables,
 
Substituting the expression for $\varPhi ^{(3)}$ (6.3) into (6.4) we find
 (6.3) into (6.4) we find
 
with
 
The solution of (6.2b) is, therefore, of the form
 
where, $\sigma ^{(3)}_{c1}, \sigma ^{(3)}_{s1}$ satisfy
 satisfy
 
Note that due to our choice of the free function in (6.3), the third harmonics of $\psi ^{(3)}$ are obtained explicitly in (6.7). We can now combine (6.8) into a single complex equation
 are obtained explicitly in (6.7). We can now combine (6.8) into a single complex equation
 
Note that we can add a homogeneous solution to $\psi ^{(3)}$ of the form
 of the form
 
We now solve (6.2c) to obtain $\alpha ^{(1)}$ up to a function $\mathfrak {a}^{(1)}(\ell )$
 up to a function $\mathfrak {a}^{(1)}(\ell )$ . Substituting the solution of $\psi ^{(3)}$
. Substituting the solution of $\psi ^{(3)}$ and integrating (6.2c) with respect to $\omega$
 and integrating (6.2c) with respect to $\omega$ , we obtain
, we obtain
 
To determine $\mathfrak {a}^{(1)}(\ell )$ we need the MDE for $\alpha ^{(1)}$
 we need the MDE for $\alpha ^{(1)}$ ,
,
 
Since $\alpha ^{(1)}$ and $\varPhi ^{(3)}$
 and $\varPhi ^{(3)}$ only have odd harmonics, the poloidal average of (6.12) is zero. Hence, both $Y^{(3)}_H$
 only have odd harmonics, the poloidal average of (6.12) is zero. Hence, both $Y^{(3)}_H$ and $\mathfrak {a}^{(1)}(\ell )$
 and $\mathfrak {a}^{(1)}(\ell )$ are zero.
 are zero.
 When the on-axis magnetic field, $\varPhi _0'=B_0$ , is a constant, the NAE results simplify even further. For $\varPhi _0''=0$
, is a constant, the NAE results simplify even further. For $\varPhi _0''=0$ , we have $\sigma ^{(3)}_{c1}=\sigma ^{(3)}_{s1}=0$
, we have $\sigma ^{(3)}_{c1}=\sigma ^{(3)}_{s1}=0$ , and we obtain the following explicit forms for the lower-order quantities:
, and we obtain the following explicit forms for the lower-order quantities:
 
 
 
 
6.2 Examples of force-free and MHS fields
 We shall now compare the NAE of force-free and MHS equilibrium with the ‘one-size fits all’ Soloviev profiles (Cerfon & Freidberg Reference Cerfon and Freidberg2010). The Soloviev profiles make the Grad–Shafranov equation (5.5) linear and, therefore, analytically tractable. In the following, we shall restrict ourselves to first-order NAE, i.e. the accuracy of $\psi$ to $O(\rho ^4)$
 to $O(\rho ^4)$ .
.
To the required order of accuracy, the one-size model is given by (Cerfon & Freidberg Reference Cerfon and Freidberg2010)
 
where, $A$ is a constant and $x,y$
 is a constant and $x,y$ represent the axisymmetric cylindrical $R,z$
 represent the axisymmetric cylindrical $R,z$ coordinates, normalized by the major radius $R_0$
 coordinates, normalized by the major radius $R_0$ . The normalized pressure and current profiles satisfy
. The normalized pressure and current profiles satisfy
 
Equivalently, the Soloviev profiles are defined by
 
where, $p_0,F_0$ are constants. The $A=1$
 are constants. The $A=1$ limit corresponds to force-free equilibrium. The poloidal flux function $\varPsi$
 limit corresponds to force-free equilibrium. The poloidal flux function $\varPsi$ , given by (6.14), satisfies the following Grad–Shafranov equation:
, given by (6.14), satisfies the following Grad–Shafranov equation:
 
 We choose a circular cross-section to the lowest order for simplicity while allowing for arbitrary shaping at higher orders. The details of the NAE are provided in Appendix H along with other analytical examples. To $O(\rho ^4)$ , the NAE matches the exact one-size results for both force-free and MHS cases. Figure 1 compares the exact one-size solution with the NAE in the case of force-free ($\beta =0\,\%$
, the NAE matches the exact one-size results for both force-free and MHS cases. Figure 1 compares the exact one-size solution with the NAE in the case of force-free ($\beta =0\,\%$ ) and MHS at $\beta =5\,\%$
) and MHS at $\beta =5\,\%$ . We see that the deviations of NAE from the exact are more on the inboard side, where the surfaces have a more significant shaping.
. We see that the deviations of NAE from the exact are more on the inboard side, where the surfaces have a more significant shaping.

Figure 1. Comparison of exact axisymmetric force-free (a) and MHS (b) equilibrium at 5 % plasma $\beta$ obtained for Soloviev profiles to the NAE. The effect of $\beta$
 obtained for Soloviev profiles to the NAE. The effect of $\beta$ is barely visible. The NAE matches exactly to the one-size model up to $O(\rho ^4)$
 is barely visible. The NAE matches exactly to the one-size model up to $O(\rho ^4)$ . Note that the NAE deviates significantly from the exact solution only when the aspect ratio is sizable ($\approx 1/2$
. Note that the NAE deviates significantly from the exact solution only when the aspect ratio is sizable ($\approx 1/2$ ).
).
7 Numerical implementation
In this section, we present some numerical examples of the second-order near-axis equilibria constructed numerically using the formalism developed in the previous sections. We verify aspects of this implementation by generating a plasma boundary at a finite aspect ratio, using it to construct a global equilibrium using the VMEC code (Hirshman & Whitson Reference Hirshman and Whitson1983), and comparing some of its properties with the near-axis equilibrium. We detail this procedure in what follows.
The examples presented here are constructed with an axis with constant torsion and a nearly circular cross-section, which we chose for simplicity. The details on the axis are provided in Appendix H.4. The choice of nearly circular cross-sections, discussed in detail in Appendix H.4, leads to the toroidal flux function,
 
where
 
with $\sigma ^{(3)}_{c1}$ and $\sigma ^{(3)}_{s1}$
 and $\sigma ^{(3)}_{s1}$ given by (H42).
 given by (H42).
 In addition, we choose $\varPhi _0=l$ so that the magnetic field is constant on the axis, $B_0=1$
 so that the magnetic field is constant on the axis, $B_0=1$ , a feature easily checked in the finite aspect ratio equilibrium constructed. Given the emphasis in this paper on the near-axis construction for finite current and pressure, we choose finite values for these: $\lambda _0=1.2$
, a feature easily checked in the finite aspect ratio equilibrium constructed. Given the emphasis in this paper on the near-axis construction for finite current and pressure, we choose finite values for these: $\lambda _0=1.2$ and $p_2=-0.1$
 and $p_2=-0.1$ .
.
 This information is sufficient to describe the near-axis equilibrium and to construct a flux surface at a finite aspect ratio. Once such a surface has been constructed, we find a global equilibrium solution with VMEC. The position vector $\boldsymbol {r}$ for a surface at constant $\psi$
 for a surface at constant $\psi$ is given by
 is given by
 
where $\rho$ is found by inverting (7.1), namely $\rho = \sqrt {2 \psi }- 2 \psi _3 \psi$
 is found by inverting (7.1), namely $\rho = \sqrt {2 \psi }- 2 \psi _3 \psi$ , at given values of $\psi$
, at given values of $\psi$ . Surfaces of constant $\psi$
. Surfaces of constant $\psi$ at $\phi =l=0$
 at $\phi =l=0$ are shown in figure 2 from the magnetic axis to $\psi =0.001$
 are shown in figure 2 from the magnetic axis to $\psi =0.001$ (figure 2a, high-aspect ratio $\epsilon =1/50$
 (figure 2a, high-aspect ratio $\epsilon =1/50$ ) and from the magnetic axis to $\psi =0.02$
) and from the magnetic axis to $\psi =0.02$ (figure 2b, moderate aspect ratio $\epsilon =1/11$
 (figure 2b, moderate aspect ratio $\epsilon =1/11$ ). Note the noticeable difference in the Shafranov shift of these configurations. This difference is consistent with their effective plasma $\beta$
). Note the noticeable difference in the Shafranov shift of these configurations. This difference is consistent with their effective plasma $\beta$ on axis: for the high-aspect-ratio $\beta =0.12\,\%$
 on axis: for the high-aspect-ratio $\beta =0.12\,\%$ , and the moderate aspect ratio case, $\beta =2.69\,\%$
, and the moderate aspect ratio case, $\beta =2.69\,\%$ .
.

Figure 2. Cross-sections of constant $\psi$ for near-axis construction. Surfaces of constant $\psi$
 for near-axis construction. Surfaces of constant $\psi$ at $\phi =l=0$
 at $\phi =l=0$ following (7.3) in the range from $\psi =0$
 following (7.3) in the range from $\psi =0$ , the magnetic axis, to (a) $\psi =0.001$
, the magnetic axis, to (a) $\psi =0.001$ and (b) $\psi =0.02$
 and (b) $\psi =0.02$ .
.
 To proceed further with the comparison, we need to compute the Fourier coefficients of the finite aspect ratio flux surface. That is, the Fourier coefficients of $R(\theta, \phi _c)$ and $Z(\theta, \phi _c)$
 and $Z(\theta, \phi _c)$ in cylindrical coordinates $(R, Z, \phi _c)$
 in cylindrical coordinates $(R, Z, \phi _c)$ for the plasma surface. Note that this cylindrical coordinate system is not the Mercier coordinate system, the natural coordinate system for near-axis construction. In particular, the toroidal angle in cylindrical coordinates is not the same as the toroidal angle associated with the length $\ell$
 for the plasma surface. Note that this cylindrical coordinate system is not the Mercier coordinate system, the natural coordinate system for near-axis construction. In particular, the toroidal angle in cylindrical coordinates is not the same as the toroidal angle associated with the length $\ell$ along the magnetic axis. Thus, if we need to use the cylindrical angle off-axis $\phi _c(\psi, \theta, \phi )$
 along the magnetic axis. Thus, if we need to use the cylindrical angle off-axis $\phi _c(\psi, \theta, \phi )$ as our coordinate for the surface, we must invert its definition,
 as our coordinate for the surface, we must invert its definition,

to compute the toroidal angle on-axis $\phi$ . This can be achieved using a numerical root solver based on Newton's method. Once this inversion is achieved, we calculate the Fourier components $(RBC,ZBS)$
. This can be achieved using a numerical root solver based on Newton's method. Once this inversion is achieved, we calculate the Fourier components $(RBC,ZBS)$ of $R(\theta,\phi _c)=\sum _{m,n}RBC_{m,n}\cos (m \theta - n\phi _c)$
 of $R(\theta,\phi _c)=\sum _{m,n}RBC_{m,n}\cos (m \theta - n\phi _c)$ and $Z(\theta,\phi _c)=\sum _{m,n}ZBS{m,n}\sin (m \theta -n \phi _c)$
 and $Z(\theta,\phi _c)=\sum _{m,n}ZBS{m,n}\sin (m \theta -n \phi _c)$ for $0\le m \le 10$
 for $0\le m \le 10$ and $0-10\le N \le 10$
 and $0-10\le N \le 10$ . The surface defined this way is now in a form to be used as an input to the equilibrium solve in VMEC. Comparing figure 2 to figure 3, we find that although the flux surfaces are nearly circular in the Frenet–Serret frame of the magnetic axis, they have significant shaping in the laboratory frame, most notably in elongation. This difference arises because of the non-circular geometry of the axis. In figure 4, we have shown the three-dimensional shapes of the outermost flux surfaces.
. The surface defined this way is now in a form to be used as an input to the equilibrium solve in VMEC. Comparing figure 2 to figure 3, we find that although the flux surfaces are nearly circular in the Frenet–Serret frame of the magnetic axis, they have significant shaping in the laboratory frame, most notably in elongation. This difference arises because of the non-circular geometry of the axis. In figure 4, we have shown the three-dimensional shapes of the outermost flux surfaces.

Figure 3. Cross-sections of the global equilibrium for $\psi =0.02$ . Example of cross-sections for the global VMEC equilibrium solution for $\psi =0.02$
. Example of cross-sections for the global VMEC equilibrium solution for $\psi =0.02$ . Cross-sections at $\phi _c=0,{\rm \pi} /4$
. Cross-sections at $\phi _c=0,{\rm \pi} /4$ and ${\rm \pi} /2$
 and ${\rm \pi} /2$ are shown at values of normalized toroidal flux from $0.1- 1.0$
 are shown at values of normalized toroidal flux from $0.1- 1.0$ . The cross-sections show the non-trivial shaping of the example field used in this section.
. The cross-sections show the non-trivial shaping of the example field used in this section.

Figure 4. Three-dimensional representation of the constructed equilibria. Plots of the boundary of the equilibria constructed from the near-axis solution for (a) $\psi =0.001$ and (b) $\psi =0.02$
 and (b) $\psi =0.02$ . Some cross-sections for the latter are shown in figure 3. The colour map represents the magnitude of the magnetic field on the surface.
. Some cross-sections for the latter are shown in figure 3. The colour map represents the magnitude of the magnetic field on the surface.
 The surfaces from the near-axis construction and the finite aspect ratio equilibrium are compared for several aspect ratios in figure 5. There are clear differences in the shapes of both equilibria, but these tend to decrease in the limit of increasing aspect ratio. For a more accurate matching, as discussed in Landreman & Sengupta (Reference Landreman and Sengupta2019), the error incurred in setting the minor radius $\sqrt {\psi }$ to a finite value, say $a$
 to a finite value, say $a$ when constructing an equilibrium makes a one-to-one comparison between the solutions complicated. A double expansion in both small parameters, $\sqrt {\psi },a$
 when constructing an equilibrium makes a one-to-one comparison between the solutions complicated. A double expansion in both small parameters, $\sqrt {\psi },a$ must be carried out to account for finite aspect ratio. Or construct the finite aspect ratio equilibrium in an alternative way (Panici et al. Reference Panici, Conlin, Dudt and Kolemen2022, Reference Panici, Rodriguez, Conlin, Kim, Dudt, Unalmis and Kolemen2023). This is particularly important for comparing higher-order NAE features, such as the magnitude of the Shafranov shift. A more accurate and complete numerical description is left for future work.
 must be carried out to account for finite aspect ratio. Or construct the finite aspect ratio equilibrium in an alternative way (Panici et al. Reference Panici, Conlin, Dudt and Kolemen2022, Reference Panici, Rodriguez, Conlin, Kim, Dudt, Unalmis and Kolemen2023). This is particularly important for comparing higher-order NAE features, such as the magnitude of the Shafranov shift. A more accurate and complete numerical description is left for future work.

Figure 5. Comparison of cross-sections from NAE and VMEC calculations. The plots show a comparison between the cross-sections at $\phi _c=0$ between the global equilibria computed with VMEC for $\psi =0.02,0.01,0.005,0.003$
 between the global equilibria computed with VMEC for $\psi =0.02,0.01,0.005,0.003$ (a–d) and the near axis solution (broken lines). The comparison of the NAE solution with the finite aspect ratio VMEC gets better with increasing aspect ratio. The flux surfaces shown correspond to $\psi =0.02,0.01,0.005,0.003,0.001$
 (a–d) and the near axis solution (broken lines). The comparison of the NAE solution with the finite aspect ratio VMEC gets better with increasing aspect ratio. The flux surfaces shown correspond to $\psi =0.02,0.01,0.005,0.003,0.001$ and the magnetic axis.
 and the magnetic axis.
 The rotational transform provides another important feature of the equilibria to study. Using Mercier's formula for the rotational transform on-axis $\iota _0$ (Mercier Reference Mercier1964), the near-axis construction expects a value
 (Mercier Reference Mercier1964), the near-axis construction expects a value
 
Figure 6 shows the difference between the NAE rotational transform and the one obtained from the finite aspect ratio equilibria. The difference tends to zero quadratically in the aspect ratio, suggesting that the construction of the equilibrium is correct to first order. The differences in rotational transform may be compared in magnitude with the total global shear of the equilibria.

Figure 6. Rotational transform profile of global equilibria and difference to the NAE. (a) Rotational transform $\iota$ as a function of the normalized toroidal flux $s=\psi /\psi _b$
 as a function of the normalized toroidal flux $s=\psi /\psi _b$ computed by VMEC for the equilibria with $\psi =0.001$
 computed by VMEC for the equilibria with $\psi =0.001$ and $0.02$
 and $0.02$ . The lower aspect ratio case shows higher magnetic shear. (b) Difference between the on-axis rotational transform between the finite aspect ratio VMEC equilibria and the near axis value, as a function of the aspect ratio. The dashed line shows a scaling $\epsilon ^2$
. The lower aspect ratio case shows higher magnetic shear. (b) Difference between the on-axis rotational transform between the finite aspect ratio VMEC equilibria and the near axis value, as a function of the aspect ratio. The dashed line shows a scaling $\epsilon ^2$ .
.
 Finally, let us recall that the near-axis construction was made for a constant magnetic field on the axis. Thus, studying the spectrum of Fourier modes of the magnetic field strength $B$ should also be informative. Figure 7 shows the spectrum computed using the BOOZ_XFORM code (Sanchez et al. Reference Sanchez, Hirshman, Ware, Berry and Spong2000). We find that, indeed, on the axis, the magnetic field is approximately constant. A mirror mode growing with decreasing aspect ratio is apparent, in line with previous findings (Landreman & Sengupta Reference Landreman and Sengupta2019; Jorge et al. Reference Jorge, Sengupta and Landreman2020a), and a more sophisticated way of generating finite-aspect-ratio equilibria would be necessary (Landreman & Sengupta Reference Landreman and Sengupta2019) to suppress them.
 should also be informative. Figure 7 shows the spectrum computed using the BOOZ_XFORM code (Sanchez et al. Reference Sanchez, Hirshman, Ware, Berry and Spong2000). We find that, indeed, on the axis, the magnetic field is approximately constant. A mirror mode growing with decreasing aspect ratio is apparent, in line with previous findings (Landreman & Sengupta Reference Landreman and Sengupta2019; Jorge et al. Reference Jorge, Sengupta and Landreman2020a), and a more sophisticated way of generating finite-aspect-ratio equilibria would be necessary (Landreman & Sengupta Reference Landreman and Sengupta2019) to suppress them.

Figure 7. Boozer spectrum of $|\boldsymbol {B}|$ for global equilibria. The plots show the Boozer spectra of $|\boldsymbol {B}|$
 for global equilibria. The plots show the Boozer spectra of $|\boldsymbol {B}|$ as a function of the normalized toroidal flux $s=\psi /\psi _b$
 as a function of the normalized toroidal flux $s=\psi /\psi _b$ , for the configurations constructed at $\psi =0.001$
, for the configurations constructed at $\psi =0.001$ (a) and $\psi =0.02$
 (a) and $\psi =0.02$ (b). The spectra were computed using the BOOZXFORM code.
 (b). The spectra were computed using the BOOZXFORM code.
8 Discussion
In this work, we have presented an asymptotic theory of MHS equilibrium in a stellarator using the NAE scheme. Our approach generalizes previous work in this area by allowing MHS fields of arbitrary plasma beta. We have shown that the analyticity property of the vacuum fields, i.e. the existence of regular power-series expansions in the vicinity of the magnetic axis, can be retained if one allows for current profiles with regular power-series expansions near the axis. We have studied the vacuum limit carefully as a model for the force-free and MHS cases. We have shown that near the axis, we can transform to variables that allow us to describe the force-free and MHS systems analogous to the vacuum system.
We have demonstrated that one can carry out the NAE formally to all orders by following the same steps. The zeroth step consists of solving a MDE for the pressure-driven part of the current. We have shown how using the leading-order Birkhoff normal form considerably simplifies this calculation. The first step is to solve a Poisson equation for a scalar representing the magnetic scalar potential in the vacuum limit. The second step is to solve another MDE to obtain the flux function up to a homogeneous solution of the MDE. We fix this homogeneous solution by requiring the periodicity of physical quantities. Finally, with the help of the flux function and the solution to the Poisson equation, we can obtain the field line label through a simple integral over the poloidal angle up to a function of only the toroidal variable. We use the poloidally averaged MDE for the field line label to fix this unknown. The procedure described above is repeated in each order. We have given the complete details of the first two orders of the NAE for vacuum fields in Appendix F followed by force-free and MHS fields in Appendix G.
We have illustrated the finite beta near-axis procedure obtained through the Mercier-Weitzer formalism for various problems. We have treated the case of vacuum fields with a nearly circular cross-section in detail in § 6.1. The force-free and finite beta analogues of this example are given in Appendix H.2. Furthermore, the special cases of axisymmetry with Solov'ev profiles and magnetic axis with constant torsion are discussed in § 6.2. The analytical details of these examples are to be found in Appendices H.3 and H.4.
The discussion of physical quantities, such as the magnetic well and the magnetic shear, which play a crucial role in MHS equilibrium and stability, is out of the scope of the present work. Analytical expression of the near-axis magnetic shear has already been obtained in inverse coordinates (Rodríguez et al. Reference Rodríguez, Sengupta and Bhattacharjee2022), while the near-axis magnetic well has been studied in Landreman & Jorge (Reference Landreman and Jorge2020) and Kim et al. (Reference Kim, Jorge and Dorland2021). In subsequent work, we shall calculate the magnetic well and the shear in direct coordinates using the formalism developed in this work.
The calculations presented here, while lengthy, move forward the NAE stellarator optimization programme significantly by presenting reduced analytical models that can be automated in fast numerical optimization suites for stellarator design and for testing numerical codes.
Acknowledgements
W.S. would like to thank H. Weitzner, H. Mynick, S. Hudson, P. Helander, G.G. Plunck, W. Dorland, A. Cerfon, F.P. Diaz, E.J. Paul, N. Nikulsin, A. Wright and G. Roberg-Clark for helpful discussions and feedback.
Editor P. Helander thanks the referees for their advice in evaluating this article.
Funding
This research was supported by a grant from the Simons Foundation/SFARI (560651, AB), and the Department of Energy award no. DE-SC0024548. E.R. was supported by a grant by Alexander-von-Humboldt-Stiftung, Bonn, Germany, through a postdoctoral research fellowship.
Declaration of interests
The authors report no conflict of interest.
Data availability
The data that support the findings of this study are available from the corresponding author upon reasonable request.
Appendix A. Choice of toroidal and poloidal flux label
 We shall now show that by choosing $\psi$ to be the toroidal flux, we can set $f(\psi )$
 to be the toroidal flux, we can set $f(\psi )$ to unity in (2.11b). Let $\psi$
 to unity in (2.11b). Let $\psi$ be the net toroidal flux,
 be the net toroidal flux,
 
where
 
We can obtain the following expression for $\boldsymbol {B}$ from (2.2a) and (2.11b):
 from (2.2a) and (2.11b):
 
The last term in (A3) vanishes on averaging by construction and does not contribute to any net flux. From the expression of the toroidal flux,
 
it follows that the poloidal component of the secular part of $\alpha$ is simply $\theta$
 is simply $\theta$ , i.e.
, i.e.
 
Similarly, we can show that the poloidal flux is given by
 
which yields the common interpretation of the rotational transform as
 
Appendix B. Vacuum and MHS Characteristics
 To understand the relationship between the consistency conditions (3.4), (3.5a) and (3.5b), we approach the vacuum system with nested flux surfaces from the point of view of characteristics. Equations (3.5) define the characteristics of the vacuum limit of MHS. As shown in Appendix B, the characteristic surfaces, given by $\varOmega (\boldsymbol {r})$ with $\boldsymbol {k}=\boldsymbol {\nabla } \varOmega$
 with $\boldsymbol {k}=\boldsymbol {\nabla } \varOmega$ , in the vacuum limit satisfy
, in the vacuum limit satisfy
 
From (B1), we find that for vacuum fields with nested flux surfaces, there are both elliptic characteristics ($k^2=0$ ) mixed with one hyperbolic characteristic ($\boldsymbol {k}\boldsymbol {\cdot }\boldsymbol {B}=0$
) mixed with one hyperbolic characteristic ($\boldsymbol {k}\boldsymbol {\cdot }\boldsymbol {B}=0$ ). If the vacuum system of equations satisfies the Laplace equation (3.4) and either of the (3.5), then the other consistency condition is satisfied automatically.
). If the vacuum system of equations satisfies the Laplace equation (3.4) and either of the (3.5), then the other consistency condition is satisfied automatically.
We shall derive (B1) for the vacuum limit of the ideal MHS. The full MHS limit was discussed in Weitzner (Reference Weitzner2014). Let
 
represent vacuum magnetic fields that possess nested flux surfaces. We shall look for solutions close to (B2) such that
 
It follows that
 
Going to Fourier space (denoted by hats), we find
 
which shows that the dispersion relation is given by $(\boldsymbol {B}_0\boldsymbol {\cdot } \boldsymbol {k}) k^2=0$ .
.
In § 3.2, we describe an alternative set of equations where we solve the Laplace equation ($k^2=0$ ) and the MDE for $\psi$
) and the MDE for $\psi$ $(\boldsymbol {k}\boldsymbol {\cdot } \boldsymbol {B}=0)$
 $(\boldsymbol {k}\boldsymbol {\cdot } \boldsymbol {B}=0)$ . The quantity $\alpha$
. The quantity $\alpha$ is obtained from these quantities. Since we do not solve the MDE for $\alpha$
 is obtained from these quantities. Since we do not solve the MDE for $\alpha$ , the characteristics satisfy (B1).
, the characteristics satisfy (B1).
Appendix C. Leading-order normal forms and MDEs
We shall now derive the leading-order normal form identities (3.77). Before we do so, we need some basic relations that can be easily obtained from the following leading-order normal form definitions (3.73a,b) and (3.73a,b):
 
 
 
Starting from the $\varPhi ^{(2)}$ expression (3.14) and
 expression (3.14) and
 
and using the identities (C1), we obtain another useful identity
 
We shall now calculate $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(n+2)}_0 z_\mathcal {N}$ , where $z_\mathcal {N}$
, where $z_\mathcal {N}$ is given by
 is given by
 
It is convenient to split the MDO $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(n+2)}_0$ , as follows:
, as follows:
 
 From the definition of $z_\mathcal {N}$ (C4) we find that
 (C4) we find that
 
Let us calculate each of the terms in (C6). From the relation between $\varTheta$ and $u$
 and $u$ (C1) it follows that
 (C1) it follows that
 
 
From the identity (C3), we find that
 
From the MDE for $\psi ^{(2)}$ (3.12) we get
 (3.12) we get
 
 
Thus,
 
 
 
Now, using (C10) it follows that
 
which proves (3.77a). Identity (3.77b) follows after straightforward algebra from (3.77a) and the expression for $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(n+2)}_0$ given in (C5).
 given in (C5).
 From (C10) we find that in general $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(1)}_0$ acting on $z_\mathcal {N}$
 acting on $z_\mathcal {N}$ for $n+2\neq -1$
 for $n+2\neq -1$ , mixes the different poloidal harmonics because of the $\varPhi ^{(2)}$
, mixes the different poloidal harmonics because of the $\varPhi ^{(2)}$ term. However, for $n+2=1$
 term. However, for $n+2=1$ we have
 we have
 
 
which shows that the action of $(\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla })^{(1)}_0$ on $z_\mathcal {N},\bar {z}_\mathcal {N}$
 on $z_\mathcal {N},\bar {z}_\mathcal {N}$ is to simplify a multiplication with a $\omega$
 is to simplify a multiplication with a $\omega$ independent function. Furthermore, (3.77b) implies that
 independent function. Furthermore, (3.77b) implies that
 
together with its complex-conjugate equation.
 We now point out the changes necessary to generalize the above leading-order normal form results to force-free and MHS fields. Firstly, $\varPhi ^{(2)}$ in (C2) and elsewhere need to be replaced by $\xi ^{(2)}$
 in (C2) and elsewhere need to be replaced by $\xi ^{(2)}$ . The force-free and MHS form of the MDO (4.29) has to be used. Next, the identity that replaces (C3) is
. The force-free and MHS form of the MDO (4.29) has to be used. Next, the identity that replaces (C3) is
 
The rest of the derivation goes through with the replacements of $\varPhi ^{(2)}$ by $\xi ^{(2)}$
 by $\xi ^{(2)}$ and $\varOmega _0$
 and $\varOmega _0$ by its new definition given in (C15).
 by its new definition given in (C15).
Appendix D. Structure of the vacuum MDEs
 In the vacuum limit, the equation $\boldsymbol {B}\boldsymbol {\cdot }\boldsymbol {\nabla }\chi =0$ for a function $\chi$
 for a function $\chi$ takes the form
 takes the form
 
where
 
D.1 The MDE for $\psi$
 We first consider the case $\chi =\psi$ . Using the NAEs (3.7) and (D2) we find
. Using the NAEs (3.7) and (D2) we find
 
Separating the $i=m=0$ component of (D3) from the rest, we obtain
 component of (D3) from the rest, we obtain
 
The first term follows from the $i=m=0$ component, and $F^{n+2}_\psi$
 component, and $F^{n+2}_\psi$ is the collective of the rest of the terms.
 is the collective of the rest of the terms.
 As shown in details in Jorge et al. (Reference Jorge, Sengupta and Landreman2020b), if for all $n$ , $\varPhi ^{(n+2)},\psi ^{(n+2)}$
, $\varPhi ^{(n+2)},\psi ^{(n+2)}$ are of the form (3.45), then products of terms $\varPhi ^{(i)}\psi ^{(n-i)}$
 are of the form (3.45), then products of terms $\varPhi ^{(i)}\psi ^{(n-i)}$ are also periodic in $u$
 are also periodic in $u$ with harmonics ranging from zero or one (depending on whether $n$
 with harmonics ranging from zero or one (depending on whether $n$ is even or not ) to a maximum of $n+2$
 is even or not ) to a maximum of $n+2$ . Perhaps, an easy way to demonstrate this is to use complex variables instead of sinusoidal functions.
. Perhaps, an easy way to demonstrate this is to use complex variables instead of sinusoidal functions.
 We shall now assume that for each order $q\leq n+2$ , we are led to a forcing term in (D4), which has harmonics up to $q$
, we are led to a forcing term in (D4), which has harmonics up to $q$ . Thus, $F^{(n+2)}_\psi$
. Thus, $F^{(n+2)}_\psi$ has $n+2$
 has $n+2$ harmonics and the solution for $\psi ^{(n+2)}$
 harmonics and the solution for $\psi ^{(n+2)}$ is given by (3.58) which is doubly periodic and has at most $n+2$
 is given by (3.58) which is doubly periodic and has at most $n+2$ harmonics in the poloidal angle.
 harmonics in the poloidal angle.
D.2 Analysis of the magnetic differential equation for $\alpha$
 We now bring the MDE for $\alpha$ (3.27) to the standard form of MDE (3.48) by using (3.11b), (3.11c) and (3.11a) to replace the angular derivatives of $\alpha ^{(0)}$
 (3.27) to the standard form of MDE (3.48) by using (3.11b), (3.11c) and (3.11a) to replace the angular derivatives of $\alpha ^{(0)}$ and $\psi ^{(2)}$
 and $\psi ^{(2)}$ in (3.27) by derivatives of $\varPhi ^{(0)}$
 in (3.27) by derivatives of $\varPhi ^{(0)}$ and $\varPhi ^{(2)}$
 and $\varPhi ^{(2)}$ . The resultant form of the MDE is
. The resultant form of the MDE is
 
where
 
The homogeneous solution of (D5) is given by
 
However, unlike $\psi ^{(n+2)}$ , $\alpha ^{(n)}$
, $\alpha ^{(n)}$ does not satisfy the analyticity condition (3.72).
 does not satisfy the analyticity condition (3.72).
 Since $\psi ^{(2)}$ is non-vanishing, we can define a quantity $\mathcal {A}^{(n+2)}$
 is non-vanishing, we can define a quantity $\mathcal {A}^{(n+2)}$ such that
 such that
 
Using the identity (3.12) we can show that (D5) implies that
 
 It can be shown inductively (details given in § D.2.1) that $F_\mathcal {A}^{(3n)}$ , at each order $n$
, at each order $n$ , has at most $(3n)$
, has at most $(3n)$ harmonics in $u$
 harmonics in $u$ . Furthermore, just like $\varPhi ^{(n+2)}, F_\mathcal {A}^{(3n)}$
. Furthermore, just like $\varPhi ^{(n+2)}, F_\mathcal {A}^{(3n)}$ has even (odd) harmonics for even (odd) $n$
 has even (odd) harmonics for even (odd) $n$ . We also note that (3.49) has even parity with respect to both $\omega$
. We also note that (3.49) has even parity with respect to both $\omega$ and $\ell$
 and $\ell$ and has only second (even) harmonics as coefficients. Since $\psi ^{(2)}$
 and has only second (even) harmonics as coefficients. Since $\psi ^{(2)}$ also has even harmonics, (D5) implies that $\mathcal {A}^{(3n)},\alpha ^{(n)}$
 also has even harmonics, (D5) implies that $\mathcal {A}^{(3n)},\alpha ^{(n)}$ will have odd (even) harmonics if $F_\mathcal {A}^{(3n)}$
 will have odd (even) harmonics if $F_\mathcal {A}^{(3n)}$ is odd (even). It follows that the solution $\mathcal {A}^{(3n)}$
 is odd (even). It follows that the solution $\mathcal {A}^{(3n)}$ must be of the same form as $\chi ^{(3n)}$
 must be of the same form as $\chi ^{(3n)}$ in (3.57) since (D9) is the same as (3.48) with $n$
 in (3.57) since (D9) is the same as (3.48) with $n$ replaced by $3n$
 replaced by $3n$ .
.
 There is an alternative approach to solving the MDE that is particularly useful if the lowest-order $\alpha ^{(0)}$ is rational. We first note that the MDE in the form
 is rational. We first note that the MDE in the form
 
can be rewritten as
 
Integrating along a constant $\alpha ^{(0)}$ line, we get
 line, we get
 
If the lowest-order field lines are closed, ${\mathfrak {a}}_H^{(n)}\left (\alpha ^{(0)}\right )$ is an arbitrary function periodic in $\alpha ^{(0)}$
 is an arbitrary function periodic in $\alpha ^{(0)}$ , which is related to the $n{\textrm {th}}$
, which is related to the $n{\textrm {th}}$ derivative of the rotational transform.
 derivative of the rotational transform.
 In summary, we find that at $O(n)$ , $\alpha ^{(n)}$
, $\alpha ^{(n)}$ is of the form $\mathcal {A}^{(3n)}/\left ( 2\psi ^{(2)}\right )^n$
 is of the form $\mathcal {A}^{(3n)}/\left ( 2\psi ^{(2)}\right )^n$ , where determining $\mathcal {A}^{(3n)}$
, where determining $\mathcal {A}^{(3n)}$ involves solving $3n$
 involves solving $3n$ coupled ODEs. Clearly, it is easier to solve the MDE for $\psi ^{(n+2)}$
 coupled ODEs. Clearly, it is easier to solve the MDE for $\psi ^{(n+2)}$ and obtain $\alpha ^{(n)}$
 and obtain $\alpha ^{(n)}$ from it.
 from it.
D.2.1 Details related to the MDE for $\alpha$
 The analysis for $\alpha ^{(n)}$ proceeds in a similar manner. We can show that
 proceeds in a similar manner. We can show that
 
Once again separating the $i=m=0$ piece from the rest of the terms in (D13), multiplying by $2\psi ^{(2)}$
 piece from the rest of the terms in (D13), multiplying by $2\psi ^{(2)}$ and using (3.12), we get
 and using (3.12), we get
 
As before, $F^{n+2}_\alpha$ denotes the $i\neq 0, m\neq 0$
 denotes the $i\neq 0, m\neq 0$ terms of (D13). We note that $F^{n+2}_\alpha$
 terms of (D13). We note that $F^{n+2}_\alpha$ has derivatives of various $\alpha ^{(i)}$
 has derivatives of various $\alpha ^{(i)}$ and is not a priori periodic.
 and is not a priori periodic.
Equivalently, in terms of
 
the MDE (D14) can be written as
 
Provided $F^{(3n)}_\mathcal {A}$ is a sum of sinusoidal functions of $u$
 is a sum of sinusoidal functions of $u$ with a maximum frequency of $3n$
 with a maximum frequency of $3n$ , the solution of $\mathcal {A}^{(3n)}$
, the solution of $\mathcal {A}^{(3n)}$ is of the same form. Note that this requires that $F^{(3n)}_\mathcal {A}$
 is of the same form. Note that this requires that $F^{(3n)}_\mathcal {A}$ does not have any denominators such as powers of $(2\psi ^{(2)})$
 does not have any denominators such as powers of $(2\psi ^{(2)})$ .
.
Substituting (D15) into (D13), we find that
 
We now assume that $\mathcal {A}^{3(n-j)}, j=1,\ldots,n$ have no factors of $2\psi ^{(2)}$
 have no factors of $2\psi ^{(2)}$ in the denominator and are sums of harmonics up to $3(n-j)$
 in the denominator and are sums of harmonics up to $3(n-j)$ . This is certainly true for $n=1$
. This is certainly true for $n=1$ .
.
 Firstly, we observe that $F^{(3n)}_\mathcal {A}$ in (D17) is a sum of harmonics provided our assumption regarding $\mathcal {A}^{3(n-j)}$
 in (D17) is a sum of harmonics provided our assumption regarding $\mathcal {A}^{3(n-j)}$ hold. Next, we observe that the highest harmonic comes from the term $\mathcal {A}^{3(n-1)}$
 hold. Next, we observe that the highest harmonic comes from the term $\mathcal {A}^{3(n-1)}$ followed by $\mathcal {A}^{3(n-2)}$
 followed by $\mathcal {A}^{3(n-2)}$ , etc. Since $\psi ^{(2)},\varPhi ^{(3)}$
, etc. Since $\psi ^{(2)},\varPhi ^{(3)}$ has up to second and third harmonics, and $\mathcal {A}^{3(n-1)}$
 has up to second and third harmonics, and $\mathcal {A}^{3(n-1)}$ has up to $3(n-1)$
 has up to $3(n-1)$ by assumption, a straightforward analysis suggests that $F^{(3n)}_\mathcal {A}$
 by assumption, a straightforward analysis suggests that $F^{(3n)}_\mathcal {A}$ can have up to $3n+2$
 can have up to $3n+2$ harmonics. However, a detailed calculation shows that
 harmonics. However, a detailed calculation shows that
 
has only up to $3n$ harmonics. To verify this consider the highest frequencies from $\psi ^{(2)},\varPhi ^{(3)},\mathcal {A}^{3(n-1)}$
 harmonics. To verify this consider the highest frequencies from $\psi ^{(2)},\varPhi ^{(3)},\mathcal {A}^{3(n-1)}$ , which are 2, 3 and $3(n-1)$
, which are 2, 3 and $3(n-1)$ , beating together. The contribution to $T_{3(n-1)}$
, beating together. The contribution to $T_{3(n-1)}$ vanishes since
 vanishes since
 
Therefore, both $F_\mathcal {A}^{3(n)}$ and the solution to (D16) $\mathcal {A}^{3(n)}$
 and the solution to (D16) $\mathcal {A}^{3(n)}$ (D16) have up to $3n$
 (D16) have up to $3n$ harmonics, which is what we wanted to prove.
 harmonics, which is what we wanted to prove.
 We now make an important observation regarding the parity of the harmonics in $\mathcal {A}^{3(n)}$ . We use (D17) and the fact that $\varPhi ^{(3)}$
. We use (D17) and the fact that $\varPhi ^{(3)}$ and $\psi ^{(2)}$
 and $\psi ^{(2)}$ have odd and even harmonics. We note that if $n$
 have odd and even harmonics. We note that if $n$ is even (odd) and $\mathcal {A}^{3(n-1)}$
 is even (odd) and $\mathcal {A}^{3(n-1)}$ has only odd (even) modes then $F^{(3n)}_\mathcal {A}$
 has only odd (even) modes then $F^{(3n)}_\mathcal {A}$ has even (odd) modes, which implies that $\mathcal {A}^{3(n)}$
 has even (odd) modes, which implies that $\mathcal {A}^{3(n)}$ has also even (odd) harmonics in $u$
 has also even (odd) harmonics in $u$ . Since $\mathcal {A}^{(3)}$
. Since $\mathcal {A}^{(3)}$ has odd harmonics, $\mathcal {A}^{(3n)}$
 has odd harmonics, $\mathcal {A}^{(3n)}$ will have only even (odd) harmonics if $n$
 will have only even (odd) harmonics if $n$ is even (odd).
 is even (odd).
Appendix E. Structure of force-free and MHS NAE equations
Owing to the similarity of the vacuum and the force-free and MHS NAE systems, many of the mathematical subtleties can be addressed within the vacuum framework. Two questions remain: whether the logarithmic singularities can occur and whether the periodicity requirements (3.6) are violated. We can show that both of these problems are avoided within this model.
Firstly, one can retrace the steps of the vacuum case (Jorge et al. Reference Jorge, Sengupta and Landreman2020b) but using $\xi$ instead of $\varPhi$
 instead of $\varPhi$ to show that the resonances never occur. The critical step here is realizing that the deviation of $\xi$
 to show that the resonances never occur. The critical step here is realizing that the deviation of $\xi$ from $\varPhi$
 from $\varPhi$ is at least second order. Thus, the terms $\xi ^{(n+2)}$
 is at least second order. Thus, the terms $\xi ^{(n+2)}$ are always separated from $\xi ^{(n)}$
 are always separated from $\xi ^{(n)}$ and lower-order quantities by two poloidal harmonics, avoiding the resonance.
 and lower-order quantities by two poloidal harmonics, avoiding the resonance.
To justify our assertion, let us look carefully at the Poisson equations. Beginning with the force-free case, we can rewrite (4.23) as
 
where,
 
We can show that $\mathcal {T}_\varXi = O(\rho ^4)$ using
 using
 
It also follows from $\xi ^{(0)}=\varPhi _0(\ell ), \xi ^{(1)}=0$ that
 that
 
In the case of MHS, we can replace (E1) by
 
where the additional terms $\mathcal {T}_\mathcal {Y}, \mathcal {T}_\mathcal {X}$ are given by
 are given by
 
From the expansions (5.18), it follows that
 
Now, the first term in both (E1) and (E5) is the only term that persists in the vacuum limit. From equation (3.15) of Jorge et al. (Reference Jorge, Sengupta and Landreman2020b), we find that
 
Since the current driven terms $\mathcal {T}_\varLambda, \mathcal {T}_\varXi, \mathcal {T}_\mathcal {X}, \mathcal {T}_\mathcal {Y}$ are all at least $O(\rho ^3)$
 are all at least $O(\rho ^3)$ , to $O(\rho ^n)$
, to $O(\rho ^n)$ only $\xi ^{(n-3)}$
 only $\xi ^{(n-3)}$ or lower can come from them. Therefore, for each $n$
 or lower can come from them. Therefore, for each $n$ , the only terms in (E1) to $O(\rho ^n)$
, the only terms in (E1) to $O(\rho ^n)$ that have a $\xi ^{(n)}$
 that have a $\xi ^{(n)}$ term come from the vacuum term. Thus, we can solve the driven harmonic oscillator equation
 term come from the vacuum term. Thus, we can solve the driven harmonic oscillator equation
 
order by order without any resonance from the forcing term. Note that fundamental to this argument is the assumption that the current distributions are smooth and can be expanded in power series (5.9). Thus, provided this assumption holds, a regular power series solution of the fields holds too. In turn, the plasma currents obtained from the smooth fields will satisfy the regularity condition (5.9).
To answer the second question, we note that the transformation from $\varPhi$ to $\xi$
 to $\xi$ is through a linear integral operator on $\alpha$
 is through a linear integral operator on $\alpha$ . Since the integral is in $\rho$
. Since the integral is in $\rho$ , the secular terms are not affected. The essential similarity with the vacuum case as far as dealing with the MDE for $\psi$
, the secular terms are not affected. The essential similarity with the vacuum case as far as dealing with the MDE for $\psi$ and the $\alpha _{,\omega }$
 and the $\alpha _{,\omega }$ equation means that we can impose the periodicity constraints (3.42) order by order in the same way as in the vacuum case. Thus, the single-valued nature of $\boldsymbol {B},\boldsymbol {J}$
 equation means that we can impose the periodicity constraints (3.42) order by order in the same way as in the vacuum case. Thus, the single-valued nature of $\boldsymbol {B},\boldsymbol {J}$ can be maintained order by order.
 can be maintained order by order.
Appendix F. The NAE vacuum: general first-order system (an order beyond the rotating ellipse solution)
 To $O(\rho )$ the NAE equations are
 the NAE equations are
 
 
 
Finally, we have the MDE for $\alpha ^{(1)}$ :
:
 
In the following, we explicitly solve the general first-order system and provide all the details of the steps involved. We extensively use the lower-order equations and identities (3.11), (3.14) and (3.15).
F.1 Step I: calculation of $\varPhi ^{(3)}$
 Equation (F1a) is the Poisson equation for $\varPhi ^{(3)}$ whose solution we now discuss. The solution of (F1a) reads
 whose solution we now discuss. The solution of (F1a) reads
 
where, $f^{(3)}_{c3}(\ell ),f^{(3)}_{s3}(\ell )$ are the free-functions. As before, we assume that the free-functions are of the Soloviev-like form
 are the free-functions. As before, we assume that the free-functions are of the Soloviev-like form
 
F.2 Step II: calculation of $\psi ^{(3)}$ using the leading-order normal forms
 using the leading-order normal forms
 Now let us turn to the MDE for $\psi ^{(3)}$ given by (F1b). Using the definition (3.49), we can rewrite (F1b) as
 given by (F1b). Using the definition (3.49), we can rewrite (F1b) as
 
After straightforward algebra the forcing term $F^{(3)}_\psi$ given in (F1b) reduces to
 given in (F1b) reduces to
 
 
 
 
 
As suggested by the forcing term (F6), we now look for a solution of the MDE (F5) of the form
 
Substituting (F7) in (F5), we obtain the following coupled ODEs
 
 
 
 
 To decouple (F8) we will use the third-order complex normal form. As discussed in § 3.6.4, at $O(n)$ , instead of a Fourier series of $\psi ^{(n+2)}$
, instead of a Fourier series of $\psi ^{(n+2)}$ with $(n+2)$
 with $(n+2)$ poloidal harmonics, one could also look for solutions that are polynomial of order $(n+2)$
 poloidal harmonics, one could also look for solutions that are polynomial of order $(n+2)$ in the complex leading-order normal form coordinates in the form (3.76). The major advantage of the complex leading-order normal form (3.76) is that it diagonalizes the MDO, thereby significantly simplifying the analysis. The complex leading-order normal form for $\psi ^{(3)}$
 in the complex leading-order normal form coordinates in the form (3.76). The major advantage of the complex leading-order normal form (3.76) is that it diagonalizes the MDO, thereby significantly simplifying the analysis. The complex leading-order normal form for $\psi ^{(3)}$ is given by
 is given by
 
We note here that the choice of numerical factors such as $\pm 1/8$ multiplying $\mathcal {Z}_{\psi 1},\mathcal {Z}_{\psi 3}$
 multiplying $\mathcal {Z}_{\psi 1},\mathcal {Z}_{\psi 3}$ are arbitrary. We have made the choices such that our results are as close as possible to Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970). Equating the two equivalent representations of $\psi ^{(3)}$
 are arbitrary. We have made the choices such that our results are as close as possible to Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970). Equating the two equivalent representations of $\psi ^{(3)}$ (F7) (Fourier), and (F9) (complex leading-order normal form), using the definition of the complex leading-order normal form,
 (F7) (Fourier), and (F9) (complex leading-order normal form), using the definition of the complex leading-order normal form,
 
and the useful identities (with $\varepsilon =\tanh {\eta }$ )
)
 
we find that
 
 
 
 
The coupled ODEs (F8) are now replaced by two decoupled complex ODEs for $\mathcal {Z}_{\psi 1},\mathcal {Z}_{\psi 3}$ ,
,
 
where
 
 
we can bring $\mathcal {F}_{\psi 1}, \mathcal {F}_{\psi 3}$ to the following form:
 to the following form:
 
The solution of (F16) subject to periodic boundary condition in $\ell$ is straightforward to obtain and has been discussed in Mercier (Reference Mercier1964), Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970) and Jorge et al. (Reference Jorge, Sengupta and Landreman2020b). We shall omit the derivation.
 is straightforward to obtain and has been discussed in Mercier (Reference Mercier1964), Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970) and Jorge et al. (Reference Jorge, Sengupta and Landreman2020b). We shall omit the derivation.
 Our results given in (F15) match with Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970) (see § 6.2 on p. 60 of Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970)) when accounting for the slight modification of the form of the free functions (3.70). To show that our diagonalization approach based on the complex leading-order normal form is indeed the same as the Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970) approach, we take a closer look at the diagonalization approach in Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970), which uses the so-called ‘rotating coordinates’ (3.19a,b), $(X_\mathcal {N}, Y_\mathcal {N})$ , with $\psi ^{(3)}$
, with $\psi ^{(3)}$ given by the following third-order homogeneous polynomial in $(X_\mathcal {N},Y_\mathcal {N})$
 given by the following third-order homogeneous polynomial in $(X_\mathcal {N},Y_\mathcal {N})$ :
:
 
which they obtained assuming analyticity. Using (F20), (3.19a,b) and standard trigonometric identities involving third harmonics, we can show that (F19) is identical to (F7) provided
 
The equations for $\zeta ^{(3)}_i$ then take the form
 then take the form
 
 
 
 
Compared with (F8), (F21) is a step forward in terms of simplification. In particular, all the $f^{(2)}_{c2},\eta '$ terms drop out. Next, Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970) define the complex variables,
 terms drop out. Next, Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970) define the complex variables,
 
 
which from (F21) can be seen to satisfy the decoupled complex ODEs (F16). Finally, the variables are given by
 
Besides extending the pioneering approach of Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970) to MHS fields, our method also systematizes their approach so that we can avoid the intermediate variables $\zeta _i, (i=1,2,3,4)$ . This is particularly needed for going to arbitrary orders in $n$
. This is particularly needed for going to arbitrary orders in $n$ , where the coefficients that connect the variables $\zeta _i$
, where the coefficients that connect the variables $\zeta _i$ to $\mathcal {Z}_{\psi i}$
 to $\mathcal {Z}_{\psi i}$ are not known a priori.
 are not known a priori.
F.3 Step III and IV: calculation of $\alpha ^{(1)}$
 We shall now solve (F1c) for $\alpha ^{(1)}$ . Rewriting (F1c) as
. Rewriting (F1c) as
 
and upon using (F7), the expression for $\mathcal {T}^{(3)}_\alpha$ can be further simplified to
 can be further simplified to
 
Using the identity (with $b/a=\varepsilon =\tanh {\eta }$ )
)
 
we can integrate equation (F1c) to obtain the following expression for $\alpha ^{(1)}$ :
:
 
 
 
 
 To determine ${\bar {a}}^{(1)}$ we need the MDE (F2) averaged over $\omega$
 we need the MDE (F2) averaged over $\omega$ . The forcing term $F^{(1)}_\alpha$
. The forcing term $F^{(1)}_\alpha$ in (F2) can be written down explicitly in the form
 in (F2) can be written down explicitly in the form
 
 
 
 
 
Since only odd harmonics are involved in $F^{(1)}_\alpha$ , the poloidal average of (F2) is zero, which implies ${\bar {a}}^{(1)}=0$
, the poloidal average of (F2) is zero, which implies ${\bar {a}}^{(1)}=0$ .
.
Before we end the discussion on the first-order solutions, we note that it is also possible to express (F2) in the same form as (F5), i.e.
 
 Therefore, we could have also solved the MDE for $\alpha ^{(1)}$ instead of $\psi ^{(3)}$
 instead of $\psi ^{(3)}$ .
.
Appendix G. The NAE force-free and MHS: first-order
We now provide the details of the first-order NAE for finite beta MHS. The force-free limit can be obtained by setting the pressure-driven current potentials, $G^{(0)},G^{(1)}$ , to zero.
, to zero.
 To the relevant order the functions $\mathcal {Y},\mathcal {X},\varXi,\mathcal {W}$ are
 are
 
The first-order NAE MHS system is given by
 
 
 
 
 
Here, the MDO is of the form (4.29), i.e.
 
and the forcing terms $F^{(1)}_G,F^{(3)}_\xi,F^{(3)}_\psi,F^{(1)}_\alpha$ are given by
 are given by
 
 
 
 
We recover the vacuum equations (F1) in the limit $p^{(2)}\to 0, G^{(1)}\to 0,\lambda _0\to 0, \xi \to \varPhi$ .
.
We follow the same steps as outlined in the vacuum case (see Appendix F) with the addition of Step 0, which involves the solution of the MDE for $G^{(1)}$ .
.
G.1 Step 0: calculation of $G^{(1)}$
 We extensively use the leading-order normal form variables and their identities (see Appendix C) to solve the MDE for $G^{(1)}$ . We first note that $\cos \theta = \cos {(u-\delta (\ell ))}$
. We first note that $\cos \theta = \cos {(u-\delta (\ell ))}$ . Using the definition of the leading-order normal form variable $z_\mathcal {N}$
. Using the definition of the leading-order normal form variable $z_\mathcal {N}$ , it is straightforward to show that
, it is straightforward to show that
 
where ‘c.c.’ stands for complex conjugate. Therefore, the forcing term $F^{(1)}_G$ is linear in $z_\mathcal {N}$
 is linear in $z_\mathcal {N}$ . The form of the forcing term (G5) and the identity (C14),
. The form of the forcing term (G5) and the identity (C14),
 
suggests that $G^{(1)}$ must be of the form
 must be of the form
 
where
 
is a complex function of $\ell$ . Substituting (G6) in the MDE for $G^{(1)}$
. Substituting (G6) in the MDE for $G^{(1)}$ , and using (G5) and (C14), we get
, and using (G5) and (C14), we get
 
With the solution of (G8) we can reconstruct $G^{(1)}$ in terms of Mercier variables as
 in terms of Mercier variables as
 
G.2 Step 1: calculation of $\xi ^{(3)}$
 This step is identical to the vacuum case. The only differences are the additional terms in the forcing $F_\xi$ that arise from currents. The solution of (G2b) is
 that arise from currents. The solution of (G2b) is
 
where $f^{(3)}_{c3}(\ell ),f^{(3)}_{s3}(\ell )$ are the free functions. The free functions are chosen to be of the Soloviev-like form
 are the free functions. The free functions are chosen to be of the Soloviev-like form
 
G.3 Step 2: calculation of $\psi ^{(3)}$
The solution of (G2c) can be obtained by proceeding exactly as in the vacuum case discussed in § F.2. Therefore, we only provide essential details here.
 The forcing $F^{(3)}_\psi$ given in (G4c) reduces to
 given in (G4c) reduces to
 
 
 
 
 
The rest of the calculation follows the vacuum case with the replacement
 
G.4 Step III and IV: calculation of $\alpha ^{(1)}$
 The calculation is once again identical to the vacuum limit. The only difference occurs in the forcing term $F^{(1)}_\alpha$ , which for MHS is given by
, which for MHS is given by
 
 
 
 
 
Appendix H. Various examples of vacuum, force-free and MHS fields
H.1 Vacuum fields with helical symmetry
 While vacuum fields with axisymmetry are trivial, fields with helical symmetry are not. Here, we consider a vacuum field with a magnetic axis with constant curvature and torsion $\kappa _0,\tau _0$ , and hence is a helix with pitch $\tau _0/\kappa _0$
, and hence is a helix with pitch $\tau _0/\kappa _0$ .
.
The magnetic field is assumed to possess helical symmetry, i.e.
 
As a consequence, $(\psi,\varPhi,\alpha )$ must be of the form
 must be of the form
 
Since $\omega$ is not defined on the axis, $B$
 is not defined on the axis, $B$ must be constant on the axis, i.e. $\varPhi _0=B_0 \ell$
 must be constant on the axis, i.e. $\varPhi _0=B_0 \ell$ .
.
The lowest-order solution is given by
 
where, $a,b,B_0,\eta$ are all constants. We can obtain all the next order relevant physical quantities by setting $\kappa,\tau,\varPhi _0',a,b,\delta$
 are all constants. We can obtain all the next order relevant physical quantities by setting $\kappa,\tau,\varPhi _0',a,b,\delta$ to constants. However, we go through the steps again to better illustrate the Mercier–Weitzner formalism through this simple analytically tractable example.
 to constants. However, we go through the steps again to better illustrate the Mercier–Weitzner formalism through this simple analytically tractable example.
 To first order, the Poisson equation for $\varPhi ^{(3)}$ ,
,
 
has a solution of the form
 
with $\varPhi ^{(3)}_{c3},\varPhi ^{(3)}_{s3}$ being the free-functions.
 being the free-functions.
 The MDE for $\psi ^{(3)}$ is
 is
 
with
 
which has only first and third harmonics. Therefore, $\psi ^{(3)}$ must be of the form
 must be of the form
 
Substituting (H8) into (H6) leads to linear algebraic equations with solution
 
We have algebraic equations instead of ODEs because of the continuous (helical) symmetry. Furthermore, because of the helical symmetry we can construct a solution that has odd and even parity in $\varPhi ^{(3)}$ and $\psi ^{(3)}$
 and $\psi ^{(3)}$ by choosing $\varPhi ^{(3)}_{c3}=0$
 by choosing $\varPhi ^{(3)}_{c3}=0$ . The expressions for $\varPhi ^{(3)},\psi ^{(3)}$
. The expressions for $\varPhi ^{(3)},\psi ^{(3)}$ derived above matches with Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970), with
 derived above matches with Solov'ev & Shafranov (Reference Solov'ev and Shafranov1970), with
 
 Proceeding to find $\alpha ^{(1)}$ , from $\varPhi ^{(3)}_{,\ell }$
, from $\varPhi ^{(3)}_{,\ell }$ equation we get
 equation we get
 
Choosing even parity for $\psi ^{(3)}$ and integrating with respect to $\omega$
 and integrating with respect to $\omega$ , we get
, we get
 
with
 
Finally, from the averaged MDE for $\alpha ^{(1)}$ , we find that $\mathfrak {a}^{(1)}$
, we find that $\mathfrak {a}^{(1)}$ is identically zero.
 is identically zero.
H.2 Force-free and MHS fields with nearly circular flux-surfaces
 Similar to the vacuum case, we now consider the circular cross-section case with $a(\ell )=1/2,b(\ell )=0$ in (4.31). As with the previous example, we show all the steps involved. The relevant lowest-order quantities are given by
 in (4.31). As with the previous example, we show all the steps involved. The relevant lowest-order quantities are given by
 
To $O(\rho )$ the equations for $(G^{(1)},\xi ^{(3)},\psi ^{(3)},\alpha ^{(1)})$
 the equations for $(G^{(1)},\xi ^{(3)},\psi ^{(3)},\alpha ^{(1)})$ are
 are
 
 
 
 
Equations (H15d) generalize the vacuum limit (6.2c) by including current terms $\lambda _0,G^{(0)},G^{(1)}$ but preserve the overall form of the equations.
 but preserve the overall form of the equations.
 Equation (H15a) is the MDE for $G^{(1)}$ , whose solution can be obtained following a procedure similar to that we used to solve the MDE for $\psi ^{(3)}$
, whose solution can be obtained following a procedure similar to that we used to solve the MDE for $\psi ^{(3)}$ in (6.1). Substituting the following form for $G^{(1)}$
 in (6.1). Substituting the following form for $G^{(1)}$ ,
,
 
into the MDE (H15a), we get the following coupled ODEs:
 
The coupled ODEs (H17) can be combined into the single complex ODE
 
 With the solution of $G^{(1)}$ in hand, we now turn to (H15b), which is the Poisson equation for $\xi ^{(3)}$
 in hand, we now turn to (H15b), which is the Poisson equation for $\xi ^{(3)}$ . The solution takes the form
. The solution takes the form
 
The reason for choosing the free-function $\xi ^{(3)}_{3H}$ in this particular Soloviev-like form will become apparent when we solve for $\psi ^{(3)}$
 in this particular Soloviev-like form will become apparent when we solve for $\psi ^{(3)}$ . The choice made earlier in (F4) is equivalent to this choice as can be seen through explicit calculation.
. The choice made earlier in (F4) is equivalent to this choice as can be seen through explicit calculation.
 Proceeding to the MDE for $\psi ^{(3)}$ (H15c) we proceed exactly as in the vacuum case to get
 (H15c) we proceed exactly as in the vacuum case to get
 
Due to the choice of the free-function in (H19), we can clearly separate the first and third harmonics of $\psi ^{(3)}$ .The solution of (H15c) can then be written in the form analogous to the vacuum case
.The solution of (H15c) can then be written in the form analogous to the vacuum case
 
where, $\sigma ^{(3)}_{c1}, \sigma ^{(3)}_{s1}$ now satisfy
 now satisfy
 
We then combine (H22) into a single complex equation
 
 The $\alpha$ equation (H15d) is identical to its vacuum analogue (6.2c). Thus, we get the same solution,
 equation (H15d) is identical to its vacuum analogue (6.2c). Thus, we get the same solution,
 
The function $\mathfrak {a}^{(1)}(\ell )$ must be determined from the poloidal average of the MDE for $\alpha ^{(1)}$
 must be determined from the poloidal average of the MDE for $\alpha ^{(1)}$ ,
,
 
Since the poloidal average of (H25) is identically zero, both $Y^{(3)}_H$ and $\mathfrak {a}^{(1)}(\ell )$
 and $\mathfrak {a}^{(1)}(\ell )$ are zero.
 are zero.
 Unlike the vacuum case, the above solutions to $(G^{(1)},\xi ^{(3)},\psi ^{(3)},\alpha ^{(1)})$ do not simplify much when the on-axis magnetic field, $\varPhi _0'=B_0$
 do not simplify much when the on-axis magnetic field, $\varPhi _0'=B_0$ is a constant. However, there are two exceptional cases where further simplification is possible: the axisymmetric limit with a planar circular axis and when the magnetic axis has constant torsion. We shall discuss this limit in the following two examples.
 is a constant. However, there are two exceptional cases where further simplification is possible: the axisymmetric limit with a planar circular axis and when the magnetic axis has constant torsion. We shall discuss this limit in the following two examples.
H.3 Axisymmetric Soloviev profiles with nearly circular cross-section
 Assuming axisymmetry, circular cross-section, planar circular axis $\kappa =1/R_0, \tau =0, \omega =\theta$ and constant $\varPhi _0'=B_0$
 and constant $\varPhi _0'=B_0$ , the analysis carried out in Appendix H.2 simplify considerably. The lowest-order quantities are
, the analysis carried out in Appendix H.2 simplify considerably. The lowest-order quantities are
 
 Using $\partial _\ell =0$ on axisymmetric quantities the next order quantities can be shown to be
 on axisymmetric quantities the next order quantities can be shown to be
 
The force-free limit of (H26) and (H27) is
 
 We first describe the force-free case assuming a circular cross-section and constant on-axis magnetic field strength. This corresponds to $A=1$ in the Soloviev profiles (6.16). Next, we will set the major radius $R_0=1$
 in the Soloviev profiles (6.16). Next, we will set the major radius $R_0=1$ .
.
 To $O(\rho ^4)$ the poloidal and toroidal $\varPsi,\psi$
 the poloidal and toroidal $\varPsi,\psi$ fluxes are
 fluxes are
 
where, $\psi ^{(3)}$ is given by (H28). Expanding $F(\varPsi )$
 is given by (H28). Expanding $F(\varPsi )$ as given in (6.16) we get
 as given in (6.16) we get
 
Now, using the relation between $\lambda (\psi )$ and $F(\psi )$
 and $F(\psi )$ , $-\lambda (\psi )=F'(\varPsi )$
, $-\lambda (\psi )=F'(\varPsi )$ , we get $\lambda _0=1/F_0$
, we get $\lambda _0=1/F_0$ . Since the on-axis axisymmetric $B_0=F_0/R_0$
. Since the on-axis axisymmetric $B_0=F_0/R_0$ , we obtain
, we obtain
 
Therefore, the third-order shaping $\psi ^{(3)}$ is now given by
 is now given by
 
Let us now compare with the one-size model. The exact solution is given by $\varPsi (x,y)$ in (6.14), where
 in (6.14), where
 
For convenience, let us set $B_0=1$ . Since $\iota _0=1/2$
. Since $\iota _0=1/2$ we have $x-1=\rho \cos \theta, y=\rho \sin \theta$
 we have $x-1=\rho \cos \theta, y=\rho \sin \theta$ . To match the NAE expression, we now expand the exact solution (6.14) in power series of $\rho$
. To match the NAE expression, we now expand the exact solution (6.14) in power series of $\rho$ . Imposing that $\varPsi =0$
. Imposing that $\varPsi =0$ on the axis and the cross-section be circular to the lowest order in the $\rho$
 on the axis and the cross-section be circular to the lowest order in the $\rho$ expansion, we get
 expansion, we get
 
 Further using $\iota _0=1/2$ , we get $\varPsi =\psi /2$
, we get $\varPsi =\psi /2$ where
 where
 
Clearly, the power series expansion of the exact solution and the NAE match exactly when
 
 For the MHS case, we use $A=1+\beta, \beta \neq 0$ . For finite values of $\beta$
. For finite values of $\beta$ , $\lambda _0,\iota _0$
, $\lambda _0,\iota _0$ are unchanged. However, the coefficients get modified to
 are unchanged. However, the coefficients get modified to
 
which generalizes (H34). The toroidal flux is now given by
 
The exact match with NAE now occurs when
 
H.4 Axis with constant torsion and nearly circular cross-section
The final example is for an axis that has constant torsion. We also choose the magnetic field magnitude on the axis as a constant, which we normalize to unity. We use the results obtained in Appendix H.2, specializing them to an axis with a constant torsion.
Curves with torsion and curvature both constant are helices, which are not closed. Therefore, closed space curves with constant non-zero torsion must have non-constant curvature. In the following, we choose the magnetic axis to have the form
 
The periodicity of $\kappa (\ell ),\tau (\ell )$ is a necessary but not sufficient condition for the closure of a curve. Periodicity of (H40) then implies that the length of the axis, $L$
 is a necessary but not sufficient condition for the closure of a curve. Periodicity of (H40) then implies that the length of the axis, $L$ , must be an integer multiple of ${\rm \pi}$
, must be an integer multiple of ${\rm \pi}$ , i.e.
, i.e.
 
The lowest-order quantities are
 
To first order, the solution of $G^{(1)}$ is given by (H16) with $\varPhi _0'=1$
 is given by (H16) with $\varPhi _0'=1$ and
 and
 
Note that $G^{(1)}$ thus obtained is automatically periodic; hence, we do not need to separately enforce periodicity by adding a homogeneous solution to the MDE for $G^{(1)}$
 thus obtained is automatically periodic; hence, we do not need to separately enforce periodicity by adding a homogeneous solution to the MDE for $G^{(1)}$ .
.
 The periodic solutions of $\xi ^{(3)}$ and $\psi ^{(3)}$
 and $\psi ^{(3)}$ are given by (H19) and (H21) with $\varPhi _0'=1$
 are given by (H19) and (H21) with $\varPhi _0'=1$ and
 and
 
Finally, $\alpha ^{(1)}$ is given by
 is given by
 
 
 We now present a numerical implementation of a curve of almost constant torsion. we define the axis shape as a closed curve $\boldsymbol {r}_0(\phi )$ parameterized by an angle $\phi$
 parameterized by an angle $\phi$ (cylindrical angle on-axis) such that $\boldsymbol {r}_0 = R(\phi ) \boldsymbol {e}_R + Z(\phi ) \boldsymbol {e}_Z$
 (cylindrical angle on-axis) such that $\boldsymbol {r}_0 = R(\phi ) \boldsymbol {e}_R + Z(\phi ) \boldsymbol {e}_Z$ with $\boldsymbol {e}_R$
 with $\boldsymbol {e}_R$ and $\boldsymbol {e}_Z$
 and $\boldsymbol {e}_Z$ the radial and vertical unit vectors in cylindrical coordinates, respectively. In order to ensure stellarator symmetry and field period symmetry, i.e. $R(\phi )=R(-\phi )=R(\phi +2{\rm \pi} /n_{fp})$
 the radial and vertical unit vectors in cylindrical coordinates, respectively. In order to ensure stellarator symmetry and field period symmetry, i.e. $R(\phi )=R(-\phi )=R(\phi +2{\rm \pi} /n_{fp})$ and $Z(\phi )=-Z(-\phi )=Z(\phi +2{\rm \pi} /n_{fp})$
 and $Z(\phi )=-Z(-\phi )=Z(\phi +2{\rm \pi} /n_{fp})$ with $n_{fp}$
 with $n_{fp}$ a natural number, the functions $(R, Z)$
 a natural number, the functions $(R, Z)$ are written as a cosine and sine Fourier series with period $2{\rm \pi} /n_fp$
 are written as a cosine and sine Fourier series with period $2{\rm \pi} /n_fp$ and coefficients $R_n$
 and coefficients $R_n$ and $Z_n$
 and $Z_n$ , respectively. We then solve the nonlinear least-squares optimization problem using the ‘trust region reflective’ algorithm by minimizing the following cost function:
, respectively. We then solve the nonlinear least-squares optimization problem using the ‘trust region reflective’ algorithm by minimizing the following cost function:
 
and vary the axis coefficients $(R_n, Z_n)$ , the components of the curvature $\kappa _0, \kappa _1$
, the components of the curvature $\kappa _0, \kappa _1$ and $\tau _0$
 and $\tau _0$ . In (H47), $\kappa$
. In (H47), $\kappa$ and $\tau$
 and $\tau$ are the axis curvature and torsion, respectively, and $\ell (\phi )$
 are the axis curvature and torsion, respectively, and $\ell (\phi )$ is found by solving the equation $|\rho '(\phi )|=\ell '(\phi )$
 is found by solving the equation $|\rho '(\phi )|=\ell '(\phi )$ at each optimization step. For the case $n_{fp}=6$
 at each optimization step. For the case $n_{fp}=6$ used here, we find the following parameters:
 used here, we find the following parameters:
 
 
 
yielding an objective function $J=5.72\times 10^{-5}$ for a grid in $\phi$
 for a grid in $\phi$ with 131 points, a total axis length of $L=6 {\rm \pi}$
 with 131 points, a total axis length of $L=6 {\rm \pi}$ and a normal vector that rotates $N=6$
 and a normal vector that rotates $N=6$ times around the axis when translating $\boldsymbol {n}$
 times around the axis when translating $\boldsymbol {n}$ from $\phi =0$
 from $\phi =0$ to $2{\rm \pi}$
 to $2{\rm \pi}$ . Due to the fact that $N\not =0$
. Due to the fact that $N\not =0$ , the poloidal angle $\theta$
, the poloidal angle $\theta$ is replaced by an untwisted poloidal angle $\overline \theta = \theta - 2{\rm \pi} N \ell /L$
 is replaced by an untwisted poloidal angle $\overline \theta = \theta - 2{\rm \pi} N \ell /L$ similar to the angle used in Landreman et al. (Reference Landreman, Sengupta and Plunk2019) to generate a finite radius boundary. The axis shape, its associated Frenet–Serret frame and its curvature and torsion are shown in figure 8. Note that from (H40) and (H50), we can show that the axis curvature does not vanish.
 similar to the angle used in Landreman et al. (Reference Landreman, Sengupta and Plunk2019) to generate a finite radius boundary. The axis shape, its associated Frenet–Serret frame and its curvature and torsion are shown in figure 8. Note that from (H40) and (H50), we can show that the axis curvature does not vanish.

Figure 8. (a) Axis curve $\boldsymbol {r}_0$ together with its Frenet–Serret frame, normal (red), binormal (blue) and tangent (green). (b) Axis curvature $\kappa$
 together with its Frenet–Serret frame, normal (red), binormal (blue) and tangent (green). (b) Axis curvature $\kappa$ (blue) and the target curvature (orange). (c) Axis torsion (blue) and the target torsion (red).
 (blue) and the target curvature (orange). (c) Axis torsion (blue) and the target torsion (red).
 
 










































































