Dyonic black hole degeneracies in $\mathcal{N} = 4$ string theory from Dabholkar-Harvey degeneracies

The degeneracies of single-centered dyonic $\frac14$-BPS black holes (BH) in Type II string theory on K3$\times T^2$ are known to be coefficients of certain mock Jacobi forms arising from the Igusa cusp form $\Phi_{10}$. In this paper we present an exact analytic formula for these BH degeneracies purely in terms of the degeneracies of the perturbative $\frac12$-BPS states of the theory. We use the fact that the degeneracies are completely controlled by the polar coefficients of the mock Jacobi forms, using the Hardy-Ramanujan-Rademacher circle method. Here we present a simple formula for these polar coefficients as a quadratic function of the $\frac12$-BPS degeneracies. We arrive at the formula by using the physical interpretation of polar coefficients as negative discriminant states, and then making use of previous results in the literature to track the decay of such states into pairs of $\frac12$-BPS states in the moduli space. Although there are an infinite number of such decays, we show that only a finite number of them contribute to the formula. The phenomenon of BH bound state metamorphosis (BSM) plays a crucial role in our analysis. We show that the dyonic BSM orbits with $U$-duality invariant $\Delta<0$ are in exact correspondence with the solution sets of the Brahmagupta-Pell equation, which implies that they are isomorphic to the group of units in the order $\mathbb{Z}[\sqrt{|\Delta|}]$ in the real quadratic field $\mathbb{Q}(\sqrt{|\Delta|})$. We check our formula against the known numerical data arising from the Igusa cusp form, for the first 1650 polar coefficients, and find perfect agreement.


Introduction and summary of results
String theory has proven to be a powerful description of the microscopic degeneracy of states of supersymmetric black holes. The original breakthrough of [1,2] gave us two complementary pictures of viewing the black hole-as a bound state of microscopic excitations of strings and branes carrying a statistical entropy, and as a solution to the equations of motion of macroscopic supergravity having a thermodynamic Bekenstein-Hawking-Wald entropy associated to the black hole horizon. A lot of progress has occurred since then on sharpening both these pictures: on the macroscopic side we have learned how to include stringy effects as well as quantum gravitational effects in the calculation of the exact quantum gravitational entropy; and on the microscopic side we have learned how to take into account subtle effects like wall-crossing to isolate the states of the black hole from the full statistical ensemble of string theory. The two complementary pictures of a black hole can now be recast as the exact AdS 2 /CFT 1 correspondence in the near-horizon region of the black hole [3], with two well-defined quantum systems each having its own rules of calculations. This formulation has allowed us to quantitatively test the picture of a black hole as an ensemble of microstates well beyond the thermodynamic approximation, and has provided examples of AdS/CFT valid at finite N .
Perhaps more importantly, the formulation of this correspondence has allowed us to ask sharp questions on both sides of the story which would not have been possible earlier-each side of the correspondence provides a novel guide for organizing the observables and calculations on the other side which may not be a priori obvious. In this context, we present in this paper an exact analytic formula for the integer quantum degeneracies of dyonic black holes in the four-dimensional N = 4 string theory arising from Type II string theory compactified on K3×T 2 . The origins of this formula involve an intricate interplay between physical ideas (AdS 2 /CFT 1 , localization in supergravity, instanton sums, black hole metamorphosis), and mathematical ones (Siegel modular forms, mock Jacobi forms, and their Rademacher expansions). We do not have a rigorous mathematical proof of our formula, but we are able to use the above ideas to obtain a precise conjectural statement relating the Fourier coefficients of the inverse of the Igusa cusp form 1/Φ 10 and the Fourier coefficients of the power of the Dedekind eta function 1/η 24 , which we have checked numerically to high order. In the rest of the introduction we present, successively, the context and the physics motivation, the mathematical formula, the idea of the calculation, and its interpretation in gravity.

Motivation and context
A prototype for an exact gravitational entropy formula can be found for 1 8 -BPS dyonic black holes in N = 8 string theory (Type II string theory compactified on T 6 ) [4]. In that case the exact degeneracies of supersymmetric black holes are known to be coefficients of a certain Jacobi form of weight −2 and index 1, Z N =8 (τ, z) = n, C N =8 (n, ) e 2πinτ e 2πi z . The black hole is labelled by the discriminant 4n − 2 which grows, at large charges, as the square of the area of the horizon. The Hardy-Ramanujan-Rademacher formula for Jacobi forms provides an exact analytic expression for the coefficients C N =8 (n, ) of this Jacobi form as an infinite sum over Bessel functions with successively decreasing arguments. Importantly, this formula has no free parameters, and the only inputs are the modular transformation properties (the weight and index) of the Jacobi form Z N =8 and its overall normalization which is fixed. 1 Each term in the formula is then interpreted, via a localization calculation in the gravitational theory, as a functional integral over the smooth fluctuations around certain asymptotically AdS 2 configurations [5][6][7].
We would now like to do the same for situations with less supersymmetry. The nextsimplest example is 1 4 -BPS dyonic black holes in N = 4 string theories, which are labelled by the T -duality invariants of the charges n = Q 2 /2, = Q · P , m = P 2 /2. (As above, the area of the horizon grows as √ ∆ where the discriminant is ∆ = 4mn − 2 .) In a class of N = 4 string theories the generating function of 1 4 -BPS states is also known in terms of Siegel modular forms. The simplest example is Type II compactified on K3×T 2 in which case the generating function of the supersymmetric index that counts the 1 4 -BPS microstates is the inverse of the Igusa cusp form Φ 10 (τ, z, σ) [8]. The main subtlety in N = 4 string theory compared to N = 8 string theory is that, at strong coupling, the supersymmetric index receives contributions from 1 4 -BPS single-centered black holes as well as bound states of two 1 2 -BPS black holes. The question then arises to isolate the microstates that contribute to the single-centered black hole only. Doing so breaks the modular invariance which was crucial to interpret the formula as a gravitational functional integral.
It was shown in [9] that one can isolate the degeneracies of single-centered black holes in N = 4 string theory while keeping the essence of modularity intact. More precisely, the degeneracies of single-centered dyonic black holes in Type II on K3×T 2 are the Fourier coefficient of certain mock Jacobi forms. One can calculate the mock Jacobi forms and their coefficients for any set of given charges, using a computer algorithm. This indeed clarifies the modular nature of the degeneracies of black hole microstates, but we would like to do better and find an explicit formula for them, as in the N = 8 theory. Upon applying the circle method of Hardy-Ramanujan-Rademacher to the known modular completions of the mock Jacobi forms, one obtains an analytic formula for the black hole degeneracies [10] which is similar to, but more complicated than, the one in the N = 8 theory-there are some additional terms coming from the fact that one has mock Jacobi and not true Jacobi forms, but the bottom line is that for a given mock Jacobi form one has an infinite series of terms controlled purely by a finite number of integers. (The explicit formula is presented in (A. 12).) The integers in question are the polar coefficients of the mock Jacobi forms themselves. Here polar state (and correspondingly polar coefficient) means states with discriminant ∆ = 4mn − 2 < 0.
In this paper we present a simple analytic formula for the polar coefficients in terms of the degeneracies of 1 2 -BPS states in N = 4 string theory. In the heterotic duality frame, these are realized as perturbative fluctuations of the fundamental strings i.e., the Dabholkar-Harvey states [11]. This means that the full quantum degeneracy of the black hole-which is a nonperturbative bound state of strings, branes, and KK-monopoles-is completely controlled by simple perturbative elements of string theory! The nature of the formula, presented below in (1.5), is also noteworthy: the polar coefficients of the mock Jacobi forms are simply linear combinations of quadratic functions of the 1 2 -BPS degeneracies. The latter can be interpreted as counting worldsheet instantons or, more precisely, genus-one Gromov-Witten invariants. This structure is clearly reminiscent of the OSV formula Z BH = |Z top | 2 [12], but the details are somewhat different. The right-hand side of our formula, involving instanton degeneracies, is controlled by Z top , while the left-hand side is the "seed" for the 1 4 -BPS BH degeneracies via an intricate series which is dictated by the mock modular symmetry. The idea of exploiting modular symmetry in order to reach a precise non-perturbative definition for the OSV formula was already initiated in [13], but the technical complications of N = 2 string theories did not allow for an explicit formula. Here we use the fact that many aspects of N = 4 string theories are solvable in order to reach such a formula.

The main formula
In order to present our main formula we briefly review the procedure [9] to calculate the single-centered black hole degeneracies in Type II string theory on K3×T 2 . One first expands the partition function in the chemical potential conjugate to the magnetic charge invariant m to obtain the Fourier-Jacobi expansion (1.1) The Igusa cusp form Φ 10 is a Siegel modular form of weight 10 which implies that the functions ψ m are meromorphic Jacobi forms of weight −10 and index m. Since Φ 10 has a double zero at z = 0, ψ m is meromorphic in z with a double pole at z = 0. This meromorphicity has its physical origin in the wall-crossing phenomenon, whereupon bound states of two 1 2 -BPS centers appear or decay as one moves around the moduli space of the compactification. It was shown in [9] that the functions ψ m have a canonical decomposition into two pieces, where ψ F m and ψ P m count the degeneracies of dyonic 1 4 -BPS single-centered black holes, and two-centered 1 2 -BPS black hole bound states, respectively. Further, the function ψ F m is a mock Jacobi form [9,14,15], which is holomorphic in z. This implies a Fourier expansion of the form 3) The microsocpic degeneracies of 1 4 -BPS single-centered black holes are related to these Fourier coefficients as We now present the analytic formula for the black hole degeneracies which is a combination of the following two formulas: 1. The BH coefficients c F m (n, ), ∆ > 0 are completely controlled by the polar coefficients c F m (n, ), ∆ < 0. The relevant formula follows from the ideas of Hardy-Ramanujan-Rademacher applied to mock Jacobi forms, which by now has become a well-established technique in analytic number theory [16][17][18]. We review this in Section 2. For the particular mock Jacobi forms ψ F m the formula was obtained in [10], which we recall in (A.12).
2. The polar coefficients c F m (n, ), ∆ < 0 are given by We obtain this formula using the ideas and results of [19], by tracking all possible ways that a two-centered black hole bound state of total charge (n, , m) decays into its constituents across a wall of marginal stability. Here W(n, , m) is a set of SL(2, Z) matrices that encode the relevant Walls of marginal stability. This set is finite and we will spend a large part of the paper characterizing this set. The precise formulas are given in (7.4), (7.7). The quantities (n γ , γ , m γ ) are the T -duality invariants of the charges (Q, P ) transformed by γ, and d(n) is the degeneracy of 1 2 -BPS states with charge invariant n, given by [11] 1 (1.6) We have checked the main formula (1.5) against the polar coefficients of ψ F m extracted from the Igusa cusp form Φ 10 using formula (1.1) for magnetic charge invariant up to m = 30, which corresponds to 1650 coefficients. In order to extract the polar coefficients from Φ 10 the steps required are to (a) build Φ 10 from the additive lift [20], (b) inverting it, and (c) extracting the relevant polar coefficients. The main computational bottleneck in this procedure is the inversion. Using recursion relations [9], which is much faster than a direct division, already took us a computing time of the order of hours on a MacBookPro. In contrast, the right-hand side of the formula (1.5) for a given value of m can be computed in milliseconds on the same computer, which is a factor of O(10 5 ).

The idea of the calculation
When the charges have a negative discriminant they cannot form a single-centered black hole (recall that the discriminant is proportional to the square of the classical horizon area). We know that the only other configurations that contribute to the 1 4 -BPS index in N = 4 string theory are two-centered bound states of 1 2 -BPS black holes [19,21]. Thus the problem becomes one of calculating all possible ways a given set of charges with negative discriminant contributing to c F m can be represented as two-centered black hole bound states. Now, any such bound state is an S-duality (SL(2, Z)) transformation of the basic bound state, which consists of an electrically charged 1 2 -BPS black hole with invariant n = Q 2 /2, a magnetically charged 1 2 -BPS black hole with invariant m = P 2 /2, and the electromagnetic fields carry angular momentum = Q · P . The indexed degeneracy of this system equals (1.7) The factors d(n) and d(m) in this formula are, respectively, the internal degeneracies of the electric and magnetic 1 2 -BPS black holes, and the factor (−1) +1 | | is the indexed number of supersymmetric ground states of the quantum mechanics of the relative motion between the two centers [22]. The degeneracy of an arbitrary bound state can be calculated by acting on the charges (Q, P ) by the appropriate S-duality transformation and replacing the charge invariants in (1.7) by their transformed versions. This is precisely the structure of the formula (1.5).
The final ingredient of the formula is to state precisely what are the allowed values of γ which labels all possible bound states. A very closely related problem was solved in an elegant manner in [19], which we use after making small adaptations (note that the modular and elliptic structures are manifest in our presentation). The basic intuition comes from particle physics-any bound state must decay into its fundamental constituents somewhere, and so the question of which bound states exist is the same as the question of what are all the possible decays of two-centered 1 2 -BPS black holes. As was shown in [19] the possible decays are labelled by a certain set of SL(2, Z) matrices. The exact nature of this set is a little subtle due to a phenomenon called black hole bound state metamorphosis (BSM) [19,23,24], which identifies different-looking physical configurations with each other. This is the step which lacks a rigorous mathematical proof, but the physical picture is well-supported. The sum over W(n, , m) in (1.5) is precisely the sum over all possible decay channels after taking metamorphosis into account. Thus our checks of the formula (1.5) can be thought of as providing more evidence for the phenomenon of metamorphosis.
The metamorphosis can be of three types: electric, magnetic, and dyonic. The corresponding identifications generate orbits of length 2 in the first two cases and of infinite length in the third. In the first two cases the metamorphosis has a simple Z/2Z structure, while the group structure of the dyonic case was less clear so far. We show in this paper that the identifications due to dyonic BSM have a group structure of Z. Moreover, the problem of finding BSM orbits maps precisely to finding the solutions to a well-studied Diophantine equation, namely the Brahmagupta-Pell equation, whose structure is completely known. In the language of algebraic number theory, this is the problem of finding the group of units in the order Z[ |∆|] in the real quadratic field Q( |∆|).

Gravitational intepretation
Recall that the quantum entropy of the gravitational theory is formulated as a functional integral over asymptotically AdS 2 configurations. Using the technique of supersymmetric localization in the variables of supergravity, a formula for the exponential of the quantum entropy was derived in [5][6][7]. The result takes the form of an infinite sum of finite-dimensional integrals over the (off-shell) fluctuations of the scalar fields around the attractor background, where the integrand includes a tree-level and a one-loop factor in the off-shell theory. The infinite sum is interpreted as different orbifold configurations in string theory with the same AdS 2 boundary [7]. In the N = 8 theory, this result agrees exactly with the Rademacher expansion for the coefficient of the Jacobi form controlling the microscopic index.
We can now offer a physical interpretation of our exact degeneracy formula (A.12), (1.5) from this point of view. The sum over k in (A.12) runs over all positive integers with the argument of the Bessel function suppressed as 1/k and the Kloosterman sum depending on k. This part of the structure comes from a sum over Γ ∞ \SL(2, Z) of the circle method, and can be interpreted in the gravitational theory exactly as in the N = 8 theory, namely as a sum over orbifolds of the type (AdS 2 × S 1 × S 2 )/Z k [7]. The Kloosterman sum arises from an analysis of Chern-Simons terms in the full geometry. The degeneracies of polar states c F m (n, ) (with ∆ = 4mn − 2 < 0) is interpreted as the number of states of a given (n, , m) which do not form a big single-centered BH. The finite sum over γ ∈ W(n, , m) in (1.5) is indicative of a further fine structure where the smallest units are the 1 2 -BPS instanton states with their corresponding degeneracy. This is the sense in which the final degeneracy formula is constructed out of the instantonic elements.
The outline of the paper is as follows: In Section 2 we explain in detail why one can reduce the counting of 1 4 -BPS states to counting bound states of 1 2 -BPS states. In Section 3 we discuss the macroscopic supergravity counting of 1 4 -BPS states. Section 4 discusses several details that are important for the proper counting of negative discriminant states. In Sections 5 and 6 we present all the relevant calculations that will lead to the explicit formula for the negative discriminant states. In Section 6, we characterize the orbits of dyonic metamorphosis in terms of the orbits of the solutions to the Brahmagupta-Pell equation. The final Section 7 presents our exact black hole formula and lists some numerical data that shows its validity. In Appendix A we review the details of the Rademacher formula applied to our case of interest. Appendix B provides numerical evidence for one special case that we could not solve analytically. Lastly, in Appendix C we provide further explicit data for the interested reader.

Exact dyonic black hole degeneracies and the attractor region
In this section we first review the microscopic counting formula for single-centered 1 4 -BPS states in N = 4 string theory. We then explain how an exact analytic formula for the corresponding black hole degeneracies reduces to the problem of counting bound states of 1 2 -BPS centers, and how this problem can be efficiently solved using the results of [19].
Four-dimensional N = 4 string theory can be described either in terms of heterotic string theory compactified on T 6 , or in another duality frame in terms of Type II string theory compactified on K3×T 2 . Dyonic states are charged under the 28 U (1) gauge fields, with the charge vector (Q, P ) taking values in the integral second cohomology lattice of Γ 6,22 ⊕ Γ 6,22 .
The microscopic degeneracies of dyonic 1 4 -BPS states 2 in the above theory are given by a Fourier transform of the inverse of the Igusa cusp form Φ 10 , the unique automorphic form of weight 10 defined on Sp(2, Z) [8,[27][28][29] .
Here, C indicates a certain contour in the three complex dimensional space spanned by (τ, z, σ), so that the degeneracies on the left-hand side depend on this contour (this dependence has been suppressed in the notation). Importantly, the contour C depends on the moduli of the compactification [30]. When moving through the moduli space for a fixed set of charges (Q, P ), the degeneracies jump when C crosses a pole in the partition function Φ −1 10 . This is a manifestation of the wall-crossing phenomenon where a 1 4 -BPS bound state of two 1 2 -BPS states appears or decays upon crossing codimension-one surfaces in the moduli space. Thus, the moduli space is divided into chambers separated by walls of marginal stability. In a given chamber the degeneracies for a given (Q, P ) are constant, and they jump as one crosses a pole in moving to another chamber. This phenomenon will be central to our investigations in the rest of the paper, and we will discuss the contour C in more detail below.

Single-and multi-centered degeneracies
In the macroscopic supergravity description, the gravitational configurations captured by the index (2.2) correspond to either (a) 1 4 -BPS single-centered black holes, or (b) 1 4 -BPS bound states of two 1 2 -BPS black holes [21]. 3 The bound states exist depending on the region of the moduli space and the values of the charges (Q, P ) [22], in accordance with the wallcrossing phenomenon discussed above. In contrast, single-centered solutions exist everywhere in the moduli space provided the U -duality invariant ∆ is positive. For large values of ∆, this is consistent with the semi-classical picture of BHs where the classical area of the black hole is 4π √ ∆. The conjecture of [31] extrapolates this intuition to all positive values of ∆. 2 Here and in the following, we refer to dyons with torsion 1, i.e. gcd {QiPj − QjPi , 1 ≤ i, j ≤ 28} = 1. A similar story for generic dyons [25,26] should follow along the same lines. 3 Multi-centered black hole bound states exist in theories with any number of supercharges. A bulk-analysis of preserved and broken supersymmetry [21] shows that only certain types of configurations contribute to the relevant indices: single-centered Far away from the black hole, the massless moduli can take any value, but the attractor mechanism [32] implies that they are "attracted" to values that are completely determined by the charges near the black hole horizon. In the N = 4 string theory under consideration, this is elegantly captured by the attractor contour [30] C * = {Im(τ ) = 2m/ε, Im(σ) = 2n/ε, Im(z) = − /ε, 0 ≤ Re(τ ), Re(σ), Re(z) < 1} , (2.3) where ε → 0 + , so that the single-centered degeneracies d * (Q, P ) evaluated using (2.2) and the contour C * are functions of the charges (Q, P ) only.
It was shown in [9] that these single-centered degeneracies are Fourier coefficients of certain mock Jacobi forms ψ F m . It is important to note however that the converse is not true, namely that not all coefficients of ψ F m are degeneracies of single-centered black holes, and this will play an important role in what follows. To construct ψ F m , one begins by expanding the partition function Φ −1 10 around the σ → i∞ point, The functions ψ m (τ, z) in this expansion are Jacobi forms of weight −10 and index m that are meromorphic 4 in the z variable. The attractor contour (2.3) then shows that to extract d * (Q, P ) from ψ m , the inverse Fourier transform in z should be taken along a path such that Im(z)/Im(τ ) = − /2m . (2.5) This contour was called the "attractor contour" in [9], and applies to general meromorphic Jacobi forms of index m. Without loss of generality one can choose 5 n > m, and furthermore the fact that the degeneracies d * (Q, P ) are invariant under spectral flow implies that we can restrict to the window 0 ≤ < 2m. Taking the remaining inverse Fourier transforms, [9] then showed that the single-centered degeneracies d * (Q, P ) are the Fourier coefficients of the so-called finite part of ψ m , defined as Above, q := e 2πiτ , ζ := e 2πiz and d(m) is defined in (1.6). The Appell-Lerch sum in (2.7) exhibits wall-crossing since its Fourier expansion differs in the strips α−1 < Im(z)/Im(τ ) ≤ α, with α ∈ Z. Subtracting ψ P m from the functions ψ m in (2.4) implies that the resulting finite part ψ F m is holomorphic in z and as such has an unambiguous Fourier expansion The discussion of single-centered degeneracies so far can then be summarized as The central mathematical result of [9] is that ψ F m is a mock Jacobi form. This means that its usual modular behavior under SL(2, Z) is modified. To salvage modularity it is possible to add a correction term, known as the shadow, to build a function ψ F m that is modular. The shadow is however non-holomorphic in τ , so modularity is restored at the expense of holomorphicity [14,15].
Starting from the completion ψ F m , the Fourier coefficients c F m (n, ) for ∆ > 0 can be computed using a generalization of the Hardy-Ramanujan-Rademacher formula suited for mixed mock modular forms [10,17]. We briefly review this in Appendix A and the final result is presented in (A.12). One of the main points of the formula is that, in order to compute the Fourier coefficients of positive discriminant states entering (2.9), the only required input are the polar coefficients of ψ F m , defined as By construction, the polar coefficients c m (n, ) count the number of negative discriminant states encoded in the generating function ψ F m . They will be the central focus of the present paper, and we will give an explicit formula for them based on a careful analysis of wall-crossing and bound states.

The moduli space and the attractor region
Having reviewed the 1 4 -BPS single-centered degeneracies, we now discuss in a bit more detail the structure of walls in the moduli space. The moduli-dependent contour C in (2.2) can be written in terms of the moduli-dependent central charge matrix Z [30]. The latter can be parameterized 6 by a complex scalar Σ = Σ 1 + iΣ 2 as In terms of this matrix, the contour in (2.2) reads (with ε → 0 + )  The expansion (2.4) then corresponds to taking the limit Σ 2 → ∞ while keeping Σ 1 and ε Σ 2 fixed. This limit has a physical interpretation as the M-theory limit, where one of the circles inside the internal T 2 of the Type II frame becomes large [9]. In this limit, the expansion (2.4) around σ → i∞ takes us high into the upper half-plane parameterized by Σ, and varying Σ 1 moves us horizontally. This is depicted in Figure 1a. The wall-crossing captured, in the Mtheory limit, by the Appell-Lerch sum (2.7) divides the moduli space into chambers separated by parallel marginal stability walls located at Σ 1 = α ∈ Z. The attractor contour (2.5) then corresponds to picking a particular chamber, which we denote by R. As mentioned below (2.5), can be restricted to 0 ≤ < 2m, so it follows that R is the chamber between the walls located at α = 0 and α = −1. Thus, Now, in the chamber R, the Fourier coefficients of ψ P m in the range 0 ≤ < 2m vanish because the coefficients of the Appell-Lerch sum vanish in this chamber, as can easily be checked. Therefore, the Fourier coefficients of the meromorphic Jacobi forms ψ m in the chamber R are equal to the coefficients of the finite part ψ F m . For ∆ > 0, these coefficients correspond precisely to the single-centered black hole degeneracies, as given by (2.9). However, ψ F m also has coefficients with ∆ < 0 which live in the chamber R. Thus, we arrive at the following physical interpretation of the Fourier coefficients c F m : they count the indexed number of 1 4 -BPS dyonic states in the chamber R. This is true for ∆ > 0 (which are singlecentered black holes) as well as, importantly, for ∆ < 0 (which correspond to multi-centered black holes).
Because of the Rademacher formula (A.12), our task of finding an analytic formula for the single-centered degeneracies (2.9) is thus reduced to finding an analytic formula for the negative discriminant degeneracies, for which we will use the above physical picture. As explained in the introduction, the 1 4 -BPS bound states counted by (2.10) always decay upon crossing a wall of marginal stability. We therefore have to track them in the Σ moduli space and reconstruct them as a sum of their 1 2 -BPS constituents. The decays corresponding to moving horizontally by varying Σ 1 have been taken into account by ψ P m , so they will not contribute to c F m (∆ < 0). As discussed above, the contribution from ψ P m in the region R actually vanishes. 7 This is consistent with the analysis of [19]. In addition, there can be other decays in the full moduli space, and to see them we need to go away from the M-theory limit. As shown in [19], the region R extends also vertically downwards back to the Σ 2 = 0 line. Therefore, away from the M-theory limit, the negative discriminant states contained in R can also decay further upon crossing circular walls (the precise shape of these walls is charge-dependent), which are shown in Figure 1b. We can now use the results of [19] to count how many negative discriminant states live in the region R and obtain the polar coefficients (2.10). This will be reviewed in Section 4.

Localization of N = 4 supergravity and black hole degeneracy
Before presenting the derivation of the formula for the polar coefficients c m (n, ) defined in (2.10), we review how the main idea originates from physical considerations. 8 In [33] two of the present authors were able to compute the asymptotic degeneracies of 1 4 -BPS singlecentered BHs as a supergravity functional integral in the AdS 2 near-horizon geometry of the BHs, following the ideas of [3,5]. This computation relied on some approximations and assumptions that we spell out below, and as such did not yield the exact answer matching the microscopic prediction. It did, however, lead to a result that could be interpreted as an approximate relation between the polar coefficients of the counting function ψ F m and the Fourier coefficients of the Dedekind eta function, which was checked to be true to a good approximation. As we explain below, the main formula of the present paper (1.5) can be seen as correcting the approximate result of [33] to an exact formula.

The quantum entropy of 1 4 -BPS single-centered black holes
In the introduction we mentioned the two pictures-macroscopic and microscopic-of BHs in string theory. While we mainly focus on the microscopic picture in the rest of the paper, the origins of our formula came from a macroscopic intuition that we now review. Using ideas of the AdS 2 /CFT 1 correspondence, a macroscopic supergravity description for the degeneracies of microstates of supersymmetric BHs, called the quantum entropy formalism, was put forward in [3]. The near-horizon geometry of extremal black holes universally contains an AdS 2 factor, and the proposal of [3] is that the degeneracies of supersymmetric extremal black holes is a functional integral on this AdS 2 space defined as (3.1) Here the brackets indicate that one should compute the expectation value of the Wilson line around the Euclidean time circle S 1 for the U (1) gauge fields A I under which the black hole is charged, q I denotes the corresponding charges of the BH, and the superscript "finite" indicates a particular infra-red regularization scheme to deal with the infinite volume of the EAdS 2 factor in the near-horizon geometry (see [3] for details).
To compute the path integral (3.1) beyond the leading large-charge approximation, powerful techniques of supersymmetric localization have been employed starting with the work of [5]. Localization has been an invaluable tool in the study of partition functions in gauge theories and in many cases has allowed us to reduce a complicated path integral to a much simpler finite dimensional integral. A complete review falls outside the scope of the present paper, 9 so we will simply give the final result obtained in [6,[35][36][37][38][39][40] for (3.1) after localization and for the class of black holes we are interested in. For 1 2 -BPS black hole solutions of an N = 2 supergravity theory with holomorphic prepotential F , we have The definition of the various quantities entering (3.2) are as follows. The integral is over the manifold M Q , which is characterized by the bosonic field configurations that are supersymmetric with respect to a specific supercharge Q preserved by the black hole solution. This manifold is (n V + 1)-dimensional, where n V is the number of abelian vector multiplets under which the black hole is charged, and φ I denote the coordinates on M Q . The integrand is completely specified by the prepotential F (p I , φ I ) of the theory, which is a homogeneous holomorphic function of its arguments. The associated Kähler potential χ V (p I , φ I ) is built out of this prepotential. Finally, we have denoted by µ(φ I ) the measure on M Q , which was not obtained from first principles in the above references, but constrained to be a function that contributes O(1) growth to the entropy when all the charges are scaled to be large.
To apply the formula (3.2) to the 1 4 -BPS single-centered black hole solution of the N = 4 theory discussed in Section 2, one consistently truncates the latter theory to an N = 2 theory with n V = 23 multiplets and prepotential [41] where C ab is the intersection matrix on the middle homology of the internal K3 manifold and a, b = 2, . . . , 23. Using this data and assuming a certain measure on M Q , [33,43] showed that the finite dimensional integral (3.2) could be put in the form of a sum of I-Bessel functions indicative of a Rademacher-type expansion for the macroscopic degeneracies 9 See [34] for an introduction and reviews in the context of field theory.
of single-centered 1 4 -BPS black holes, similar to the exact microscopic formula (A.12). The above assumption about the measure was essentially a statement of consistency with a certain way of expanding the microscopic formula (2.2), as we now explain.

The measure and Rational Quadratic Divisors
The z-integral in the microscopic degeneracy formula (2.2) can be performed by calculating residues at the so-called Rational Quadratic Divisors (RQDs) of the Igusa cusp form Φ 10 . The leading contribution to the integral comes from the RQD located at z = 0 [8]. Near z = 0, the Igusa cusp form behaves as The remaining integral in τ and σ can then be expressed as [42] where indicates that there are subleading contributions coming from other RQDs (additional poles in Φ −1 10 ), and τ = τ 1 + iτ 2 . The function F(τ 1 , τ 2 ) is given by and the contour of integration C 2 is required to pass through the saddle-point of F(τ 1 , τ 2 ). This way of manipulating the microscopic degeneracy formula corresponds, in physics, to calculating the degeneracies of BHs whose magnetic as well as electric charges grow at the same rate. In contrast, the expansion studied in Section 2 following [9] corresponds to fixing the magnetic charges and letting the electric charges grow (see Equation (2.4)). Adding a total derivative term and comparing to the macroscopic localized integral (3.2), the authors of [33,43] concluded that the measure factor, corresponding to the leading RQD of Φ 10 located at z = 0, should take the form where E 2 is the Eisenstein series of weight 2, related to the Dedekind eta function as Using the measure (3.7) in the integral (3.2) leads to an infinite sum of I-Bessel functions coming from integrating term-by-term the series expansions of the prepotential and the measure [33]. It was noticed in that paper that this infinite sum begins with terms that become smaller up to a point, but that the integrals start diverging after a while. This behavior is characteristic of an asymptotic series, which prompted [33] to truncate the sum after a finite number of terms. This was achieved using a contour prescription given in [43]. The end result, after evaluating the integrals, was then where d(n) is the n th Fourier coefficient of the Dedekind eta function as given in (1.6), ∆ is the usual discriminant 4mn − 2 , and the I-Bessel function is defined in (A.9). Comparing the above macroscopic result to the Fourier coefficients (A.8) and (A.11), we see that d macro is the first (k = 1) term in the Rademacher expansion for a Jacobi form of weight −10 upon making the identification This proposal, motivated by the exact computation of a supergravity path integral, already offered a very good numerical agreement with the microscopic data and hinted at an intricate relationship between the Fourier coefficients of a simple modular form (the Dedekind eta function) and those of the more complicated mock Jacobi forms ψ F m . However, detailed numerical investigations also showed that the formula (3.10) cannot be the complete answer, as evidenced by the small discrepancies between the left-and right-hand sides highlighted in the tables of [33].
Since the derivation reviewed above relied on the approximations related to the asymptotic nature of the series, it was already clear that (3.9) is just the beginning of the complete formula. In the rest of the paper, we obtain the correct and exact relationship between the polar terms of ψ F m and the Fourier coefficients of η(τ ) −24 based on a precise analysis of negative discriminant states in N = 4 string theory, as summarized in our main formula (1.5). Therefore, the results of the present paper can be interpreted as giving us the precise way to take into account the subleading RQDs that correct the measure (3.7), and truncate the infinite sum of Bessel functions arising from (3.2). 10 11 4 Negative discriminant states and walls of marginal stability Now we turn back to our main goal, which is to obtain an analytic formula for the degeneracies of negative discriminant 1 4 -BPS states c m (n, ) as defined in (2.10) in terms of the coefficients of the Dedekind eta function. In this section we set up the problem in a convenient form after reviewing some facts about negative discriminant states and walls of marginal stability associated to negative discriminant state decays. As reviewed in Section 2, we are interested in counting the number of negative discriminant states in the region R, which correspond to bound states of two 1 2 -BPS states. Following [19], a convenient way to do so is to count how bound states appear or decay as we move around the moduli space parameterized by Σ discussed around (2.11). When we cross a wall of marginal stability, bound states appear or decay and contribute to the degeneracies of all negative discriminant states contained in ψ F m . We now review the structure of these walls of marginal stability, referring the reader to [19,45] for more details. (a) Semi-circles connecting two rational points p/r and q/s such that ps − qr = 1. We denote these walls as S-walls.
(b) Straight lines connecting i∞ to an integer. These can be thought of as special cases of the above expressions when r = 0 and p = s = 1, or when s = 0 and q = −r = 1.
We denote these walls as T-walls. To any T-or S-wall we associate the following matrix, γ = p q r s ∈ P SL(2, Z) . 2. Given an initial charge vector (n, , m) = (Q 2 /2, Q · P, P 2 /2), there is an associated charge breakdown at a wall γ of the form (4.1), given by and which corresponds to a 1 4 -BPS BH decaying into two 1 2 -BPS centers. The charges of the two centers are given by γ · Q γ 0 and γ · 0 P γ , with which shows that after the breakdown one center is purely electric while the other is purely magnetic in the new frame. We define (n γ , γ , m γ ) = (Q 2 γ /2, Q γ · P γ , P 2 γ /2), which are given explicitly by 3. The set of matrices that characterize the walls in the Σ upper half-plane can be divided into subsets that satisfy the following properties: (4.5) Because the above matrices have unit determinant, the walls in Γ + S have p/r > q/s, and the walls in 4. We define the orientation of a wall γ to be q/s → p/r. With respect to this orientation, a bound state of 1 2 -BPS states exists in the chamber to the right of the wall if γ < 0, and in the chamber to the left of the wall if γ > 0 [19]. 5. The attractor region R in (2.13) is the region of the Σ upper half-plane bounded by the T-walls 0 → i∞, 1 → i∞ and the semi-circular S-wall 0 → 1. (Note that, because of the negative sign in the contour (2.12), the attractor region −Im(τ ) < Im(z) ≤ 0 as in (2.13) maps to 0 ≤ Re(Σ) < 1.) We will be interested in the degeneracies of negative discriminant states in this region, as reviewed in Section 2.
From Point 4 combined with (4.4), it is clear that none of the T-walls contribute in the region R. For example, when r = 0, γ = 1 q 0 1 which means (n γ , γ , m γ ) = (n + q 2 m − q , − 2qm, m). Recalling that we can restrict ourselves to 0 ≤ < 2m, this shows that when q ≥ 0, the above T-walls contribute to the right of the region R. This is consistent with our analysis of Section 2, where we showed that ψ P m , which captures all the T-walls, actually has vanishing Fourier coefficients in the region R.
For the S-walls, there exists a map between the sets Γ + S and Γ − S , given by the right multiplication of an element of Γ + S by the matrix This map reverses the orientation of the wall and flips the sign of γ . Furthermore,S squares to −I, which means that it is an involution in P SL(2, Z). Therefore we can focus only on elements of Γ + S when discussing the details of negative discriminant states breakdowns across walls of marginal stability.

Towards a formula for black hole degeneracies
Upon crossing a wall of marginal stability, the index jumps by an amount controlled by the generating function of each of the associated 1 2 -BPS centers. The latter is given by the inverse of η(τ ) 24 , whose Fourier coefficients are given by the partition function into 24 colors p 24 (n) (cf. Equation (1.6)). Summing up all possible decays across the S-walls leads to the following counting formula for negative discriminant states living in the region R: where the function θ(γ, R) is a step-function giving 1 if the bound state exists on the same side of the wall γ bounding R and 0 otherwise. Formally, it is defined as follows On one hand this sum can be written in a more covariant manner by extending it to a sum over all matrices in P SL(2, Z), by extending the θ function to all of P SL(2, Z) via because the T-walls do not contribute in the region R as we saw above. On the other hand, the sum (4.8) can also be written as a sum over a smaller set as follows. Note that the summand in equation (4.7) is invariant under a transformation by the matrixS given in equation (4.6) because n γS = m γ , m γS = n γ , γS = − γ andS exchanges Γ + S and Γ − S . This means that the contributions from the sum over γ ∈ Γ + S and γ ∈ Γ − S are equal and we can sum over Γ + S only. So, we can alternatively write (4.7) as

A subtlety from bound state metamorphosis
While accounting for all the negative discriminant states in the region R, there is a further subtlety that needs to be taken into account due to a phenomenon known as bound state metamorphosis (BSM) [19,23,24]. BSM stems from the fact that when one or both 1 2 -BPS centers making up a 1 4 -BPS bound state carry the lowest possible charge invariant (that is, when n γ = −1, m γ = −1 or n γ = m γ = −1 for a given wall γ), two or more bound states must be identified following a precise set of rules to avoid overcounting in the index (4.11). Thus we can write the set of all contributing walls as the quotient Γ BSM (n, , m) = P SL(2, Z)/BSM , Here we have to introduce a new function Θ(γ) which generalizes the function θ(γ, R) defined above to take into account the phenomenon of BSM so that it is defined on the coset Γ BSM (n, , m). We will be in a position to give a proper definition after a discussion of BSM in the following sections. We can also present this formula as a sum over the set Γ S or Γ + S modulo the identifications due to BSM for the reasons discussed above (T-walls do not contribute in R, andS gives a map between Γ − S and Γ + S ): (4.14) Given that the left-hand side of this formula is finite, it is reasonable to expect that given a set of initial charges (n, , m), only a finite subset of walls of marginal stability gives a non-zero contribution to the above sums. This expectation turns out to be correct and we can write the final formula as a sum over the finite set W(n, , m) c m (n, ) = γ∈W(n, ,m) Our goal in the following sections is to now fully characterize the subset W(n, , m) and show that it contains a finite number of elements for a given charge vector (n, , m).
It will be convenient to split the characterization of the set W(n, , m) depending on whether BSM does not or does occur. This will be the subject of sections 5 and 6, respectively. Before initiating the study of the finiteness of W(n, , m), we recall from the discussion below (2.5) that we can restrict the charge vector to be such that 0 ≤ < 2m. In addition, ψ F m has even weight so there is a reflection symmetry → − which allows us to restrict ourselves to the case 12 ∈ {0, . . . , m}. The index m runs from −1 to +∞ in the expansion (2.4). For m = −1 and m = 0, there is no macroscopic BH as explained in Section 2, and therefore we only study m > 0 in the following. Thus our goal is to study the set W(n, , m) of walls of marginal stability for a charge vector (n, , m) that satisfies m > 0, n ≥ −1 and 0 ≤ ≤ m.

Negative discriminant states without metamorphosis
In this section, we begin to characterize W(n, , m). For the time being we ignore the phenomenon of BSM (which will be the subject of the next section), and show that the contribution to W(n, , m) in this case is finite. Accordingly, in order to identify the walls that contribute to the polar degeneracies c m (n, ), we study the system of inequalities m γ ≥ 0 and n γ ≥ 0 defined in (4.4) for a given charge vector (n, , m) such that ∆ = 4mn − 2 < 0 and 0 ≤ ≤ m. As explained above, we focus on walls in Γ + S ⊂ P SL(2, Z), which allows us to choose r, s > 0 in the following. The condition m γ ≥ 0 then amounts to The first equality defines a parabola in the (p/r, y = m γ )−plane and the condition m > 0 means that the inequality has two branches: We will call these positive and negative "runaway branches" since p/r is unbounded from above or from below, respectively. The condition n γ ≥ 0 amounts to Moreover, using that the determinant of γ must be equal to one, we have and so the first equality in (5.3) can also be seen as a parabola in the (p/r, y = n γ )−plane, shifted by 1/(rs) compared to the first parabola. The condition n γ ≥ 0 also has a positive and negative runaway branch, (5.5) 12 Note that even though ψ F m is not modular but only mock modular, both its completion ψ F m and its shadow, and therefore ψ F m itself, enjoy this → − symmetry [9].
Recall from Section 4 that we focus on Γ + S walls which corresponds to rs > 0. We split the argument in two cases. Considering the smaller intercept with the p/r axis of the shifted n γ -parabola is smaller than the larger intercept with the p/r axis of the m γ -parabola. This situation is illustrated in Figure 3a. In on the negative runaway branch which we denote A − . For a given set of (n, , m), the conditions (5.7) have solutions over the integers for (p, r, s). However, if we supplement this system with the condition that γ > 0 (since this is a Γ + S wall this condition is necessary to have a non-zero contribution owing to the Θ function in (4.14)), then there are no solutions for (p, r, s). Indeed these conditions imply that which is in contradiction with the first equality of (5.7). Similarly, supplementing the branch A − by the condition γ > 0, there are no solutions for (p, r, s). This can be seen by showing that the inequality 2 s r m γ + γ > 0 is in contradiction with the first inequality of (5.8).
The other case to consider is when This means that the smaller intercept of the shifted parabola is larger than or equal to the larger intercept of the original one, as illustrated in Figure 3b. In this case, we still have the usual runaway branches which we call B + and B − , but in addition a new branch of solutions for p/r opens up, which we call the bounded branch C, Once again, adding the condition that γ > 0 suffices to show that there are no integer solutions (p, r, s) to the system of inequalities characterizing the runaway branches B ± . The proof of this is identical to the one above for A ± . There are now however solutions for the C branch. Observe that on this branch we also have a condition on the original charges: since r and s are integers, rs ≥ 1 and so the second condition in (5.11) demands that m ≥ |∆|.
Including the inequality γ > 0, we obtain the following system for potential walls without BSM contributing to the polar coefficients: (5.14) We can analyze this system on a case-by-case basis, depending on the original charges (n, , m).
1. Case 1: m > 0, n = −1 In this case, there are no integer solutions to (5.14). We see from equations (4.4) that n = −1 and n γ ≥ 0, m γ ≥ 0 require that p, q = 0. The left-hand-side of the first inequality in equation (5.14) implies that P/R > 0, which then implies that p > 0 since r, s > 0. The determinant condition ps − qr = 1 then requires that q > 0 as well. However, this is a contradiction since the right-hand-side of the first inequality in equation (5.14) can be rewritten as Here we used that for m > 0, n = −1 we have |∆| = √ 2 + 4m > .
2. Case 2: m > 0, n = 0, and > 0 In this case we find solutions given by Translating back to the original (p, q, r, s) variables, this yields matrices of the form Note that all entries in the above matrix are bounded from above by m. As we will see below, such m-dependent bounds always arise when considering the set of contributing walls W(n, , m).
3. Case 3: m > 0, n > 0 and > 0 This case is slightly more involved. First, notice from the left-hand-side of the first inequality in equation (5.14) that P = ps > 0. Therefore we split the discussion depending on whether P = 1 or P > 1.
(a) Case 3a: P = 1 In this case the inequalities (5.14) with P = 1 impose In the variables (p, q, r, s), we therefore have a non-zero contribution to the polar coefficients from matrices of the form: Again, note that all entries in the above matrix are smaller than m.
(b) Case 3b: P > 1 In this case, the inequalities (5.14) yield the following bounds on P and R: The corresponding walls do not start at q/s = 0 but instead are strictly inside the largest semi-circular S-wall 0 → 1.
Note that we can again get an m-dependent upper bound on P by using the fact that ≤ m and |∆| ≥ 1. We can also use this upper bound on P in the upper bound on R directly to obtain The above implies that all matrix entries of γ ∈ P SL(2, Z) satisfying (5.20) are bounded from above by m.
This exhausts all possible cases for contributions without BSM: the conditions (5.17), (5.19) and (5.20) with n ≥ 0 and , m > 0 fully characterize the set W(n, , m) in this case. By inspection, this set has a finite number of elements. Observe that all the walls giving a non-zero contribution to (4.15) have entries bounded from above by m.

Effects of black hole bound state metamorphosis
We now turn to identifying the walls of marginal stability for which BSM is relevant. We study the problem systematically in three different cases viz., magnetic-, electric-, and dyonicmetamorphosis, corresponding to m γ = −1, n γ = −1 and m γ = n γ = −1, respectively.
6.1 Magnetic metamorphosis case: m γ = −1, n γ ≥ 0 As in Section 5, we start with a charge vector (n, , m) such that 4mn− 2 < 0 and 0 ≤ ≤ m. However, we are now interested in the walls γ for which m γ = −1 and n γ ≥ 0. The idea behind magnetic metamorphosis is that when there is a wall γ such that m γ = −1, then there is another wallγ which has the exact same contribution to the index as γ. Furthermore, one needs to implement a precise prescription to properly account for such walls, and avoid overcounting in the polar degeneracies, as shown in [19,24]. It will be useful to explicitly review some details of this phenomenon. To do so, we begin with the following definition: Definition 6.1. For a wall γ with m γ = −1, n γ ≥ 0, we define its metamorphic dual as With this definition, the prescription found in [19,24] to properly account for magnetic-BSM can be summarized as follows (we refer the reader to the references just mentioned for a physical justification of this): A wall γ at which magnetic-BSM occurs contributes to the polar coefficients c m (n, ) if and only if γ and its metamorphic dualγ both contribute in R. If so, the contributions of γ andγ should be counted only once.
A necessary condition for the second part of the prescription is that both γ andγ have the same index contribution, as we now review. First, from Definition 6.1, it is easy to see that a wall γ and its metamorphic dualγ have the same end point p/r, γ = p q r s ⇐⇒γ = p −p γ + q r −r γ + s .
With this, we prove the following statement: Proposition 6.1. For a given set of charges (n, , m), the wallγ has the same index contribution as γ to the polar coefficients c m (n, ).
We now illustrate the potential non-zero contributions to the formula (4.14) from magnetic-BSM walls, implementing the above prescription. Recall that the walls we are summing over in the index formula are in Γ + S and are thus oriented from left to right (they have p/r > q/s). From (6.2), we then have the following possible configurations for the wall γ and its dual: , as shown in Figure 4 (a) Case If −r γ + s > 0, then we find from −p γ + q −r γ + s > q s that −ps γ + qs > −rq γ + qs which implies 0 > γ (ps − qr) = γ (because γ ∈ P SL(2, Z)), which contradicts the assumption that γ > 0. For −r γ + s < 0, we find from p r > −p γ + q −r γ + s that −pr γ + ps < −pr γ + qr which leads to the contradiction 1 = ps − qr < 0. Therefore this scenario does not occur.
(b) The situation γ = − γ < 0 as seen in Figure 4b does occur but does not contribute to the index computed in the region R owing to the BSM prescription presented below Definition 6.1.
(a) Case , as shown in Figure 5 (a) For the case γ = − γ < 0 as in Figure 5a, we run into a contradiction analogous to the one of Figure 4a.
(b) The case of γ = − γ > 0 as in Figure 5b does again occur but does not contribute to the black hole degeneracy in the region R owing to the BSM prescription.
3. Case −p γ + q −r γ + s > p r > q s as shown in Figure 6 (a) Case (a) For the case as in Figure 6a, there will be a contribution to the index in the region R from the walls γ andγ, in accordance with the BSM prescription. Furthermore, Proposition 6.1 shows that both contributions are equal, and the prescription states that they must be identified to avoid overcounting.
(b) The case shown in Figure 6b does not contribute to the black hole degeneracy in R since neither γ norγ contribute in R.
In summary, we have shown that the only magnetic-BSM walls that give a non-trivial contribution to (4.14) must satisfy m γ = −1, n γ ≥ 0, γ > 0, as well as Observe now that if −r γ + s > 0, then we can rewrite the latter inequality as 0 > ps − qr = 1 which is a contradiction. Thus, we find that the walls giving a non-trivial contribution to the index (4.14) must have −r γ + s < 0, which implies γ > s/r and therefore is stronger than γ > 0.
Upon eliminating q using the condition that the walls are in P SL(2, Z), we can write the three conditions m γ = −1, n γ ≥ 0 and γ > s/r as We split the discussion in various cases depending on the values of the charges (n, , m), subject to the conditions 4mn − 2 < 0, m > 0 and 0 ≤ ≤ m. We further focus on the Γ + S walls that have r, s > 0.
1. Case 1: m > 0, n = −1 In this case we solve for r in (6.7) and obtain two solutions Since r − is negative we can discard it and focus on the r + solution. Inserting this in the inequalities n γ ≥ 0 and γ > s/r, we obtain the following inequalities on s, where we have taken into account the fact that we are only interested in solutions with s > 0. Clearly the right-hand side must be greater or equal to one for this to have solutions in Z, which in turn translates to an upper bound on p, given below. A lower bound on p arises because the lower bound on s will become p-dependent for sufficiently small p (certainly for p ≤ 0). In that case we know that the lower bound 1 2 p 2 |∆| + 4 − p|∆| = 1 2 (2r + + p) − p|∆| is an integer or a half-integer. Since s has to be strictly larger than this lower bound but smaller than the upper bound, we find that the gap between the upper and lower bound on s has to be at least 1/2, which leads to a lower bound on p. The final range one obtains is Since 0 ≤ ≤ m, the upper bound on p is maximized by taking = m, in which case one obtains p ≤ 1 < 1, while the lower bound on p trivially implies that p ≥ 0. So, we actually find that there are only solutions with p = 0, which then implies that r = r + = 1 and q = (ps − 1)/r = −1. The range for s simplifies substantially and the only matrices that contribute in this case are Here we have used that 0 ≤ ≤ m to get a simple m-dependent upper bound on s.

2.
Case 2: m > 0, n = 0 and > 0 In this case, the system (6.7) imposes Requiring r > 0 to be an integer fixes p = 1 and | (m+1). Then the condition γ > s/r is automatically satisfied for s > 0, while the condition m γ ≥ 0 requires s = 1. Thus, the matrices satisfying (6.7) are of the form This set of matrices has entries that are trivially bounded from above by (m + 1)/ . Among all matrices that contribute to the index (4.14), we obtain here the maximal entry m + 1 for = 1.
3. Case 3: m > 0, n > 0 and > 0 In this case we solve for r using m γ = −1 and obtain two solutions Note that sign(p) = sign(r ± ), so our restriction to r > 0 implies in this case p > 0. The reality of the square root in r ± actually implies a stronger lower bound on p, Together with the conditions n γ ≥ 0 and γ > s/r, we find max 1 2n p|∆| ± p 2 |∆| − 4n , 0 < s ≤ 1 4n + |∆| p |∆| ± p 2 |∆| − 4n , (6.16) where the upper and lower signs are for r = r + and r = r − , respectively. We should require that the right-hand side of the above equation be greater than one to have integer solutions for s. For the lower sign, this criterion yields an upper bound on p, which shows that there is a finite number of walls with r = r − contributing to (4.14). Furthermore, the wall matrix entries are again bounded by simple m-dependent functions, as follows. For p as in (6.17) we notice that the upper bound is maximized for = m and |∆| = 1, 13 in which case one finds p < 1 2 2 + m − 1 m < 1 + m 2 . Similarly, we can derive an m-dependent upper bound on s > 0 as follows: p |∆| − p 2 |∆| − 4n is a monotonically decreasing function of p and therefore maximal when p is at its lower bound 2 n/|∆| from (6.15). Taking into account that 1 ≤ n and |∆| < ≤ m, we then find s ≤ Using the upper bound on s we likewise find an upper bound on the remaining entry, 0 ≤ q = (ps − 1)/r − ≤ p |∆| − p 2 |∆| − 4n /2 < √ m/2. For the upper sign, which corresponds to picking r = r + in (6.14), requiring that the right-hand side of (6.16) be greater than one does not yield additional constraints on p.
In this case, we thus only have the lower bound (6.15). However, numerical investigations up to m = 30 show that the set of walls with r = r + is finite, and in fact consists of only a single element for a given value of m, n, > 0. Furthermore, the entries of the matrix associated to such walls are always strictly less than m. It seems that imposing integrality of the matrix entries on top of the above conditions severely restricts the contributing walls with r = r + , although we have not managed to show this analytically. We leave this as an interesting problem for the future.
The above analysis shows that the set of walls at which magnetic-BSM occurs and that give a non-trivial contribution to the index (4.14) is finite with entries bounded from above by m + 1 (see Equation (6.13)). Aside from the case with m, n, > 0 and r = r + , we were able to show this analytically. Nevertheless, our numerical investigations have shown that the same conclusion holds for the latter walls. Some more details are presented in Appendix B.
6.2 Electric metamorphosis case: n γ = −1, m γ ≥ 0 Having expounded the details of the magnetic metamorphosis case in the previous subsection, we can make use of these results to work out the electric metamorphosis case at almost no 13 These values cannot actually be obtained, so there is a slightly stronger but more complicated bound. extra cost. This follows from combining Proposition 6.1 with the observation below (4.6), which shows that acting withS on the metamorphic dualγ (6.1) of a wall γ with m γ = −1 produces a wall with n γ = −1 and with the same orientation as that of γ. Indeed, the charges associated with the wallγ ·S are given by (nγS, γS , mγS) = (m γ , γ , n γ ) = (−1, γ , n γ ) . (6.18) As in the magnetic-BSM case, for a wall γ such that electric metamorphosis occurs there is another wallγ which gives the same contribution to the index: For a wall γ with n γ = −1, m γ ≥ 0, we define its metamorphic dual as We must then employ a prescription analogous to the one presented below Definition 6.1 for electric-BSM contributions to avoid overcounting. This is again necessary since an electric-BSM wall and its metamorphic dual (6.19) have the same contribution to the index: Proposition 6.2. For a given set of charges (n, , m), the wallγ has the same index contribution as γ to the polar coefficients c m (n, ).
Proof. This is proven completely analogously to the proof of Proposition 6.1.
Furthermore we recall that, as explained below (4.10), the summand of the counting formula for negative discriminant states is invariant under anS-transformation. From (6.18), it is clear that the electric-BSM wallγ ·S gives the same contribution to the polar coefficients c m (n, ) as the magnetic-BSM wall γ. Thus, in addition to the above prescription that requires us to identify an electric-BSM wall with its metamorphic dual, we also need to identify the contribution of electric-BSM walls with the contribution of magnetic-BSM walls to avoid further overcounting. The BSM prescription in the case of magnetic or electric walls therefore identifies four contributions together for a given set of charges (n, , m).
From Definition 6.2, it is easy to see that a wall γ and its metamorphic dualγ have the same starting point q/s, γ = p q r s ⇐⇒γ = −q γ + p q −s γ + r s . (6.20) Given this and the fact that we look for walls in Γ + S (with p/r > q/s), we have the following possible configurations for the electric-BSM wall γ and its dual: , as shown in Figure 7 (a) For the situation γ = − γ > 0 as in Figure 7a, one can show that this configuration leads to a contradiction, analogous to the magnetic-BSM case of Figure 4a. Therefore this scenario does not occur.
(a) Case The case γ = − γ < 0 as seen in Figure 7b does occur but does not contribute to the index in the region R owing to the BSM prescription.

Case
, as shown in Figure 8 (a) Case (a) For the case γ = − γ < 0 as in 8a, there is again a contradiction which prevents this configuration from happening, as in the magnetic-BSM case of Figure 5a.
(b) The case γ = − γ > 0 as in Figure 8a does again occur but does not contribute to the index in the region R owing to the BSM prescription.
3. Case p r > q s > −q γ + p −s γ + r , as shown in Figure 9 (a) Case For the case as in Figure 9a, there will be a contribution to the index in the region R from γ andγ. Here, just as in the magnetic-BSM case, both these contributions are equal owing to Proposition 6.2 and must be identified according to the BSM prescription.
(b) The case as shown in Figure 9b does not contribute to the black hole degeneracy in the region R since neither γ norγ does.
Just as in the previous section, the above analysis shows that the only electric-BSM walls that give a non-trivial contribution to (4.14) must satisfy m γ ≥ 0, n γ = −1, γ > 0, as well as q s > −q γ + p −s γ + r . Once again, the last inequality leads to a stronger restriction on γ , namely γ > r/s. We now explicitly give the form of the walls for which electric-BSM occurs, for all values of (n, , m) with the usual restrictions that 4mn − 2 < 0, m > 0 and 0 ≤ ≤ m. We make use of the observation at the beginning of this section regarding the action ofS on the metamorphic dual of a magnetic-BSM wall.
3. Case 3: m > 0, n > 0 and > 0 Acting on the metamorphic dual (6.1) of the walls of Case 3 in Section 6.1 with anStransformation, we obtain a finite set of electric-BSM walls. This can be shown analytically when acting on walls with r = r − , and numerically when acting on walls with r = r + . Moreover, all entries are strictly bounded from above by m. See again Appendix B for some numerical checks.
Just as in the magnetic-BSM analysis of Section 6.1, in all the above cases we obtain a finite number of electric-BSM walls whose entries are bounded by m+1 (see Equation (6.22)). In the next section, we turn to the final case that remains to be analyzed, which is when both transformed charges m γ and n γ are equal to −1.

Dyonic metamorphosis case
The final case of metamorphosis occurs when both the electric and magnetic charges attain their lowest possible values. In the previous two cases of BSM, a magnetic or electric wall came with a single metamorphic dual, and as explained above the resulting four walls for a given charge vector (n, , m) have to be identified to obtain the correct contribution to the polar coefficients c m (n, ). When both m γ = n γ = −1, there are two centers to be identified and we can identify the magnetic and electric centers alternatively. This generates an infinite sequence of dual walls [19]. The metamorphic duals can be generated in two ways depending on which center we start the identification with. Since they are equivalent, we choose to start the identification with the magnetic center. where M 1 , M 0 are defined as For example,γ 1 = γ · M 1 ,γ 2 =γ 1 · M 0 ,γ 3 =γ 2 · M 1 , . . . 14 Note that the identification of the electric center in M 0 does not have a '− γ ' unlike in (6.19) and this dual wall will have the same sign of γ as γ. Proof. From the previous sections, we have already shown that the matrices that identify magnetic centers (6.1) and electric centers (6.19) leave the value of electric and magnetic charges invariant while only flipping the sign of γ . Therefore, the infinite set of walls generated in (6.23) have the same contribution to the index.
We now characterize dyonic metamorphosis. The possible cases for dyonic metamorphosis are shown in Figure 10, where only one case as shown in Figure 10b can in principle contribute to the black hole degeneracy in the attractor region R. The reason for this is our BSM prescription: all walls and their metamorphic must contribute in the same region to contribute to the polar coefficients c m (n, ). To obtain the explicit form of the dyonic-BSM walls we  with p q r s ∈ P SL(2, Z). It is important to recall that the discriminant ∆ is a U -duality invariant. For this reason, the value of γ is not independent and is fixed in terms of the charges (n, , m) as 2 γ − 4 = 2 − 4mn = |∆|. We further restrict to the case where γ is positive i.e., γ = |∆| + 4 so that the wall contributes to the region R. Given a charge vector (n, , m), there is an infinite sequence of walls, all with associated transformed charges (n γ , γ , m γ ) = (−1, |∆| + 4, −1), which get identified by the BSM prescription.
When n = 0, we can solve the system (6.25) after eliminating q using the P SL(2, Z) relation q = (ps − 1)/r. From m γ = −1 we obtain For each value of r, the condition n γ = −1 is quadratic in s and yields two branches of solutions. We therefore arrive at the following dyonic-BSM walls 15 Since −γ +,± (−p) = γ −,± (p) and we look for walls in P SL(2, Z), we can focus on one type of walls, say γ −,± . We therefore drop the first subscript and simply denote walls of the form (6.29) as γ ± . Examining the top-right entry of γ ± , a necessary condition for these walls to have integer entries is that |∆| + 4, |∆|p 2 − 4n ∈ Z. In the following we let y = p and D = |∆|. The requirement that D + 4 is a perfect square implies that D is not a square (as already observed above), and further that D is congruent to 0 or 1 modulo 4. The requirement Dy 2 − 4n ∈ Z can then be expressed as the requirement for y to be a solution of with x, y ∈ Z. We now split the discussion in two cases.
1. Case 1: n = −1 In the case n = −1, the condition (6.30) takes the form This equation is the so-called Brahmagupta-Pell equation and has been well-studied over the years. 16 It is one of the classic Diophantine equations, and its solutions have been fully classified. In the language of modern algebraic number theory this problem is closely related to the problem of finding units in the ring of integers of the real quadratic field Q( √ D). We will present the solution below in elementary terms, and later make some comments on the more formal interpretation. We follow the treatment of [46][47][48]. The equation (6.31) has an infinity of solutions given as follows. Let be such that u 2 0 −D v 2 0 = 4 with the least strictly positive v 0 . Then all solutions of (6.31) are given by [46] x + √ D y In general the difficulty is to find the fundamental solution u, as u 0 and v 0 need not be small even for small D. 17 In our case however, we can can use the physics of the problem which guarantees that γ = √ D + 4 is an integer. Therefore, the fundamental solution is simply From this solution we generate all other solutions from (6.33). Expanding that equation and matching the coefficients of unity and √ D leads to the recurrence for k ≥ 0. Given a solution x k + √ D y k to (6.31), the matrix (6.29) reads (6.36) 16 In the literature, it is common to denote "the" Pell equation as the equation where the right-hand side is equal to one. However, the latter is a special case of our equation (6.30) with n = −1, see e.g., [46][47][48]. Using the recursion relations (6.35), we can now show that acting on the right of γ + (k) while acting on the right of In the language of Definition 6.3, the recurrence (6.37) can be written as where we used M 0 =S · M 1 ·S. Had we chosen to start the identification with the electric center in Definition 6.3, we would have used (6.38) instead. Equation (6.39) shows that all metamorphic duals of the dyonic-BSM walls γ ± (0) are precisely all the solutions to the Brahmagupta-Pell equation (6.31).
The first representative of the orbit (the wall with k = 0) is given by Note that 2 = D −4m ≡ D +4 (mod 2), which implies that ≡ √ D + 4 (mod 2), so that the bottom-right entry of (6.40) is always an integer. Since < √ D + 4, the wall γ − (0) is an element of Γ − S . Therefore, provided that √ D + 4 ∈ Z, the wall γ + (0) ∈ Γ + S and all the metamorphic duals to be identified according to the BSM prescription are generated by the right action of M 1 ·S. These dual walls are given by all the solutions to (6.31) as in (6.36). This completely characterizes dyonic-BSM in the case n = −1. Furthermore, since 0 ≤ ≤ m, the first representative of this orbit γ + (0) clearly has entries bounded by 0 < 1 2 + √ D + 4 ≤ m + 1. By repeating the same steps as in Case 1 above, one can again show that the orbit of metamorphic duals is precisely the solution set of the generalized Pell equation, and is generated by the matrices (6.37) and (6.38) acting on As in (6.40), we have √ D + 4 ∈ Z and ≡ √ D + 4 (mod 2). In order for the matrix entries to be integer, a sufficient condition is x 0 ≡ y 0 (mod 2n). By (6.41) we have x 2 0 ≡ D y 2 0 (mod 2n). Together with the fact that D ≡ 2 (mod 2n), this implies that x 2 0 ≡ 2 y 2 0 (mod 2n), so that if n is square free, then we automatically have x 0 ≡ y 0 (mod 2n). Once this condition is met, the full orbit of metamorphic duals is generated by M 1 ·S or M 0 ·S as before.
Since k runs over all integers in (6.42), it is clear that every Pell orbit-and therefore every dyonic BSM orbit-has an element with smallest |y|, which is called the fundamental solution. Although there is no existence theorem for solutions to the generalized Brahmagupta-Pell equation (6.41) when n ≥ 1, there is a powerful theorem [47,48] which states that the fundamental solution is bounded according to These bounds are very restrictive, and in particular, they imply that the set of dyonic-BSM orbits is finite, with a representative whose entries are strictly less than m + 1.
We have thus fully characterized the dyonic-BSM walls and explained how the infinite orbit of metamorphic duals defined in Definition 6.3 is in one-to-one correspondence with the infinite orbit of solutions to the (generalized) Brahmagupta-Pell equation. Crucial to being able to solve the problem was the fact that U -duality fixes γ = |∆| + 4 to be an integer.
It is instructive to restate the solutions of the Brahmagupta-Pell equation in the language of algebraic number theory [46][47][48]. Consider the real quadratic field K = Q( √ D) where D > 0 is not a square. We will denote elements of this field either as (x, y) or as x + √ D y with x, y ∈ Q. The norm of this element is N (x, y) = x 2 −Dy 2 . By a change of variables ( [46], p. 355) one can bring the basic Brahmagupta-Pell equation to the form Thus we are looking for elements of norm 1. By multiplicativity of the norm, it is clear that if u = x + √ D y is a solution of (6.45), then so is u k for k ∈ Z. (It is easy to check, by rationalizing denominators and using (6.45), that negative powers are also good solutions. we have D = D 0 f 2 . When f = 1 the solution to this problem is given by Dirichlet's unit theorem, that all solutions are generated as powers of the fundamental unit a 0 + √ D b 0 which is the unit with least positive b 0 . In fact this statement holds even when f > 1 (one can use a proof by induction on the number of prime powers of f ). By changing variables back, we obtain the formulation (6.33).
For the general case we have, after the change of variables mentioned above, with n ∈ Z (our interest in this paper is in n ≥ −1 with n = 0). In this case, we are looking for elements in K with norm −n. Once again it is easy to see, by the multiplicativity of the norm, that given one such element (x 0 , y 0 ) with N (x 0 , y 0 ) = −n we have an infinite number of elements with the same norm generated by multiplying x 0 + √ D y 0 by arbitrary powers of a unit. The main theorem in this case says that there are a finite number of fundamental solutions (x 0 , y 0 ) which lie in the range |x 0 | ≤ |n|u, |y 0 | ≤ |n|u/D, where u is any unit satisfying u > 1 and N (u) = 1. This last condition, translated back to our variables is presented in (6.44).

Summary
For convenience, we now summarize the results of Sections 5 and 6 where we have characterized all the walls contributing to the negative discriminant degeneracies (4.14). There are two notable points.
Finiteness. Examining the various cases (with and without BSM), we see that the set of relevant walls is finite, and in fact small in the following sense: it consists of S-walls with entries bounded (in absolute value) from above by m + 1, where the upper bound is optimal for certain values of the original charges (n, , m), as evidenced e.g., in (6.13). Moreover, all walls are such that |p/r| ≤ 1 and |q/s| ≤ 1 and so their endpoints lie in the strip Σ 1 ∈ [−1, +1] in the Σ moduli space.
Structure. The structure of walls of electric and magnetic BSM form an orbit generated by the corresponding BSM transformation which acts as Z/2Z. The dyonic bound state metamorphosis has a very interesting characterization. We already knew that there is an infinite set of different-looking gravitational configurations, all with the same total dyonic charge invariants with negative discriminant, which are related by U -duality to each other. The phenomenon of BSM [19,24] says that these configurations actually should not be considered as distinct physical configurations; rather, they must be identified as different avatars of the same physical entity. Our considerations in this section show that the following sets are in one-to-one correspondence: as the fundamental unit, as well as the second congruence condition above.
Moreover, these sets are isomorphic to each other (and to Z) as an additive group. The generators of the groups are given, respectively, by the generators in Definition 6.3 (moduloS), and by multiplication in K by the fundamental unit.

The exact black hole formula and experimental checks
In this section we assemble all the elements of the previous sections into one formula, and then we present checks of this formula. So far we have seen that the walls of marginal stability contributing to the polar coefficients according to Equation (4.14) are a subset of P SL(2, Z). Bound state metamorphosis is an equivalence relation on the set P SL(2, Z) and therefore divides it into orbits µ. We denote the set of orbits as (cf. Equation (4.12)) Γ BSM (n, , m) = P SL(2, Z)/BSM .
The orbits are of the following three types: 1. Walls for which there are no metamorphosis. These walls have no duals and therefore lie in an orbit of length 1.
2. Walls with either electric or magnetic metamorphosis, for which there is exactly one dual with the same contribution to the index. These walls lie in an orbit of length 2.
3. Walls with dyonic metamorphosis for which there are an infinite number of dual walls. These walls lie in an orbit of infinite length with a group structure isomorphic to Z.
We have seen that the contribution of an orbit to the index is one if all its elements contribute, and zero otherwise. This can be encoded in the following function defined on orbits (recalling Equations (4.8), (4.10) for the definition of the θ function), which can be lifted to a function on the space of walls as (using the same notation) We now have all the elements to present the full formula for the polar degeneracies (2.10). in the range 0 ≤ ≤ m we have: 18 c m (n, ) = 1 2 γ∈Γ BSM (n, ,m) The sum in the above formula runs over Γ BSM (n, , m) which was defined as a coset of P SL(2, Z) in (7.1). We can also write the formula so that the sum runs over a smaller set, by using the symmetry of the theory and making a choice in obtaining the coset representative. Such a choice makes the formula more explicit and is useful for computations. We had already illustrated the idea of two such formulas in our preliminary discussion in Section 4.2 where we didn't take BSM into account. In that case we had a sum over P SL(2, Z) in (4.9) but by using the involution S, we could equivalently write it as a sum over Γ + S as in (4.11) with an additional factor of 1 2 . When BSM is present this discussion needs to be modified. When we have pure electric or pure magnetic BSM, the orbits of length 2 discussed in Case 2 above are actually part of a full symmetry orbit of length 4 via the following identifications: (7.5) In particular, the combined symmetry of BSM and S implies an identification of two walls in Γ + S , namely the first and the third of the above sequence. By definition, a given wall belongs to one and only one symmetry orbit, and, as we have shown in the previous sections, when 0 ≤ ≤ m, every orbit has a non-empty intersection with the set p q r s ⊂ Γ + S |p| , |q| , |r| , |s| ≤ m + 1 .
We now present checks of this formula. Table 1 lists negative discriminant states for m = 1, . . . , 5. Column I lists the charge invariants (m, n, ) with discriminant ∆ = 4mn− 2 < 0. Note that we have changed the order of the charge invariants here with respect to the rest of the paper. The organization is as follows: we first list m which is the index of the mock Jacobi form, followed by n and . The range of is m, . . . , 0 which covers all the cases as explained in Section 2, and n runs over all values that produce a negative discriminant with non-zero coefficient for ψ F m . Column II lists the walls γ ∈ W(n, , m) which contribute to the degeneracy of states with these charge invariants. These walls have been discussed in Sections 5 and 6. The walls in Column II, as stated in (4.5), are semicircles from q/s → p/r, where p q r s is a P SL(2, Z) matrix. Column III shows the transformed charges at the wall γ. In the γ-transformed S-duality frame the decay products are (Q γ , 0) and (0, P γ ) with invariants (m γ , n γ , γ ) (cf. (4.2) and (4.4)). Cases with either m γ = −1 or n γ = −1 correspond, respectively, to magnetic and electric metamorphosis. An example is (m, n, ) = (1, −1, 0) where we have the walls (m γ , n γ , γ ) = (−1, 0, 2) and (−1, 0, −2) (with contribution 48) are identified due to magnetic BSM as shown in the table. According to the discussion around (7.5), we also need to identify these walls with (0, −1, 2) and (0, −1, −2) (which we have not explicitly displayed in the table). In a similar manner, we have only displayed pure magnetic, but not pure electric BSM phenomena in the table. The cases with m γ = n γ = −1 correspond to dyonic metamorphosis, in which case an infinite number of walls must be identified (see Section 6.3). An example is (m, n, ) = (1, −1, 1). Here we have exhibited four walls corresponding to the first two solutions to the Brahmagupta-Pell equation (6.31) (the trivial solution with p = 0 and the first non-trivial one with p = 1) and their respective first metamorphic duals (γ built with M 1 in Definition 6.3). Column IV is the index contribution of each wall and Column V is the total index c m (n, ) according to our formula (7.7). This agrees with with a direct calculation of the polar degeneracies of ψ F m (τ, z). We have run similar checks up to m = 30 which includes 1650 polar coefficients and find perfect agreement between the formula (7.7) and the polar coefficients of ψ F m . In Appendix C we show more values of the total index (corresponding to Columns I and V of Table 1).
In [33], two of the authors of this paper compared the degeneracies of negative discriminant states of ψ F m for m = 1, · · · , 7 and the result of the formula (3.10) which, as explained in Section 3, was found by a combination of physical and mathematical ideas. It was observed in that paper that (3.10) agrees with the data from ψ F m for many but not all the cases of negative discriminant states. The main formula of this paper (7.4) or, equivalently, (7.7), removes these discrepancies completely. As an example, the approximate formula (3.10) gives 6400 for the charges (m, n, ) = (3, −1, 0), while the correct answer is 6404. In the table we explicitly see the correction of 4 coming from the subleading contribution of dyonic-BSM walls.
A natural extension of this technique is to extend it to the cases of Z N CHL orbifolds. We have preliminary data which we hope to analyze in the near future, thereby generalizing the formula presented here. Here, the comparison against coefficients of the inverse of the orbifolded Igusa cusp form, Φ k would involve the Rademacher technique for mock Jacobi forms on congruence subgroups of SL(2, Z). This would be a generalization of the analysis for 1 2 -BPS black holes under CHL orbifolds as studied in [49] and the techniques studied in [50,51].   The Rademacher expansion provides a powerful tool to reconstruct the Fourier coefficients of Jacobi forms. We illustrate it here for weights w + 1/2 smaller or equal to zero, modular group SL(2, Z) and generic multiplier system ψ(γ). Once the modular properties of the modular forms h (τ ) are known, the only extra ingredient required to determine the Fourier coefficients c(n, ) with ∆ ≥ 0 are the polar coefficients, i.e. the terms with negative powers of q in the Fourier expansion h (τ ) = and asymptotics There exists a generalization of the Rademacher expansion applicable to cases where the function ϕ is a mock Jacobi form [16][17][18]52]. As discussed in the main text, the function that is relevant to our story is the mock Jacobi form ψ F m . In this case, the generalized Rademacher expansion for the Fourier coefficients c F m (n, ), ∆ ≥ 0, was obtained in [10]. It reads:

A (Mock) Jacobi forms and the Rademacher expansion
where the multiplier system ψ(γ) is given explicitly in [10] in terms of the (known) multiplier system of the Jacobi theta functions (A. 6), and the function f k,g,m in the last line is given by (A.13) The last two terms in (A.12) arise due to the mock modular nature of ψ F m . Note that these terms have no free parameter, which is a consequence of the fact that the shadow of ψ F m has a single polar coefficient equal to one. The first line is the standard Rademacher expansion for a Jacobi form of weight −10 and index m. Although the above formula may appear daunting, its main feature is that the coefficients c F m (n, ) for ∆ ≥ 0 (the left-hand side) are completely determined by the polar coefficients c F m (n, ) for ∆ < 0, and the modular properties of ψ F m such as its weight, index, and multiplier system.

B Checks of finiteness of the set W(n, , m)
In this appendix, we present the magnetic-BSM walls of Section 6.1, Case 3 that have r = r + . As explained there, we were not able to derive an analytic upper bound on their p entry. However, we were able to check that for a given charge vector (n, , m) only a single 19 wall contributes to the polar coefficients. Below we give the explicit form of these walls for all charge vectors with m ≤ 30 where they exist. They are built as P SL(2, Z) matrices with p, s entries consistent with (6.15) and (6.16), together with a numerical upper bound p ≤ 10 6 .

C A sample of polar degeneracies
In this section, we use our formula (7.4) to compute the polar coefficients of ψ F m (τ, z) for a few sample cases of m. The results presented below precisely agree with the polar coefficients extracted from the inverse of the Igusa cusp form Φ −1 10 following the method outlined in the introduction below (1.6). For the sake of brevity, we only present a few examples owing to the large amount of data.