Refinement and modularity of immortal dyons

Extending recent results in ${\cal N}=2$ string compactifications, we propose that the holomorphic anomaly equation satisfied by the modular completions of the generating functions of refined BPS indices has a universal structure independent of the number ${\cal N}$ of supersymmetries. We show that this equation allows to recover all known results about modularity (under $SL(2,\mathbb{Z})$ duality group) of BPS states in ${\cal N}=4$ string theory. In particular, we reproduce the holomorphic anomaly characterizing the mock modular behavior of quarter-BPS dyons and generalize it to the case of non-trivial torsion invariant.


Introduction
The spectra of BPS states in theories with extended supersymmetry contain vital information about their non-perturbative structures and strong coupling regimes. These in turn provide valuable insights into the mathematical structures that encode the organization of the fundamental degrees of freedom in these theories. Hence, determining these spectra constitutes an active avenue of research initiating a rich interplay between theoretical and mathematical physics. The BPS spectrum in any such theory is strongly constrained by symmetry requirements. Specifically, in superstring theory compactifications the BPS spectrum is expected to be invariant under the U-duality group acting on charges carried by the BPS states. The duality group also manifests itself in the same context, when it acts on generating functions of BPS indices restricting them to be modular or mock modular forms.
The mock modular behavior [1,2] of the generating functions under SL(2, Z) duality group has, in fact, been found to be a very generic phenomenon. It features prominently in the counting functions of black hole degeneracies in string compactifications with N = 2 and N = 4 supersymmetry [3,4,5], Vafa-Witten theory [6,7], Donaldson-Witten theory [8,9], moonshine phenomenon [10] and numerous other setups. Mock modularity implies that the holomorphic generating functions are not quite modular forms. They have a very specific modular anomaly which can be cancelled by the addition of a suitably chosen nonholomorphic term. The resulting functions, called modular completions, do transform as modular forms, but by construction fail to be holomorphic and satisfy certain holomorphic anomaly equations. These modular completions and the associated anomaly equations are of paramount significance both from a physical and mathematical standpoint. On the one hand, they are building blocks of physical quantities such as partition functions while on the other hand, they facilitate access to the precise modular transformation properties of BPS indices which can notably be used to determine these indices exactly.
Recently, in [5] a quite general result about these modular completions has been obtained in the context of D4-D2-D0 black holes in type IIA string theory compactified on a generic Calabi-Yau (CY) threefold Y. This result took the form of a formula for expressing the modular completions h p,µ (τ,τ ) of the generating functions 1 h p,µ (τ ) of BPS indices for these black holes, evaluated at the large volume attractor point (see section 3.1 for precise definitions), in terms of the generating functions h p,µ (τ ) themselves. This formula in particular implies that as soon as the divisor D ⊂ Y wrapped by D4-brane is reducible, i.e. it can be decomposed into a sum with positive coefficients of other divisors, the corresponding generating function is a vector valued (higher depth) mock modular form. This result was subsequently generalized in [11] to include a refinement parameter y = e 2πiz conjugate to the angular momentum. Although in the case of compact CY threefolds the refined BPS indices Ω(γ, y), where γ is an electromagnetic charge, are not protected by supersymmetry, they can still be defined [12,13,14] and their generating functions possess very similar modular properties provided the parameter z transforms as an elliptic parameter. As a result, the generating functions h ref p,µ (τ, z) of refined BPS indices were shown to behave as mock Jacobi forms [3]. Although the formula for the modular completion has been found in the case of a generic compact CY, i.e. a threefold with SU(3) holonomy and not its proper subgroup, and for an ample divisor, it turned out that it has a wider range of applicability. In particular, it can be extended to non-compact CYs given by the canonical bundle over a projective surface S. In this case it provides the modular completion of generating functions of (refined) Vafa-Witten invariants of the surface S with gauge group U(N) [11]. In [15,16] this result has been used to actually find these generating functions as well as their completions explicitly, for any rank N and S = P 2 , Hirzebruch or del Pezzo.
In this paper we study another extension of that construction. While it was originally formulated in the context of 4d N = 2 supergravity, it is natural to ask whether it also captures the modular properties of BPS indices in theories with larger amount of supersymmetry, which are obtained by compactifying type II string theory either on Y = K3 × T 2 or on T 6 . This amounts to dropping the condition that the holonomy group of Y is exactly SU (3). Here we mostly restrict our analysis to the case Y = K3 × T 2 corresponding to N = 4 supersymmetry in four dimensions, and reserve the case Y = T 6 for future work. N = 4 superstring compactifications have been extensively studied in the literature and there is, at present, a substantial body of knowledge about their BPS indices and the duality transformation properties of their generating functions. As we review below in section 2, there are two types of BPS states for both of which the counting functions are known exactly. For 1 2 -BPS states the generating function is a weakly holomorphic SL(2, Z) modular form of weight −12, whereas the degeneracies of 1 4 -BPS states are given by Fourier coefficients of Z(τ, z, σ), the inverse of an Igusa cusp Seigel modular form of weight 10, which transforms under the larger group Sp(2, Z) [17]. Expanding this function only in σ, one finds that the coefficients ψ m (τ, z) are Jacobi forms of weight −10 and index m with respect to the usual modular group SL (2, Z). Although everything appears to be modular at this stage, the remarkable work [3] revealed a hidden mock modularity. It turns out that each meromorphic function ψ m has a canonical decomposition into two parts, ψ P m and ψ F m . While the former only counts bound states, the single centred black holes, known as immortal dyons, are encoded in the latter. Both ψ P m and ψ F m are mock Jacobi forms and the work [3] provides the holomorphic anomaly equations satisfied by their completions, ψ P m and ψ F m . As will be shown below, all the results concerning the modular properties of BPS dyons under SL(2, Z) can be derived from a simple extension of the holomorphic anomaly equation satisfied by the modular completions h ref p,µ of the generating functions of refined BPS indices. This extension allows to drop restrictions on Y and the divisor D. The derivation is based on two observations. First, we note that the BPS indices counting black hole degeneracies are given by helicity supertraces B 2K [18] with the center of mass contribution factored out. Which helicity supertrace is relevant depends on the number of broken supersymmetries, but all of them can be obtained from the refined BPS index Ω(γ, y) by taking appropriate number of derivatives with respect to y, needed to kill fermionic zero modes, and then setting it to y = 1. In particular, in this way we arrive at generating functions which transform as (mock) modular forms of weight where 2K is the label of the relevant helicity supertrace and r is the rank of the electric charge lattice Λ p assigned to the magnetic charge p. Secondly, it is well known that in the chamber of the moduli space containing the large volume attractor point, the indices counting BPS black holes with non-vanishing area receive no contribution from bound states [19] (except the so called scaling solutions [20,21] [3] holds only for charge vectors with the trivial torsion invariant I(γ) = 1 (see (2.7)), we generalize it to arbitrary values of I(γ). To the best of our knowledge, this result, provided in eq. (4.26), did not appear in the literature before.
The organization of the paper is as follows. In the next section we recall relevant aspects of string compactifications with N = 4 supersymmetry. In particular, we introduce the generating functions counting immortal dyons and the holomorphic anomaly equation satisfied by their completions. In section 3 we review the construction of the completion of the generating functions of refined BPS indices in N = 2 string compactifications, extend it to cases with more supersymmetries, and derive consequences of this extension in the unrefined limit. Subsequently, in section 4 we apply these results in the N = 4 case where we reproduce the counting function of 1 2 -BPS dyons, derive the holomorphic anomaly equation for 1 4 -BPS dyons, demonstrate its consistency with [3] and provide a generalization for I(γ) > 1. We conclude with a discussion in section 5. The few appendices herein contain useful details on the chain of dualities between different formulations with N = 4 supersymmetry, modular transformations of generating functions, as well as restrictions on charges implied by the attractor mechanism.

Charges and generating functions
Type IIA string theory compactified on K3 × T 2 reduces in four dimensions to N = 4 supergravity coupled to 22 vector multiplets. The number 22 is the dimension of the second homology lattice of K3, which has signature (3,19) and is composed by two lattices of E 8 and three two-dimensional even latices of signature (1,1), which will be denoted by U 1,1 : The corresponding vector fields A i , i = 1, . . . , 22, arise from the ten-dimensional 3-form gauge field after its reduction on the 2-cycles of K3. In addition, there are also 6 vector fields (A 0 , A ♭ , A x ), x = 23, . . . 26, in the supergravity multiplet related to the geometry of the torus: they originate from the ten-dimensional 1-form, the 3-form reduced on T 2 , the B-field reduced along the two circles of T 2 and the two KK gauge fields on T 2 , respectively. Thus, in total there are 28 gauge fields A I , I ∈ {0, ♭, 1, . . . , 26}, so that the electro-magnetic charge vector γ = (p I , q I ) has 56 components. In fact, many features of the compactified theory, including its symmetries, are better seen in the dual heterotic formulation which is obtained by compactifying heterotic superstring on T 6 [22]. The 28 gauge fields now arise from the Cartan subalgebra of the rank 16 tendimensional gauge group, the reduction of the B-field and the KK gauge fields on T 6 . They transform as a vector under T-duality group SO (6,22), whereas the full U-duality group includes also SL(2, Z) S-duality which acts on the heterotic axio-dilaton Note that in the type II formulation, the SL(2, Z) factor is just the modular group of the torus T 2 .
In this heterotic frame, the electro-magnetic charge belongs to the representation (2, 28) of the U-duality group and hence can be represented as a doublet of two vectors under the orthogonal group and Λ m = Λ * e = Λ e because Λ e is unimodular. The bilinear form on Λ e is given by an O(6, 22) invariant matrix where C 16 is the Cartan matrix of E 8 × E 8 . Using this bilinear form, one can define three T-duality invariants and one their U-duality invariant combination Besides, there is also another U-duality invariant, the torsion, which is defined as follows [23] I(γ) = gcd{Q I P J − Q J P I }. (2.7) Taken together, these invariants are sufficient to characterize uniquely the duality orbit of the charge vector [24,25]. The heterotic frame is particularly convenient to classify BPS states. There are two classes of them: 1 2 -BPS and 1 4 -BPS. The former are characterized by the charges (2.3) which have parallel electric and magnetic charge vectors, Q P . This implies that there is a duality frame where one of them, e.g. P , can be set to zero. Thus, the 1 2 -BPS index, which is invariant under the full U-duality group, depends only on one T-duality invariant n and, moreover, it is known to be independent of the moduli. Thus, the 1 2 -BPS spectrum can be encoded into a generating function of one variable where q = e 2πiτ and we accepted the convention, which will be extensively used below, that the upper index of type (N |r) refers to 1 r -BPS states in a theory with N extended supersymmetry. The generating function (2.8) has been found explicitly [26] and is given by a modular form of weight −12, The spectrum of 1 4 -BPS states, which have Q and P non-parallel, is much more complicated. First of all, their degeneracies depend on all duality invariants introduced above so that we can write 2 Ω (4|4) (γ) = Ω where y = e 2πiz , p = e 2πiσ and q is as in (2.8). The famous result of [17] expresses this function for I = 1 in terms of the so-called Igusa cusp form , which is a modular form with respect to Sp(2, Z) acting on the Seigel upper half-plane parametrized by τ , z and σ. We will not use this fact in this paper since our analysis is restricted to the modularity with respect to the usual S-duality group SL(2, Z). The degeneracies of 1 4 -BPS states with I > 1 have been found in [29] and can be expressed through those with I = 1 determined by (2.12), Another complication compared to the 1 2 -BPS case is that the indices Ω (4|4) I are actually moduli dependent. The physical reason for this is that a 1 4 -BPS state can be a bound state of two 1 2 -BPS ones [30]. Such bound states do not exist throughout all the moduli space and decay after crossing the lines of their marginal stability [31]. Mathematically, this dependence is manifested by the existence of second order poles in the generating function (2.12). As a result, its Fourier coefficients are not defined uniquely, but depend on the integration contour in the Seigel upper half-plane which in turn is determined by the moduli [32].
While the heterotic frame is very convenient for formulating results about BPS states, for our purposes we need to relate it to the type IIA frame. To this end, we express the charge vector (2.3) through the charges (p I , q I ) introduced in the beginning of this section. The resulting charge vector reads [33] where α = 1, . . . , 26. In appendix A we recall the chain of dualities leading to this result.

Mock modularity of immortal dyons
Let us return to 1 4 -BPS states and expand their generating function (2.12) for the trivial torsion invariant in Fourier series in σ From the modularity of Φ 10 with respect to Sp(2, Z) it follows that the coefficients ψ m (τ, z) are Jacobi forms of weight −10 and index m (see (B.1) for the definition of a general Jacobi form). Note that if we considered the generating function Z (4|4) I with I > 1 and performed a similar expansion, due to (2.13) the corresponding coefficients would be Jacobi forms only with respect to a congruence subgroup Γ 0 (I) ⊂ SL(2, Z) [29] defined by The Jacobi forms ψ m inherit the double poles from Z (4|4) 1 and hence are meromorphic functions in z. In [3] it was shown that they admit a canonical decomposition where ψ P m contains the "polar" part of the original function and is captured by the so-called Appell-Lerch sum, whereas ψ F m is holomorphic. This decomposition was also given a physical interpretation: all contributions of single centered black holes are encoded in ψ F m while ψ P M only contains contributions of bound states. Since the bound states decay at lines of marginal stability, it is possible to choose a region of moduli space where ψ P m vanishes. Single-centered black holes exist in all regions of moduli space and hence, ψ F m can be viewed as the counting function of immortal dyons.
An important result of [3] is that both functions ψ P m and ψ F m are mock Jacobi forms, i.e. their modular transformations are anomalous. The corresponding modular anomalies must be equal and opposite so as to cancel each other on adding the corresponding mock Jacobi forms to give a fully modular object as in (2.17). Furthermore, there is a canonical way to construct modular completions ψ P m and ψ F m which do transform as Jacobi forms, but are not holomorphic. In particular, the modular completion ψ F m was shown to satisfy the following holomorphic anomaly equation 4 This is the result which will be reproduced below, and generalized to include a non-trivial torsion, from a completely different approach starting from the generating functions of D4-D2-D0 black holes degeneracies in N = 2 compactifications.

Refined BPS index and modularity
Let us consider type IIA string theory compactified on a generic compact CY threefold Y with SU(3) holonomy group. At low energies it is described by N = 2 supergravity coupled to h 1,1 (Y) = b 2 (Y) vector multiplets and h 2,1 (Y) + 1 hypermultiplets. The 1 2 -BPS states in this theory are labelled by electro-magnetic charge γ = (p 0 , p a , q a , q 0 ) with a = 1, . . . , b 2 whose entries correspond to D6, D4, D2 and D0-brane charges, respectively, and at large coupling are realized as supersymmetric black holes. They are counted (with sign) by BPS indices Ω (2|2) (γ) which are known to coincide with the generalized Donaldson-Thomas (DT) invariants of the CY threefold. In fact, below we will deal mostly with their refined version which reduces to Ω (2|2) (γ) at y = 1. Here J 3 is a Cartan generator in the massive little group in 3+1 dimensions, H ′ γ is the Hilbert space of states graded by the charge γ with the center of mass degrees of freedom excluded, and y is a refinement parameter. In particular, we will be interested in the modular properties of the generating functions of the refined indices.
While in string theory on K3 × T 2 the modular symmetry can be trivially identified with large diffeomorphisms of the torus, one may wonder where it comes from for type IIA on a generic CY. It can be revealed by compactifying this theory on a circle. Indeed, the resulting theory has two dual formulations: it can be viewed either as M-theory on Y × T 2 or, after applying T-duality along the circle, as type IIB string theory on Y × S 1 . In both formulations the modular symmetry is evident 5 and must be realized as an isometry of the moduli space M 3d in three dimensions [34]. Given that the BPS states in four dimensions induce instanton corrections weighted by Ω (2|2) (γ) to the metric on M 3d , this modular isometry constraint imposes non-trivial restrictions on the BPS indices.
To proceed further we need to restrict to the vanishing D6-brane charge p 0 . The reason is that SL(2, Z) mixes D6-branes wrapped on Y × S 1 with KK-instantons (or in the Tdual picture, D5 and NS5-branes both wrapped on Y). Whereas the exact description of D-instantons is well-known by now [34,35,36], the understanding of NS5-brane instantons remains incomplete (see [37,38,39]), which makes it difficult to draw precise conclusions for the modular properties of BPS indices with non-vanishing p 0 .
Thus, we consider BPS states with the charge γ = (0, p a , q a , q 0 ) satisfying the following quantization conditions [37]: Here c 2,a are components of the second Chern class of Y and κ abc are the intersection numbers on Λ = H 4 (Y, Z). Furthermore, the divisor D = p a γ a , where γ a is a basis of Λ, wrapped by D4-brane must be ample, i.e. belong to the Kähler cone defined, in terms of a convenient notation (lkp) = κ abc l a k b p c , by for all divisor classes r a γ a ∈ H 4 (Y, Z) with r a > 0, and curve classes k a γ a ∈ H 2 (Y, Z) with k a > 0. Under these conditions, the charge p a induces a quadratic form κ ab = κ abc p c of signature (1, b 2 − 1) on the lattice Λ. This quadratic form allows to embed Λ into Λ * = H 2 (Y, Z), but the map ǫ a → κ ab ǫ b is in general not surjective, the quotient Λ * /Λ being a finite group of order | det κ ab |. As in N = 4 string theory, the BPS indices carry dependence on CY moduli z a due to the existence of bound states and the wall-crossing phenomenon [40]. But while in N = 4 there are only bound states with two constituents [30], in the N = 2 setup the number of constituents can be arbitrary. Given that the modular group acts on z a and thus can map from one chamber of the moduli space M to another, the complicated wall-crossing pattern makes it difficult to expect any simple modular properties from the BPS indices considered at arbitrary point in M.
This problem is solved by considering the BPS indices evaluated at the large volume ) as well as their refined version possess a set of important properties: • Spectral flow symmetry. They are invariant under spectral flow transformations acting on the D2 and D0 charges via with ǫ a ∈ Λ. These transformations leave invariant the combination where κ ab is the inverse of κ ab , and allow a decomposition of the D2-brane charge into the spectral flow parameter ǫ and the residue class As a result, due to the spectral flow symmetry, the BPS indices evaluated at (3.4) depend only onq 0 , p a and µ a so that we can write (in the presence of refinement) Ω ⋆ (γ, y) = Ω p,µ (q 0 , y). • Relation to single-centered black holes. The index Ω p,µ (q 0 , y) is known to be closely related to the one counting single-centered black holes. Although they do not coincide [19], the difference between these two indices is only due to the so-called scaling solutions, i.e. multi-centered black holes whose constituents can become arbitrarily close to each other and are allowed to exist in the attractor chamber. An important feature of these scaling solutions is that they comprise of at least 3 centers [20,21].
These properties allow to define a natural generating function where we represented the refinement parameter as y = e 2πiz and introduced rational invariants which differ from the integer valued ones only for non-primitive charges, In the refined case, the rational invariants appeared first in [14] where they were shown to have simplified wall-crossing properties. It is crucial to use them in the generating function for the latter to possess nice modular properties, and we will see that they are also important for agreement with the results presented in the previous section.
In [11], on the basis of the unrefined construction resulting from the analysis of the threedimensional moduli space M 3d [5], it was argued that that the generating functions (3.9) of refined BPS indices transform under modular transformations which transforms as a true Jacobi form of the same weight and index, and the main result of [11] was a formula for such completion expressing it as a series in h ref We will be mainly interested in the holomorphic anomaly equation satisfied by h ref p,µ which was also derived in [11] and takes the following form , the electric charges q i,a are decomposed as in (3.7) with the quadratic form κ i,ab = κ abc p c i , and Each term in (3.12) has the form of the product of the completions corresponding to charges p a i , multiplied by a theta series determined by the quadratic form Q n and the kernel J ref n . It is important that due to the restrictions on the divisors D i = p a i γ a , all κ i,ab are of Lorentzian signature so that Q n has rank (n − 1)b 2 and signature ((n − 1)(b 2 − 1), n − 1).
Of course, all non-trivialities are hidden in the kernels J ref n . They are expressed through the so called generalized error functions [41,42], but we will not need their explicit form in this work and refer an interested reader to [11]. The only fact which is relevant for us is that they have a zero of order n − 1 at y = 1, i.e.
is finite and well defined. In particular, one can show that where is the Dirac product on the charge lattice (for vanishing D6-brane charge). Taking into account the presence of the factor (y − y −1 ) −1 in the definition of the generating functions (3.9), the property (3.14) ensures that the holomorphic anomaly equation (3.12) has a well defined unrefined limit y → 1. Provided the generating functions of unrefined BPS indices are defined by Our goal is to extend the results just described to more general compactifications which include in particular CY threefolds with a reduced holonomy group like K3 × T 2 . One immediately notices some similarities in the (mock) modular behavior of the generating functions defined in this and the previous sections. However, a closer inspection reveals important differences: • While the anomaly equations (2.18) and (3.12) both imply mock modularity of the holomorphic generating functions, the r.h.s. of the former is only quadratic in BPS indices, whereas in the latter one sums over all possible decompositions of the charge into any number of constituents with the only condition of D i being ample.
• In the case of Y = K3×T 2 , the electric charge lattice is larger than the second homology lattice H 2 (Y, Z) and its signature is not Lorentzian.
In the next subsections we show how these differences can be incorporated into a general framework allowing to establish a precise correspondence with the well known results in N = 4 string compactifications.

Helicity supertraces and refined index
The differences delineated above between the N = 2 and N = 4 cases are not too surprising in light of the fact that we are trying to compare theories with different amount of supersymmetry. Furthermore, it is important to note that the BPS indices in the two theories are genuinely different quantities, irrespective of whether they count BPS states with the same or different number of conserved supersymmetries. These indices, similar to the Witten index, perform a weighted count (with signs) of the short and intermediate multiplets in the corresponding supersymmetric theories and are precisely defined in terms of helicity supertraces [18], where R is a representation of the supersymmetry algebra. The insertion of each power of J 3 in the trace soaks up 2 fermionic zero modes. Each fermionic zero mode corresponds to a broken supercharge and all of them should be soaked up to get a non-vanishing result. A 1 r -BPS state breaks 4N (1 − 1 r ) supercharges resulting in the same number of zero modes. Hence, the first helicity supertrace to which a multiplet of 1 r -BPS states in a 4d theory with N extended supersymmetry can contribute non-trivially is B 2K with Hence, the index Ω (2|2) (γ) counting 1 2 -BPS states in N = 2 theories is encoded in B 2 , whereas the indices Ω (4|2) (γ) and Ω (4|4) (γ) in N = 4 can be obtained from B 4 and B 6 , respectively. In order to extract an index from a helicity supertrace, one should factor out the center of mass contribution equal to the helicity supertrace of the corresponding BPS multiplet, 7 where R j,2K denotes the supersymmetry multiplet constructed by acting on a spin j ground state with 2K oscillators. Hence we can write down indices in N = 2, 4 theories as , , where H γ,j = H ′ γ ⊗ R j,2K . Here we have suppressed the suffix 2K on H γ,j as it is purely determined by the charge γ and the total number of supersymmetries, and instead indicated explicitly the latter.
At this juncture, we make the following significant observation. All of the different helicity supertraces B 2K can be obtained from a single helicity generating function [18] B(R, y) = Tr R (−y) One immediately recognizes this generating function to be reminiscent of the refined BPS index Ω(γ, y) introduced in (3.1). Indeed, to obtain the latter, one needs only to factor out again the center of mass contribution Ω(γ, y) = B(H γ,j , y) B cm (j, y) . (3.24) Since, by definition, in the unrefined limit, the refined index reduces to the 1 2 -BPS index of N = 2 theory, Ω(γ, 1) = Ω (2|2) (γ), the center of mass contribution must be given by the helicity generating function evaluated on an N = 2 short multiplet which results in It is easy to check that, setting y = 1 in (3.24), ones does reproduce the first relation in (3.21) because in N = 2 theory the helicity generating function behaves near y = 1 as Importantly, the relation (3.24) holds as a perfectly sensible relation beyond N = 2. Thus, the refined index can be defined in a theory with any number of supersymmetries through its relation to the helicity generating function and the only information about its N = 2 origin is contained in its normalization factor (3.25). It can also be related to the indices counting 1 r -BPS multiplets in theories with N extended supersymmetry with generic N and r, which we define by generalizing (3.21) where K is determined by N and r by (3.19). To get such a relation, one should note that B(R j,2K , y) ∼ (y − 1) 2K near y = 1. This fact together with the relation (3.23) ensures that B 2K is the first non-vanishing helicity supertrace for such multiplets. By combining (3.23)-(3.25), one can then express the index (3.26) through the refined BPS index as In particular, for (N |r) = (4|2) and (4|4) corresponding to K = 2 and 3 respectively, this provides a precise relation between the BPS indices in N = 4 theory and the refined BPS index introduced in the N = 2 context. More generally, eq. (3.27) encodes the formula for extracting BPS indices in a general theory with extended supersymmetry from a single refined index.

Proposal
Given that one can write down a refined BPS index in any theory with extended supersymmetry, the next natural step is to generalize the results about modularity of its generating functions, presented in section 3.1, to string compactifications with N > 2. In particular, we assume that in all these theories one can still construct the generating functions h ref p,µ (3.9) of (rational) refined indices evaluated at the large volume attractor point and that they behave under modular transformations as vector valued (higher depth) mock Jacobi forms. To write however a generalization of the holomorphic anomaly equation satisfied by their completions requires understanding of several issues.
The first new feature appearing for N > 2 is that the charge lattice is larger than the homoology lattice of the CY and includes NS charges appearing due to the existence of nontrivial one-cycles. The full charge vector can be represented as γ = (p I , q I ) = (p 0 , p A , q A , q 0 ) where A runs over b 2 + 2b 1 values and as before we will restrict to the vanishing D6-brane charge p 0 = 0.
The crucial role in the construction of section 3.1 was played by the quadratic form κ ab = κ abc p c determined by the intersection numbers. In theories with N > 2 there is a natural generalization of this object which can be read off from the classical prepotential governing the couplings of vector multiplets in the effective action at the two-derivative level. The prepotential has a cubic form 8 and hence defines a tensor 9 κ ABC , which can be seen as an extension of the intersection numbers. It defines the natural quadratic form κ AB = κ ABC p C which appears in the spectral flow transformations (3.5) [44]. Hence, one may expect it to replace κ ab also in the definition of the quadratic form Q n (3.13) entering the holomorphic anomaly equation for refined indices. This replacement has important implications. First, it changes the rank of the quadratic form and hence the modular weight of various theta series appearing as building blocks in the construction of the completion. On the other hand, the weight of h ref p,µ was tuned to compensate the weight of these theta series. Thus, one can expect that now it will be given by . (3.29) In the N = 2 case the rank was always maximal due to the ampleness condition on the divisor. It turns out that for N > 2 this condition should be relaxed and replaced by a weaker one that the divisor is effective, i.e. p A ≥ 0. In particular, as we will see in the next section, for 1 2 -BPS states in N = 4 the corresponding divisor is never ample. As a result, the rank can be less than b 2 + 2b 1 and the weight (3.29) starts depending on the choice of the magnetic charge vector p A . If the rank is not maximal, the quadratic form is not invertible so that we should clarify the meaning of the expressions involving its inverse, like the one for the invariant charge (3.6). It turns out that in this case the electric charge lattice is reduced: the charges associated with the degenerate directions of the quadratic form get frozen. More precisely, if {λ A s } is the set of eigenvectors of κ AB with zero eigenvalue, i.e. κ AB λ B s = 0, then the charges must satisfy In fact, it is easy to see that this condition is necessary for theta series to converge. Moreover, it was noticed to hold in the case of non-compact CYs [11], and in appendix C we show that it also follows from the attractor equations. As a result, the relevant charge lattice which one sums over in theta series is After the reduction to Λ p the quadratic form becomes non-degenerate and hence invertible. It is convenient to introduce the embedding of its inverse into R b 2 +2b 1 which we denote by κ AB . It can be defined by the following conditions: i) rank(κ AB ) = rank(κ AB ), ii) where e st is the inverse of e st = λ A s λ t,A . Then a proper generalization from the N = 2 case involves a replacement κ ab q a q b → κ AB q A q B where the charges are supposed to satisfy (3.30).
Another new feature is that the signature of the quadratic form κ AB , even after the restriction to Λ p , is not necessarily Lorentzian, i.e. it can be (n + , n − ) with n + > 1. This fact drastically affects the construction of h ref p,µ because the naive extension of the formula from [11] to the larger lattice with the quadratic form κ AB would lead to a divergent expression. A way to cure this problem is to change the kernels of theta series like J ref n in (3.12). In this paper we do not provide explicit expressions for the new kernels and simply assume that they exist. The only additional assumption which will be used here is that, as soon as the quadratic form Q n has n − 1 negative eigenvalues, the kernels are given by those found in [11].
Summarizing, we formulate the following , the magnetic charges p A , p A i are all non-negative, the electric charges are decomposed as

The unrefined limit
Let us now show how the above conjecture can be used to extract modular properties of the generating functions of the unrefined BPS indices. The key fact is the relation (3.27). Applying it to (3.9), one can obtain a relation between the generating functions of refined and unrefined indices, generalizing (3.17) valid in the N = 2 case, where as usual K is determined by (3.19) andΩ is characterized by the holomorphic anomaly equation for its completion (if it is non-trivial), which should also be obtained as the limit y → 1 of (3.12). Before taking the limit, it is useful to rewrite this equation in a slightly different form where we simply substituted the definition of the generating functions on the r.h.s. and used the spectral flow invariance of the refined BPS indices. The reason for this rewriting is that the charges γ i that differ only by D0-brane charge q i,0 may correspond to states preserving different number of supersymmetries. If this is the case, the behavior of the corresponding indicesΩ(γ i , y) in the unrefined limit will be different and hence they will contribute differently to the anomaly equation in this limit. Now it is clear how to proceed: one should apply the derivative operator from (3.35) to both sides of (3.38) and take the unrefined limit. To this end, it is crucial to take into account that the coefficients (y − y −1 ) 1−n J ref n are assumed to be finite in the limit reducing to J n (3.14), while the refined BPS indices develop a zero of certain order. More precisely, in a theory with N extended supersymmetry they behave as ∼ z N −2 if the charge corresponds to a 1 2 -BPS state and for other BPS states they vanish even faster. Thus, to get a non-vanishing contribution, all powers of z must be canceled by the derivative operator. However, the number of derivatives satisfies with equality reached (for N > 2) only for n = 2 and r = N . This simple inequality immediately implies several important consequences: • The holomorphic anomaly equation can be non-trivial, and hence generating functions be mock modular, only for 1 N -BPS states.
• Only 1 2 -BPS states can contribute to the r.h.s. of the holomorphic anomaly equation.
• For N > 2 only the contribution of 1 2 -BPS states with n = 2 survives the unrefined limit.
Thus, for N > 2 the only non-trivial holomorphic anomaly equation takes the following form All other generating functions (3.35) must be vector valued modular forms with respect to the full SL(2, Z) duality group.
In the next section we verify these predictions for N = 4 against the known results explained in section 2 and extract a new result concerning modularity of 1 4 -BPS states with a non-trivial torsion.

Modularity of immortal dyons from refinement
Let us now apply the formalism of the previous section to the compactification of type II string theory on the CY threefold Y = K3 × T 2 which preserves N = 4 supersymmetry in four dimensions. This CY is characterized by the following data The most general charge vector which we consider takes the following form in the heterotic frame (c.f. (2.14)) For this charge, the T-duality invariants (2.6) are found to be where q 2 = η αβ q α q β and p 2 = η αβ p α p β , and one has p 3 = 6mp ♭ .
To proceed with the analysis, we need to further specify the charge vector so that it describes either a half-or a quarter-BPS state.

Half-BPS states
As was recalled in section 2, 1 2 -BPS states are distinguished by the condition that the vectors given by the first and second lines of the charge (4.3) are parallel. There are two possibilities to satisfy this condition.
First, if p ♭ > 0, then all charges in the second line must vanish. To simplify the analysis, we restrict ourselves to the case p ♭ = 1, which ensures the primitivity of the charge and will be enough for our purposes. Thus, we consider In this case the quadratic form κ AB = κ ABC p C is It is degenerate and has rank equal to 26. Note that the existence of a degenerate direction in the charge lattice implies the vanishing of q ♭ , consistently with the 1 2 -BPS condition. The non-degenerate part of the quadratic form is η αβ and it is unimodular. This fact implies that there is no the residual flux µ, and the generating function h Thus, the generating function can be explicitly written as and coincides with (2.8). Furthermore, the formula (3.37) and the analysis of the holomorphic anomaly done in the previous section imply that it is a modular form of weight w = 2 · 2 − 3 − 26/2 = −12, with a trivial multiplier system as can be checked from (B.2) specialized to p α = µ = 0. Since the space of cusp modular forms (i.e. those which have only positive Fourier coefficients) of weight 12 is one-dimensional and generated by η(τ ) 24 [3], it follows that h (4|2) p 0 (τ ) ∼ η(τ ) −24 , consistently with (2.9). Of course, the precise proportionality coefficient cannot be fixed from the analysis based only on modularity.
The second possibility to get a 1 2 -BPS state is to take p ♭ = 0 and other components in the two lines proportional to each other, i.e.
In this case the charge q 0 is not independent, but fixed in terms of other charges. This implies that it is impossible to construct a generating function as in (3.35). Nevertheless, as we now demonstrate, the formalism of the previous section works even in such trivial situation. For the charge (4.9), the quadratic form reads as It has rank equal to 2, which corresponds to 2 integers, q ♭ and ǫ, labelling independent electric charges in (4.9). Therefore, according to (3.37), the generating function corresponding to the magnetic charge (0, p α ) must be a modular form of weight w = 2 · 2 − 3 − 2/2 = 0, which implies that the generating function is a constant! On the other hand, what the fixation of q 0 really means is that, due to the 1 2 -BPS condition, in the generating function (3.35) only one term survives. To find this term, note that the matrix κ AB defined below (3.31) is given by Substituting it into (3.32) together with the constraints on q 0 and q α implied by (4.9), it is easy to show thatq 0 vanishes. Thus, consistently with the above conclusion based on modularity, the generating function reduces to a constant term.

Quarter-BPS states: holomorphic anomaly
The indices counting 1 4 -BPS states in N = 4 theory are moduli dependent due to the formation and decay of bound states across lines of marginal stability in the moduli space. However, being evaluated at the attractor point, they coincide with the indices counting only singlecentered black holes because of the absence of scaling solutions in this theory. Therefore, it is natural to expect that the indices Ω (4|4) p,µ (q 0 ) coincide with the ones captured by the function ψ F m , which appears in the decomposition (2.17) and also counts the immortal dyons. As was reviewed in section 2.2, ψ F m is a mock Jacobi form with the completion ψ F m satisfying the holomorphic anomaly equation (2.18). This nicely fits with the result of the previous section that the generating function h (4|4) p,µ is also mock modular. Below we demonstrate that the holomorphic anomaly equation (3.40) satisfied by its completion can be used to derive the equation (2.18) for ψ F m as well as its generalization for I(γ) > 1. To achieve this goal, let us make all ingredients of (3.40) explicit. We restrict our consideration to the charges (4.3) with p ♭ = 1 and p 2 > 0. The first condition, as in the previous subsection, guaranties the primitivity of the charge, while the second ensures the existence of a solution to the attractor equations. For such charge the quadratic form is non-degenerate and is given with its inverse by (4.12) This implies the following spectral flow decomposition of the electric charges Since | det κ AB | = p 2 = 2m, the residual flux µ takes 2m non-equivalent values which can be represented by µ ♭ = 0, . . . , 2m − 1 and vanishing µ α . Accepting this choice and substituting the decomposition into (4.4), one finds so that this T-duality invariant changes under spectral flow by 2m. According to (3.40), the non-vanishing contributions to the anomaly equation arise only from splits of the charge γ = γ 1 + γ 2 where γ 1 and γ 2 are both 1 2 -BPS charges. It is easy to see that this is possible only if one of them belongs to the class (4.5) and the other to (4.9). Thus, the charges are restricted to satisfy Here we took into account that d Q defined in (4.9) coincides with the torsion invariant I(γ) (2.7) of the full charge, which due to (4.14) can also be written as The constraint (4.15) fixes all charges of the constituents in terms of the full charge and one parameter ǫ. This means that the lattice one sums over on the r.h.s. of the anomaly equation is one-dimensional! It is immediate to check that the quadratic form (3.34) depends on the free parameter as Q 2 = − 2m I(γ) 2 ǫ 2 + O(ǫ) and thus has signature (0, 1). As a result, according to our assumption, the function J 2 can be replaced by the simple exponential function (3.15) found in [11]. Taking into account that (pp 1 p 2 ) = 2m, where we used (4.14) with ǫ ♭ = 0, and parametrizing the residue flux as µ(ℓ) = (m−ℓ, 0, . . . , 0), the anomaly equation (3.40) takes the following explicit form 11 (4.18) 11 Note the factor of 2 coming from the symmetry γ 1 ↔ γ 2 .
As follows from (4.8), the first sum gives the factor η(τ ) −24 . To deal with the second sum, we decompose it into two sums by representing ǫ = s−I(γ)r where r ∈ Z and s = 0, . . . , I(γ)−1. Then we note that by a duality transformation the charge γ 2 can be brought to the form γ ′ 2 = 0, 0, 0 ds I(γ) (2m − ℓ), 0, ds I(γ) η αβ p β , d s = gcd(s, I(γ)) . (4.19) In this form the charge has only one non-vanishing T-duality invariant m ′ = d 2 s I(γ) 2 m. As a result, the invariance under U-duality and the relation (3.36) allow to express the BPS index Ω (4|2) (γ 2 ) in terms of the coefficients of (4.8) (4.20) Finally, the sum over r can be evaluated explicitly giving rise to the theta function (2.19) at z = 0. Thus, the holomorphic anomaly equation becomes (4.21) To bring the resulting equation to the same form as (2.18), one needs to construct a Jacobi form out of the modular vector. Comparing the modular transformations of h (4|4) p,µ(ℓ) and the theta series θ m,ℓ (τ, z), one observes that their multiplier systems, (B.3) and (B.4), cancel each other up to a factor produced by (−1) ℓ . In other words, the following function transforms as a mock Jacobi form where we expressed the invariant charge in terms of duality invariantŝ and took into account thatq max 0 = m 4 + 1. Given that the modular weight of h (4|4) p,µ , as follows from (3.37), is equal to w = 2 · 3 − 3 − 27/2 = − 21 2 , the function (4.22) has weight −10 and index m, which perfectly agrees with the properties of the function ψ F m defined in section 2.2. Thus, we expect that in the case I(γ) = 1 these two functions can be identified. Furthermore, setting I(γ) = 1 in (4.21) and rewriting it in terms of ψ p , it is immediate to see that one recovers the holomorphic anomaly equation (2.18).
It is important to note that, as can be seen from (4.16), the torsion invariant depends on ℓ, the variable one sums over in the definition (4.22). Therefore, setting I(γ) = 1, we assume that this constraint holds for all ℓ = −m, . . . , m − 1. This is equivalent to the simpler condition that d p ≡ gcd{p α } = 1. Once this condition holds, the anomaly equation (4.21) reduces to the well known equation (2.18).
On the other hand, if we do not impose the condition d p = 1 in (4.21), it provides a generalization of the anomaly equation which includes contributions of charges with a nontrivial torsion. In the rest of this section we derive a simplified form of the resulting anomaly equation and show its consistency with the formula (2.13).
To this end, we rewrite (4.21) in terms of ψ p and perform some manipulations with the finite sums. First, we note that d ′ = I(γ)d/d s divides both d p and ℓ, while I(γ)/d ′ = d s /d divides s. This allows to trade the sum over d for the sum over d ′ and exchange the order of summation so that this sum appears the first. By changing the variables as ℓ = d ′ k and s = I(ℓ) d ′ c, one obtains Next, we manipulate with the sum of theta series as follows (we drop the prime on d to avoid cluttering) where at the second step we decomposed k = ℓ + 2ms d 2 . As a result, the anomaly (4.24) for d p > 1 can be expressed through the anomaly for d p = 1: using the function A m (τ, z) defined in (2.18) as the r.h.s. of the holomorphic anomaly equation for trivial torsion, the general anomaly equation takes the form where I is given by (4.16), and substituting (2.13), the mock Jacobi form (4.22) can be rewritten as ψ p (τ, z) = n≥−1 ℓ∈Z d|(ℓ,dp) d Ω (4.28) It is clear that this result implies the holomorphic anomaly equation for ψ p which coincides with the one in (4.26) derived from the formalism based on the refinement. It is worth emphasizing that the function ψ p for d p > 1 comprises contributions of charges with different values of the torsion invariant: the sum over ℓ allows us to get all I dividing d p . In this sense ψ p is very different from the function obtained by expanding the generating function Z (4|4) I with a fixed torsion. This difference is the reason why the former is a mock Jacobi form for the full SL(2, Z) group, whereas the latter transforms properly only under the congruence subgroup Γ 0 (I). This is a generic feature of our construction in that it automatically produces functions which transform as (mock) modular or Jacobi forms under the full SL(2, Z). It tells us how charges with different torsion should be combined together in order to form objects with nice modular properties. In particular, we expect that generalizing our results for p ♭ > 1, even more sophisticated combinations of BPS indices can be turned into SL(2, Z) modular functions.

Discussion
In this paper we established a relation between the results encoding modular properties of the generating functions of D4-D2-D0 black holes in N = 2 string compactifications, and their refined version, with the corresponding results in compactifications with N > 2 extended supersymmetry. Key to this relation is the observation that the refined BPS index Ω(γ, y) coincides with a properly normalized helicity generating function, so that all BPS indices Ω (N |r) (γ) counting 1 r -BPS states in a theory with N supersymmetries can be obtained from Ω(γ, y) by taking an appropriate number of derivatives with respect to the refinement parameter y and consequently setting it to y = 1 (see (3.27)). This allows to extract information about the modular properties of generating functions of Ω (N |r) (γ) from the corresponding generating functions of Ω(γ, y) by providing a direct link between them, and also between the holomorphic anomaly equations satisfied by their completions. In particular, assuming the holomorphic anomaly equation for h ref p,µ (τ, z) to have a universal form independent of the number N of extended supersymmetries, one finds easily that in an N > 2 theory the unrefined limit of the holomorphic anomaly can be non-trivial only for r = N , in which case it receives contributions only from two 1 2 -BPS states. Next, we tested the predictions of this refined construction approach against known results on counting BPS states in N = 4 string theory on K3 × T 2 , and found perfect agreement for both half-and quarter-BPS states. More precisely, the generating function for half-BPS states was shown to be uniquely determined by the modular properties predicted for it by the refined counting, whereas for quarter-BPS states this approach accurately reproduced the holomorphic anomaly equation of [3] satisfied by the completion of the generating function of immortal dyons. Finally, we also derived a generalization (4.26) of this equation which comprises contributions of BPS dyons with non-trivial torsion I(γ) > 1 and demonstrated its consistency with the formula of [29] expressing Ω (4|4) I through the degeneracies for I = 1. In order to appreciate the difference between BPS state counting in N = 2 and N > 2 theories, it useful to recall that for the latter there exists a description of BPS degeneracies via generating functions that transform as modular objects under the U-duality group of the theory. Furthermore, mock modularity arises when one restricts oneself to counting only a specific class of BPS states such as single centred or immortal black holes. There is no analogous description in the N = 2 case. The generating functions obtained in our approach are not invariant under the full U-duality group, as can be seen from the fact that they require vanishing of the D6-brane charge. Instead, they preserve only a subgroup of the T-duality group and transform generically as mock modular forms under SL(2, Z). This is where our approach comes into its own. Due to its universality, it naturally produces generating functions which turn out to be modular or mock modular with respect to the full SL(2, Z) group, irrespective of the number N of supersymmetries. In contrast, the naive extension of the counting of 1 4 -BPS states to non-trivial torsion I > 1, based on duality invariant generating functions, leads to modular forms under a smaller congruence group Γ 0 (I) [29]. The modularity under SL(2, Z) is achieved due to a clever combination of contributions with different torsion. It is the formalism explained above that ensures the right combination, which otherwise would have been difficult to arrive at by plain guesswork.
There are natural avenues for extending the results reported here. Firstly, in the N = 4 case we imposed a restriction on the charge counting D4-branes wrapped on K3, p ♭ ≤ 1. Although this is enough to reproduce the known counting functions, it would be interesting to relax this restriction. One may expect that the generating functions with p ♭ > 1 provide new examples of non-trivial modular combinations of BPS indices, which might even lead to new interesting mathematical constructions of (vector valued) modular forms.
Secondly, this approach should be tested in other cases where there are known results on counting BPS states. One such possibility is to consider the CHL orbifolds. Another option is given by compactification of type II string theory on T 6 leading to N = 8 supersymmetry, where a plethora of rigorous results (see e.g. [45,46,47,48]) furnishes a rich test-ground for the predictions of our approach.
Finally, we have left an important gap in our construction. Namely, due to the nonstandard signature of the quadratic form κ AB appearing in compactifications with N > 2 extended supersymmetry, we did not determine the explicit form of the functions J ref n entering the holomorphic anomaly equation in the refined case. This explicit form is not required to get the unrefined limit for N = 4, and it is likely that the same is still true for N = 8. However, this gap should be filled in order, in particular, to confirm a few mild assumptions we made about J ref n . This problem also represents an interesting mathematical challenge with the promise of generating new insights into the theory of indefinite theta series, to which string theory has already made important contributions.
where µ · ν = κ AB µ A ν B is determined by the quadratic form of the non-degenerate part of the lattice of electric charges, which can be defined as Λ = {ǫ A ∈ Z : λ A s ǫ A = 0}. In the N = 2 case, Λ = H 4 (Y, Z) and the quadratic form coincides with κ ab .

C. Attractor equations and electric charges
In this appendix we analyze the attractor equations in the large volume limit and will be particularly interested in the case where the quadratic form defined by the classical part of the prepotential is degenerate. The attractor equations are the equations of motion of the low-energy effective action restricted to BPS black hole near-horizon backgrounds [51]. They allow to fix the values of scalar fields at the black hole horizon in terms of charges and can easily be formulated in terms of the prepotential F (X) as Im X I = p I , Im ∂ X I F = q I . (C.1) The full quantum prepotential can be formally written in a perturbative worldsheet genus expansion with order g term captured in terms of a genus-g topological string amplitude where g top = 1/X 0 and z A = X A /X 0 . In the large volume limit t A = Im z A ≫ 1, the leading term in the prepotential is holomorphic and has a universal form where the exponentially suppressed contributions correspond to worldsheet instantons. Sometimes, the prepotential also contains contributions quadratic and linear in z A , but they can be removed by a symplectic transformation (see footnote 8). In contrast, the first subleading term F 1 satisfies a holomorphic anomaly equation. Its solution can be found explicitly and in the large volume limit it asymptotes to a linear term (see e.g. [52]) where a A are real and depend on the second Chern class of the underlying CY. The higher F g are exponentially suppressed in t A and so are their derivatives with respect to z A . Due to this, the generic prepotential in the large volume limit reduces to Let us now turn to the attractor equations. To ensure the large volume limit, we choose the electro-magnetic charge to be where we set D6-brane charge to zero, as everywhere in the paper, and take the parameter λ to be large. In the case of degenerate κ AB = κ ABC p C , the inverse κ AB is defined as below (3.31). The first attractor equation in (C.1) is solved by Substituting this solution into the second set of equations, one finds As a result, the attractor equations are solved by (C.10) In particular, for p 3 > 0, X 0 ∼ const and one reproduces the large volume attractor point (3.4) for the moduli z A = X A /X 0 up to a redefinition of the scaling parameter and replacement κ ab → κ AB . On the other hand, if p 3 = 0, while the solution is still non-degenerate due to taking into account the one-loop correction a A , the scaling is different leading to X 0 ∼ λ −1 . However, the solution for the moduli z A is still consistent with (3.4) upon redefinition λ 2 → λ. 12 Most importantly, the attractor equation (C.8) shows that if the quadratic form κ AB is degenerate, a solution exists only if the electric charges satisfy certain constraints. Namely, if λ A s is a set of vectors such that κ AB λ B s = 0, then the existence of solution requires λ A s q A = 0. (C.11) If this is the case, eq. (C.10) with κ AB defined as below (3.31) provides the corresponding solution.