1 Introduction and Summary

The degeneracies of BPS black holes in string vacua with extended supersymmetry possess remarkable modular properties, which have been instrumental in recent progress on explaining the statistical origin of the Bekenstein-Hawking entropy in [1] and many subsequent works. Namely, the indices \(\Omega (\gamma )\) counting—with sign—microstates of BPS black holes with electromagnetic charge \(\gamma \) may often be collected into a suitable generating function which exhibits modular invariance, providing powerful constraints on its Fourier coefficients and enabling direct access to their asymptotic growth. When the black holes can be realized as black strings wrapped on a circle, a natural candidate for such a generating function is the elliptic genus of the superconformal field theory supported by the black string, which is modular invariant by construction [2,3,4]. Equivalently, one may consider the partition function of the effective three-dimensional gravity living on the near-horizon geometry of the black string [5].

In most cases however, the BPS indices depend not only on the charge \(\gamma \) but also on the moduli \(z^a\) at spatial infinity, due to the wall-crossing phenomenon: some of the BPS bound states with total charge \(\gamma \) only exist in a certain chamber in moduli space, and decay as the moduli are varied across ‘walls of marginal stability’ which delimit this chamber. At strong coupling where the black hole description is accurate, this phenomenon has a transparent interpretation in terms of the (dis)appearance of multi-centered black hole configurations, which can be used to derive a universal wall-crossing formula [6,7,8,9].

In the case of four-dimensional string vacua with \({\mathcal {N}}=4\) supersymmetry, where the BPS index is sensitive only to single-centered 1/4-BPS black holes and to bound states of two 1/2-BPS black holes, the resulting moduli dependence is reflected in poles in the generating function, requiring a suitable choice of contour for extracting the Fourier coefficients in a given chamber [10,11,12]. Upon subtracting contributions of two-centered bound states, the generating function of single-centered indices is no longer modular in the usual sense but it transforms as a mock Jacobi form with specific ‘shadow’—a property which is almost as constraining as standard modular invariance [13].

In four-dimensional string vacua with \({\mathcal {N}}=2\) supersymmetry, the situation is much more complicated, firstly due to the fact that the moduli space of scalars receives quantum corrections, and secondly due to BPS bound states potentially involving an arbitrary number of constituents, resulting in an extremely intricate pattern of walls of marginal stability. Thus, it does not seem plausible that a single generating function may capture the BPS indices \(\Omega (\gamma ,z^a)\)—which are known in this context as generalized Donaldson-Thomas (DT) invariants—in all chambers. Nevertheless, modular invariance is still expected to constrain them. In particular, D4–D2–D0 black holes in type IIA string theory compactified on a generic compact Calabi–Yau (CY) threefold \({\mathfrak {Y}}\) can be lifted to an M5-brane wrapped on a divisor \({\mathcal {D}}\subset {\mathfrak {Y}}\) [2]. If the divisor \({\mathcal {D}}\) labelled by the D4-brane charge \(p^a\) is irreducible, the indices \(\Omega (\gamma ,z^a)\) are independent of the moduli of \({\mathfrak {Y}}\), at least in the limit where the volume of \({\mathfrak {Y}}\) is scaled to infinity, and their generating function is known to be a holomorphic (vector valued) modular form of weight \(-{1\over 2}\, b_2({\mathfrak {Y}})-1\) [3, 4, 6, 14]. This includes the case of vertical, rank 1 D4–D2–D0 branes in K3-fibered Calabi–Yau threefolds [15,16,17]. But if the divisor \({\mathcal {D}}\) is a sum of n effective divisors \({\mathcal {D}}_i\), the indices \(\Omega (\gamma ,z^a)\) do depend on the Kähler moduli \(z^a\), even in the large volume limit. In general however, the black string SCFT is supposed to capture the states associated to a single \(AdS_3\) throat, while for generic values of the moduli multiple \(AdS_3\) throats can contribute [18, 19]. It is thus natural to consider the modular properties of the DT invariants \(\Omega (\gamma ,z^a)\) at the large volume attractor pointFootnote 1

$$\begin{aligned} z^a_\infty (\gamma )= \lim _{\lambda \rightarrow +\infty }\left( -q^a+\mathrm {i}\lambda p^a\right) , \end{aligned}$$
(1.1)

where only a single \(AdS_3\) throat is allowed [20]. Following [21] we denote these invariants by \(\Omega ^{\mathrm{MSW}}(\gamma )=\Omega (\gamma ,z^a_\infty (\gamma ))\) and call them Maldacena-Strominger-Witten (MSW) invariants. As we discuss in Section 2, the DT invariants \(\Omega (\gamma ,z^a)\) can be recovered from the MSW invariants \(\Omega ^{\mathrm{MSW}}(\gamma )\) by using a version of the split attractor flow conjecture [6, 22] developed in [23], which we call the flow tree formula.

The case where \({\mathcal {D}}\) is the sum of two irreducible divisors was first considered in [20, 24, 25], and studied more recently in [14, 26]. In that case, the generating function of MSW invariants turns out to be a mock modular form, with a specific non-holomorphic completion obtained by smoothing out the sign functions entering in the bound state contributions, recovering the prescription of [20, 27]. The goal of this paper is to extend this result to the general case where \({\mathcal {D}}\) is the sum of n irreducible divisors \({\mathcal {D}}_i\), where n can be arbitrarily large. In such generic situation, we characterize the modular properties of the generating function \(h_{p,\mu }\) of MSW invariants and find an explicit expression for its non-holomorphic completion \(\widehat{h}_{p,\mu }\) in terms of the generating functions \(h_{p_i,\mu _i}\) associated to the n constituents, multiplied by certain iterated integrals introduced in [28, 29] which generalize the usual error function appearing when \(n=2\).Footnote 2 This result implies that in this case \(h_{p,\mu }\) is a (mixed, vector valued) mock modular form of depth \(n-1\), in the sense that the antiholomorphic derivative of its modular completion is itself a linear combination of modular completions of mock modular forms of lower depth, times antiholomorphic modular forms (with the depth 1 case reducing to the standard mock modular forms introduced in [27, 35], and the depth 0 case to usual weakly holomorphic modular forms; see [36, (3.16)] for a more precise definition).

In order to establish this result, we follow the same strategy as in our earlier works [14, 26] and analyze D3–D1–D(-1) instanton corrections to the metric on the hypermultiplet moduli space \({\mathcal {M}}_H\) in type IIB string theory compactified on \({\mathfrak {Y}}\), at arbitrary order in the instanton expansion. After reducing on a circle and T-dualizing, this moduli space is identical to the vector multiplet moduli space in type IIA string theory compactified on \({\mathfrak {Y}}\times S_1\), where it receives instanton corrections from D4–D2–D0 black holes winding around the circle. In either case, each instanton contribution is weighted by the same generalized DT invariant \(\Omega (\gamma )\) which counts the number of BPS black hole microstates with electromagnetic charge \(\gamma \). The modular properties of the generalized DT invariants are fixed by requiring that the quaternion-Kähler (QK) metric on \({\mathcal {M}}_H\) admits an isometric action of \(SL(2,\mathbb {Z})\), which comes from S-duality in type IIB, or equivalently from large diffeomorphisms of the torus appearing when viewing type IIA/\({\mathfrak {Y}}\times S_1\) as M-theory on \({\mathfrak {Y}}\times T^2\) [37]. This QK metric is most efficiently encoded in the complex contact structure on the associated twistor space, a \(\mathbb {C}P^1\)-bundle over \({\mathcal {M}}_H\) [38, 39]. The latter is specified by a set of gluing conditions determined by the DT invariants [37, 40], which can in turn be expressed in terms of the MSW invariants using the tree flow formula.

An important quantity appearing in this twistorial formulationFootnote 3 is the so called contact potential\(e^\phi \), a real function on \({\mathcal {M}}_H\) related to the Kähler potential on the twistor space, and afforded by the existence of a continuous isometry unbroken by D-instantons. On the type IIB side, \(e^\phi \) can be identified with the four-dimensional dilaton \(1/g_4^2\). When expressed in terms of the ten-dimensional axio-dilaton \(\tau =c_0+\mathrm {i}/g_s\) (or in terms of the modulus of the 2-torus on the M-theory side), it becomes a complicated function having a classical contribution, a one-loop correction, and a series of instanton corrections expressed as contour integrals on the \(\mathbb {C}P^1\) fiber. The importance of the contact potential stems from the fact that it must be a non-holomorphic modular form of weight \((-\frac{1}{2},-\frac{1}{2})\) in the variable \(\tau \) in order for \({\mathcal {M}}_H\) to admit an isometric action of \(SL(2,\mathbb {Z})\) [37]. This requirement imposes very non-trivial constraints on the instanton contributions to \(e^\phi \), which can be used to deduce the modular properties of generating functions of DT invariants, at each order in the instanton expansion. This strategy was used in [14] at two-instanton order to characterize the modular behavior of the generating function of MSW invariants in the case of a divisor equal to the sum of \(n=2\) irreducible divisors. In this paper we generalize this result to all n, by analyzing the instanton expansion to all orders. Below we summarize the main steps in our analysis and our main results.

  1. 1.

    First, we show that the contact potential \(e^\phi \) in the large volume limit, where the Kähler parameters of the CY are sent to infinity, can be expressed (see (3.24)) through another (complex valued) function \({\mathcal {G}}\) (3.22) on the moduli space, which we call the instanton generating function. The expansion of \({\mathcal {G}}\) in powers of DT invariants is governed by a sum over unrooted trees decorated by charges \(\gamma _i\) (see (3.25) and (3.26)). The modularity of the contact potential requires \({\mathcal {G}}\) to transform as a modular form of weight \((-\tfrac{3}{2},\tfrac{1}{2})\).

  2. 2.

    After expressing the DT invariants \(\Omega (\gamma ,z^a)\) through the moduli independent MSW invariants \(\Omega ^{\mathrm{MSW}}(\gamma )\) using the tree flow formula of [23], and expanding \({\mathcal {G}}\) in powers of \(\Omega ^{\mathrm{MSW}}(\gamma )\), each order in this expansion can be decomposed into a sum of products of certain indefinite theta series and of holomorphic generating functions \(h_{p_i,\mu _i}\) of the invariants \(\Omega ^{\mathrm{MSW}}(\gamma )\) (see (4.2)), similarly to the usual decomposition of standard Jacobi forms. Thus, the modular properties of the indefinite theta series \(\vartheta _{{{\varvec{p}}},{\varvec{\mu }}}\bigl (\Phi ^{\mathrm{tot}}_{n},n-2\bigr )\) are tied with the modular properties of the generating functions \(h_{p_i,\mu _i}\), in order for \({\mathcal {G}}\) to be modular.

  3. 3.

    In order for an indefinite theta series \(\vartheta _{{{\varvec{p}}},{\varvec{\mu }}}\bigl (\Phi ,\lambda )\) to be modular, its kernel \(\Phi \) must satisfy a certain differential equation (D.3), which we call Vignéras’ equation [43]. By construction, the kernels \(\Phi ^\mathrm{tot}_n\) appearing in our problem are given by iterated contour integrals along the \(\mathbb {C}P^1\) fiber of the twistor space, multiplied by so-called ‘tree indices’ \(g_{\mathrm{tr},n}\) coming from the expression of \(\Omega (\gamma ,z^a)\) in terms of \(\Omega ^{\mathrm{MSW}}(\gamma )\). We evaluate the twistorial integrals in terms of the generalized error functions introduced in [28, 29], and show that the resulting kernels satisfy Vignéras’ equation away from certain loci where they have discontinuities. Furthermore, we prove that the discontinuities corresponding to walls of marginal stability cancel between the integrals and the tree indices. But there are additional discontinuities coming from certain moduli independent contributions to the tree index. They spoil Vignéras’ equation at the multi-instanton level so that the theta series \(\vartheta _{{{\varvec{p}}},{\varvec{\mu }}}\bigl (\Phi ^{\mathrm{tot}}_{n},n-2\bigr )\) are not modular. In turn, this implies that the holomorphic generating functions \(h_{p_i,\mu _i}\) are not modular either.

  4. 4.

    However, we show that one can complete \(h_{p,\mu }\) into a non-holomorphic modular form \({\widehat{h}}_{p,\mu }(\tau )\), by adding to it a series of corrections proportional to products of \(h_{p_i,\mu _i}\) with the same total D4-brane charge \(p=\sum _i p_i\) (see (5.1)). The non-holomorphic functions \(R_n\) entering the completion are determined by the condition that the expansion of \({\mathcal {G}}\) rewritten in terms of \({\widehat{h}}_{p,\mu }\) gives rise to a non-anomalous, modular theta series. Equivalently, one can work with functions \({\widehat{g}}_n\) appearing in the expansion (5.2) of the holomorphic generating function of DT invariants \(h^\mathrm{DT}_{p,q}\) in powers of the non-holomorphic functions \({\widehat{h}}_{p_i,\mu _i}\).

  5. 5.

    Imposing the conditions for modularity, we find that \({\widehat{g}}_n\) can be represented in an iterative form (5.9), or more explicitly as a sum (5.33) over rooted trees with valency \(\ge 3\) at each vertex (known as Schröder trees), where \(g^{(0)}_n\) are certain locally polynomial functions defined in (5.27), while \({\mathcal {E}}_n\) are smooth solutions of Vignéras’ equation constructed in terms of generalized error functions. The functions \(R_n\) are similarly given by a sum over Schröder trees (5.34) in terms of exponentially decreasing and non-decreasing parts of \({\mathcal {E}}_n\). These equations represent the main technical result of this work.

  6. 6.

    For \(n\le 5\) our general formulas can be drastically simplified. In particular, the main building blocks, the functions \(g^{(0)}_n\) and \({\mathcal {E}}_n\), can be written as a sum over a suitable subset of flow trees, as in (5.42). In addition, we show that \(g^{(0)}_n\) has a natural extension including the refinement parameter conjugate to the spin \(J_3\) of the black hole.

Fig. 1
figure 1

Various types of trees arising in this work. \(\mathbb {T}_{n,m}\) denotes the set of unrooted trees with n vertices and m marks distributed between the vertices. \(\mathbb {T}_n\!\equiv \mathbb {T}_{n,0}\) comprises the trees without marks. \(\mathbb {T}_n^{\mathrm{r}}\) is the set of rooted trees with n vertices. \(\mathbb {T}_n^{\mathrm{af}}\) is the set of attractor flow trees with n leaves (of which we only draw the different topologies). \(\mathbb {T}_n^{\mathrm{S}}\) denotes the set of Schröder trees with n leaves. In addition, an important rôle is played by the sets \(\mathbb {T}_{n,m}^\ell \) and \(\mathbb {T}_n^\ell =\mathbb {T}_{n,0}^\ell \) of unrooted, labelled, marked trees which are obtained from \(\mathbb {T}_{n,m}\) and \(\mathbb {T}_{n}\) by assigning different labels and markings to the vertices in such way that a vertex with \(m_{\mathfrak {v}}\) marks is decorated by \(2m_{\mathfrak {v}}+1\) labels

At the end of this lengthy analysis, we thus find a modular completion of the generating functions \(h_{p,\mu }\) of MSW invariants for an arbitrary divisor, i.e. decomposable into a sum of any number of irreducible divisors. The result is expressed through sums of products of generalized error functions labelled by trees of various types. For the reader’s convenience, in Fig. 1 we display the various trees which appear in our construction, up to \(n=4\). Since generalized error functions are known to be related to iterated Eichler integrals [14, 44], which occur in the non-holomorphic completion of mock modular forms, we loosely refer to the generating functions of MSW invariants as higher depth mock modular forms, although we do not spell out the precise meaning of this notion.

An unexpected byproduct of our analysis is an interesting combinatorial identity, relating rooted trees to the binomial coefficients, which plays a rôle in our derivation of the modular completion. Since we are not aware of such an identity in the mathematical literature,Footnote 4 we state it here as a theorem whose proof can be found in appendix A.

Theorem 1

Let \(V_T\) be the set of vertices of a rooted ordered tree T and \(n_v(T)\) is the number of descendants of vertex v inside T plus 1 (alternatively, the number of vertices of the subtree in T with the root being the vertex v and the leaves being the leaves of T). Then for a rooted tree T with n vertices and \(m<n\) one has

$$\begin{aligned} \sum _{T'\subset T}\prod _{v\in V_{T'}}\frac{n_v(T)}{n_v(T')}=\frac{n!}{m!(n-m)!}\, , \end{aligned}$$
(1.2)

where the sum goes over all subtrees with m vertices, having the same root as T (see Fig. 2).

The organization of the paper is as follows. In Sect. 2 we review known results about DT invariants, their expression in terms of MSW invariants, and specialize them to the case of D4–D2–D0 black holes in type IIA string theory on a Calabi–Yau threefold. In Sect. 3 we present the twistorial description of the D-instanton corrected hypermultiplet moduli space in the dual type IIB string theory, evaluate the contact potential in the large volume approximation by expressing it through a function \({\mathcal {G}}\), and obtain the instanton expansion for this function via unrooted labelled trees. In Sect. 4 we obtain a theta series decomposition for each order of the expansion of \({\mathcal {G}}\) in MSW invariants and analyze the modular anomaly of the resulting theta series, implying a modular anomaly for the generating functions \(h_{p,\mu }\). In Sect. 5 we construct the non-holomorphic completion \({\widehat{h}}_{p,\mu }\), for which the anomaly is cancelled, and determine its explicit form. Section 6 is devoted to discussion of the obtained results. Finally, several appendices contain details of our calculations and proofs of various propositions. In addition, in appendix G we present explicit results up to order \(n=4\), and in appendix H, as an aid to the reader, we provide an index of notations.

Fig. 2
figure 2

An example illustrating the statement of the Theorem for a tree with \(n=7\) vertices and subtrees with \(m=3\) vertices. The subtrees are distinguished by red color. Near each vertex of the subtrees we indicated the pair of numbers \((n_v(T),n_v(T'))\)

2 BPS Indices and Wall-Crossing

In this section, we review some aspects of BPS indices in theories with \({\mathcal {N}}=2\) supersymmetry, including the tree flow formula relating the moduli-dependent index \(\Omega (\gamma ,z^a)\) to the attractor index \(\Omega _\star (\gamma )\). We then apply this formalism in the context of Calabi–Yau string vacua, and express the generalized DT invariants \(\Omega (\gamma ,z^a)\) in terms of their counterparts evaluated at the large volume attractor point (1.1), known as MSW invariants.

2.1 Wall-crossing and attractor flows

The BPS index \(\Omega (\gamma ,z^a)\) counts (with sign) micro-states of BPS black holes with total electro-magnetic charge \(\gamma =(p^\Lambda ,q_\Lambda )\), for a given value \(z^a\) of the moduli at spatial infinity. While \(\Omega (\gamma ,z^a)\) is a locally constant function over the moduli space, it can jump across real codimension one loci where certain bound states, represented by multi-centered black hole solutions of \(N=2\) supergravity, become unstable. The positions of these loci, known as walls of marginal stability, are determined by the central charge \(Z_\gamma (z^a)\), a complex-valued linear function of \(\gamma \) whose modulus gives the mass of a BPS state of charge \(\gamma \), while the phase determines the supersymmetry subalgebra preserved by the state. Since a bound state can only decay when its mass becomes equal to the sum of masses of its constituents, it is apparent that the walls correspond to hypersurfaces where the phases of two central charges, say \(Z_{\gamma _L}(z^a)\) and \(Z_{\gamma _R}(z^a)\), become aligned. The bound states which may become unstable are then those whose constituents have charges in the positive cone spanned by \(\gamma _L\) and \(\gamma _R\). We shall assume that the charges \(\gamma _L,\gamma _R\) have non-zero Dirac-Schwinger-Zwanziger (DSZ) pairing \(\langle \gamma _L,\gamma _R\rangle \ne 0\), since otherwise marginal bound states may form, whose stability is hard to control.

The general relation between the values of \(\Omega (\gamma ,z^a)\) on the two sides of a wall has been found in the mathematics literature by Kontsevich–Soibelman [46] and Joyce–Song [47, 48], and justified physically in a series of works [6,7,8,9]. However, in this work we require a somewhat different result: an expression of \(\Omega (\gamma ,z^a)\) in terms of moduli-independent indices. One such representation, known as the Coulomb branch formula, was developed in a series of papers [49,50,51] (see [52] for a review) where the moduli-independent index is the so-called ‘single-centered invariant’ counting single-centered, spherically symmetric BPS black holes. Unfortunately, this representation (and its inverse) is quite involved, as it requires disentangling genuine single-centered solutions from so-called scaling solutions, i.e. multi-centered solutions with \(n\ge 3\) constituents which can become arbitrarily close to each other [6, 53].

A simpler alternative is to consider the attractor index, i.e. the value of the BPS index in the attractor chamber \(\Omega _*(\gamma )\equiv \Omega (\gamma ,z^a_\star (\gamma ))\), where \(z^a_\star (\gamma )\) is fixed in terms of the charge \(\gamma \) via the attractor mechanism [54] (recall that for a spherically symmetric BPS black hole with charge \(\gamma \), the scalars in the vector multiplets have fixed value \(z^a_\star (\gamma )\) at the horizon independently of their value \(z^a\) at spatial infinity.). By definition, the attractor indices are of course moduli independent. The problem of expressing \(\Omega (\gamma ,z^a)\) in terms of attractor indices was addressed recently in [23], extending earlier work in [20, 55]. Relying on the split attractor flow conjecture [6, 22], it was argued that the rational BPS index

$$\begin{aligned} {\bar{\Omega }}(\gamma ,z^a) = \sum _{d|\gamma } \frac{1}{d^2}\, \Omega (\gamma /d,z^a) \end{aligned}$$
(2.1)

can be expanded in powers of \({\bar{\Omega }}_*(\gamma _i)\),

$$\begin{aligned} {\bar{\Omega }}(\gamma ,z^a) = \sum _{\sum _{i=1}^n \gamma _i=\gamma } g_{\mathrm{tr},n}(\{\gamma _i\},z^a)\, \prod _{i=1}^n {\bar{\Omega }}_*(\gamma _i), \end{aligned}$$
(2.2)

where the sum runs over orderedFootnote 5 decompositions of \(\gamma \) into sums of vectors \(\gamma _i\in \Gamma _+\), with \(\Gamma _+\) being the set of all vectors \(\gamma \) whose central charge \(Z_\gamma (z^a_\infty )\) lies in a fixed half-space defining the splitting between BPS particles (\(\gamma \in \Gamma _+\)) and anti-BPS particles (\(\gamma \in - \Gamma _+\)). Such decompositions correspond to contributions of multi-centered black hole solutions with constituents carrying charges \(\gamma _i\).

The coefficient \(g_{\mathrm{tr},n}\), called the tree index, is defined as

$$\begin{aligned} g_{\mathrm{tr},n}(\{\gamma _i\},z^a)= \frac{1}{n!} \sum _{T\in \mathbb {T}_n^\mathrm{af}}\Delta (T)\, \kappa (T) , \end{aligned}$$
(2.3)

where the sum goes over the set \(\mathbb {T}_n^{\mathrm{af}}\) of attractor flow trees with n leaves. These are unordered rooted binary treesFootnote 6T with vertices decorated by electromagnetic charges \(\gamma _v\), such that the leaves of the tree carry the constituent charges \(\gamma _i\), and the charges propagate along the tree according to \(\gamma _v= \gamma _{L(v)}+\gamma _{R(v)}\) at each vertex, where \(L(v)\), \(R(v)\) are the two childrenFootnote 7 of the vertex v (see Fig. 3). The charge carried by the root of the tree is then the total charge \(\gamma =\sum \gamma _i\). The idea of the split attractor flow conjecture is that each tree represents a nested sequence of two-centered bound states describing a multi-centered solution built out of constituents with charges \(\gamma _i\). With this interpretation, the edges of the graph represent the evolution of the moduli under attractor flow, so that one starts from the moduli at spatial infinity \(z^a_\infty \equiv z^a\) and assigns to the root \(v_0\) the point in the moduli space \(z^a_{v_0}\) where the attractor flow with charge \(\gamma \) crosses the wall of marginal stability where \(\,\mathrm{Im}\,\bigl [Z_{\gamma _{L(v_0)}} {\bar{Z}}_{\gamma _{R(v_0)}}(z^a_{v_0})\bigr ]=0\). Then one repeats this procedure for every edge, obtaining a set of charges and moduli \((\gamma _v,z^a_v)\) assigned to each vertex, with the bound state constituents and their attractor moduli \((\gamma _i,z^a_{\gamma _i})\) assigned to the leaves.

Fig. 3
figure 3

An example of attractor flow tree corresponding to the bracketing ((13)(2(45)))

Given these data, the factor \(\Delta (T)\) in (2.3) is given by

$$\begin{aligned} \Delta (T)=\prod _{v\in V_T}\Delta _{\gamma _{L(v)}\gamma _{R(v)}}^{z_{p(v)}}, \quad \Delta _{\gamma _L\gamma _R}^z= {1\over 2}\,\Bigl [\mathrm{sgn}\,\,\mathrm{Im}\,\bigl [ Z_{\gamma _L}{\bar{Z}}_{\gamma _R}(z^a)\bigr ]+ \mathrm{sgn}(\gamma _{LR}) \Bigr ] ,~~ \end{aligned}$$
(2.4)

where \(V_T\) denotes the set of vertices of T excluding the leaves, p(v) is the parent of vertex v, and \(\gamma _{LR}=\langle \gamma _L,\gamma _R \rangle \). This factor vanishes unless the stability conditionFootnote 8

$$\begin{aligned} \gamma _{L(v)R(v)} \, \,\mathrm{Im}\,\bigl [ Z_{\gamma _{L(v)}}{\bar{Z}}_{\gamma _{R(v)}}(z^a_{p(v)})\bigr ]>0 \end{aligned}$$
(2.5)

is satisfied for all \(v\in V_T\), which ensures admissibility of the flow tree T, i.e. the existence of the corresponding nested bound state. Importantly, the sign of \(\,\mathrm{Im}\,\bigl [ Z_{\gamma _{L(v)}}{\bar{Z}}_{\gamma _{R(v)}}(z^a_{p(v)})\bigr ]\) entering (2.4) can be computed recursively in terms of asymptotic data, without evaluating the attractor flow along the edges [23]. More precisely, the signs depend only on the stability parameters (also known as Fayet-Iliopoulos parameters)

$$\begin{aligned} c_i(z^a) = \,\mathrm{Im}\,\bigl [ Z_{\gamma _i}{\bar{Z}}_\gamma (z^a)\bigr ]\, . \end{aligned}$$
(2.6)

Note that due to \(\gamma =\sum _{i=1}^n \gamma _i\), these parameters satisfy \(\sum _{i=1}^n c_i=0\). Accordingly, we shall often denote \(g_{\mathrm{tr},n}(\{\gamma _i\},z^a)\) by \(g_{\mathrm{tr},n}(\{\gamma _i,c_i\})\), and always assume that \(\{c_i\}\) are generic real parameters subject to the condition \(\sum _{i=1}^n c_i=0\), such that no proper subset of them sums up to zero.

The second factor in (2.3) is independent of the moduli, and given by

$$\begin{aligned} \kappa (T) \equiv (-1)^{n-1} \prod _{v\in V_T} \kappa ( \gamma _{L(v)R(v)}), \qquad \kappa (x)=(-1)^x\, x. \end{aligned}$$
(2.7)

This is simply the product of the BPS indices of the nested two-centered solutions associated with the tree T. Note that the signs of \(\Delta (T)\) and \(\kappa (T)\) separately depend on the choice of ordering \((\gamma _{L(v)},\gamma _{R(v)})\) at each vertex, but their product is independent of that choice.

Sometimes, it is useful to consider the refined BPS index \(\Omega (\gamma ,z^a,y)\) which carries additional dependence on the fugacity y conjugate to the spin \(J_3\). All the above equations remain valid in this case as well (except for the definition of the rational invariant (2.1), which must be slightly modified, see e.g. [8, (1.3)]), but now the function \(\kappa (x)\) appearing in (2.7) becomes a symmetric Laurent polynomial in y

$$\begin{aligned} \kappa (x)=(-1)^x \, \frac{ y^x-y^{-x}}{y-y^{-1}}\, , \end{aligned}$$
(2.8)

reducing to \((-1)^x x\) in the unrefined limit \(y\rightarrow 1\).

It is easy to see that the ‘flow tree formula’ (2.2) is consistent with the primitive wall-crossing formula [6, 7]

$$\begin{aligned} \Delta {\bar{\Omega }}(\gamma _L+\gamma _R) = -\mathrm{sgn}(\gamma _{LR})\, \kappa (\gamma _{LR})\, {\bar{\Omega }}(\gamma _L,z^a)\, {\bar{\Omega }}(\gamma _R,z^a) , \end{aligned}$$
(2.9)

which gives the jump of the BPS index due to the decay of bound states after crossing the wall defined by a pair of primitiveFootnote 9 charges \(\gamma _L\) and \(\gamma _R\). To this end, it suffices to consider all flow trees which start with the splitting \(\gamma \rightarrow \gamma _L+\gamma _R\) at the root of the tree. It is also consistent with the general wall-crossing formula of [46], provided the tree index is computed for a small generic perturbation of the DSZ matrix \(\gamma _{ij}\) [23]. Finally, it is useful to note that, assuming that all charges \(\gamma _i\) are distinct, the sum over splittings and flow trees in (2.2) can be generated by iterating the quadratic equation [23]

$$\begin{aligned} {\bar{\Omega }}(\gamma ,z^a)= & {} {\bar{\Omega }}_*(\gamma ) -{1\over 2}\sum _{\begin{array}{c} \gamma =\gamma _L+\gamma _R \\ \langle \gamma _L,\gamma _R \rangle \ne 0 \end{array}} \Delta _{\gamma _L\gamma _R}^z \, \kappa (\gamma _{LR})\, {\bar{\Omega }}(\gamma _L,z^a_{LR})\, {\bar{\Omega }}(\gamma _R,z^a_{LR}), \end{aligned}$$
(2.10)

where \(z^a_{LR}\) is the point where the attractor flow of charge \(\gamma \) crosses the wall of marginal stability \(\,\mathrm{Im}\,\bigl [Z_{\gamma _L}{\bar{Z}}_{\gamma _R}(z^a_{LR})\bigr ]=0\).

2.2 Partial tree index

While the representation of the BPS index based on attractor flows is useful for many purposes, it produces a sum of products of sign functions depending on non-linear combinations of DSZ products \(\gamma _{ij}\), which are very difficult to work with. A solution to overcome this problem was found in [23]. The key idea is to introduce a refined index with a fugacity y conjugate to angular momentum, and represent it as

$$\begin{aligned} g_{\mathrm{tr},n}(\{\gamma _i,c_i\},y) = \frac{(-1)^{n-1+\sum _{i<j} \gamma _{ij} }}{(y-y^{-1})^{n-1}} \,\,\mathrm{Sym}\, \Bigl \{ F_{\mathrm{tr},n}(\{\gamma _i,c_i\})\,y^{\sum _{i<j} \gamma _{ij}}\Bigr \}, \end{aligned}$$
(2.11)

where \(\,\mathrm{Sym}\, \) denotes symmetrization (with weight 1 / n!) with respect to the charges \(\gamma _i\), and \(F_{\mathrm{tr},n}\) is the ‘partial tree index’ defined byFootnote 10

$$\begin{aligned} F_{\mathrm{tr},n} (\{\gamma _{i},c_i\}) = \sum _{T\in \mathbb {T}_n^{ \text{ af-pl }}} \Delta (T) . \end{aligned}$$
(2.12)

Here the sum runs over the set \(\mathbb {T}_n^{ \text{ af-pl }}\) of planar flow trees with n leavesFootnote 11 carrying ordered charges \(\gamma _1,\ldots , \gamma _n\). Although this is not manifest, the refined tree index (2.11) is regular at \(y=1\), and its value (computed e.g. using l’Hôpital rule) reduces to the tree index (2.3). The advantage of the representation (2.11) is that the partial tree index \(F_{\mathrm{tr},n}\) does not involve the \(\kappa \)-factors (2.7) and is independent of the refinement parameter.

The partial index \(F_{\mathrm{tr},n}\) satisfies two important recursive relations. To formulate them, let us introduce some convenient notations:

$$\begin{aligned} S_k=\sum _{i=1}^k c_i, \quad \ \beta _{k\ell }=\sum _{i=1}^k \gamma _{i\ell }, \quad \ \Gamma _{k\ell }=\sum _{i=1}^k\sum _{j=1}^\ell \gamma _{ij}. \end{aligned}$$
(2.13)

In terms of these notations, the partial index satisfies the iterative equation [23, (2.59)],

$$\begin{aligned} F_{\mathrm{tr},n}(\{\gamma _i,c_i\})={1\over 2}\sum _{\ell =1}^{n-1} \bigl ( \mathrm{sgn}(S_\ell )-\mathrm{sgn}(\Gamma _{n\ell })\bigr )\, F_{\mathrm{tr},\ell }(\{\gamma _i,c_i^{(\ell )}\}_{i=1}^\ell )\, F_{\mathrm{tr},n-\ell }(\{\gamma _i,c_i^{(\ell )}\}_{i=\ell +1}^n),\nonumber \\ \end{aligned}$$
(2.14)

where \(c_i^{(\ell )}\) is the value of the stability parameters at the point where the attractor flow crosses the wall for the decay \(\gamma \rightarrow (\gamma _1+\cdots +\gamma _\ell ,\gamma _{\ell +1}+\cdots +\gamma _n)\), given by

$$\begin{aligned} c_i^{(\ell )}=c_i -\frac{\beta _{ni}}{\Gamma _{n\ell }}\, S_{\ell }\, . \end{aligned}$$
(2.15)

Importantly, \(c_i^{(\ell )}\) satisfies \(\sum _{i=1}^\ell c_i^{(\ell )}= \sum _{i=\ell +1}^n c_i^{(\ell )}=0\) so that the two factors on the r.h.s. of (2.14) are well-defined. Note that the iterative equation (2.14) is in the spirit of the quadratic equation (2.10).

According to [23, Prop. 2], the partial tree index satisfies another recursion

$$\begin{aligned} F_{\mathrm{tr},n}(\{\gamma _i,c_i\})= & {} F^{(0)}_n(\{c_i\})- \sum _{n_1+\cdots +n_m= n\atop n_k\ge 1, \ m<n} F_{\mathrm{tr},m}(\{\gamma '_k,c'_k\}) \prod _{k=1}^m F^{(0)}_{n_k}(\beta _{n,j_{k-1}+1},\ldots ,\beta _{nj_{k}}),\nonumber \\ \end{aligned}$$
(2.16)

where the sum runs over ordered partitions of n, m is the number of parts, and for \(k=1,\ldots ,m\) we defined

$$\begin{aligned} \begin{aligned}&\qquad \qquad j_0=0, \qquad j_k=n_1+\cdots + n_k, \\&\gamma '_k=\gamma _{j_{k-1}+1}+\cdots +\gamma _{j_{k}}, \qquad c'_k=c_{j_{k-1}+1}+\cdots +c_{j_{k}}. \end{aligned} \end{aligned}$$
(2.17)

The function appearing in (2.16) is simply a product of signs,

$$\begin{aligned} F^{(0)}_n(\{c_i\})=\frac{1}{2^{n-1}}\prod _{i=1}^{n-1}\text{ sgn }(S_i) . \end{aligned}$$
(2.18)

This new recursive relation allows to express the partial index in a way which does not involve sign functions depending on non-linear combinations of parameters, in contrast to the previous relation (2.14) where such sign functions arise due to the discrete attractor flow relation (2.15).

2.3 D4–D2–D0 black holes and BPS indices

The results presented above are applicable in any theory with \({\mathcal {N}}=2\) supersymmetry. Let us now specialize to the BPS black holes obtained as bound states of D4–D2–D0-branes in type IIA string theory compactified on a CY threefold \({\mathfrak {Y}}\). In this case the moduli \(z^a=b^a+\mathrm {i}t^a\) (\(a=1,\ldots , b_2({\mathfrak {Y}})\)) are the complexified Kähler moduli with respect to a basis of \(H^2({\mathfrak {Y}},\mathbb {Z})\), parametrizing the Kähler moduli space \({\mathcal {M}}_{\mathcal {K}}({\mathfrak {Y}})\). The charge vectors \(\gamma \in H_{\mathrm{even}}({\mathfrak {Y}},\mathbb {Q})\) have the form \(\gamma =(0,p^a,q_a,q_0)\) where the first entry corresponds to the D6-brane charge, which is taken to vanish, whereas the other components, corresponding to the D4, D2 and D0-brane charges, satisfy the following quantization conditions [56]:

$$\begin{aligned} p^a\in \mathbb {Z}, \qquad q_a \in \mathbb {Z}+ \frac{1}{2} \,(p^2)_a , \qquad q_0\in \mathbb {Z}-\frac{1}{24}\, p^a c_{2,a}, \end{aligned}$$
(2.19)

where \(c_{2,a}\) are components of the second Chern class of \({\mathfrak {Y}}\). In the second relation we used the notations \((kp)_a=\kappa _{abc}k^b p^c\) and \((lkp)=\kappa _{abc}l^a k^b p^c\) (recall that \(\kappa _{abc}\) are the intersection numbers on \(H_4({\mathfrak {Y}},\mathbb {Z})\)) which will be extensively used below. The lattice of charges \(\gamma \) satisfying (2.19) will be denoted by \(\Gamma \). The cone \(\Gamma _+\subset \Gamma \) is obtained by imposing the further restriction that the D4-brane charge \(p^a\) corresponds to an effective divisor in \({\mathfrak {Y}}\) and belongs to the Kähler cone, i.e.

$$\begin{aligned} p^3> 0, \qquad (r p^2)> 0, \qquad k_a p^a > 0, \end{aligned}$$
(2.20)

for all effective divisors \(r^a \gamma _a \in H_4^+({\mathfrak {Y}},\mathbb {Z})\) and effective curves \(k_a \gamma ^a \in H_2^+({\mathfrak {Y}},\mathbb {Z})\), where \(\gamma _a\) denotes irreducible divisors giving an integer basis of \( \Lambda =H_4({\mathfrak {Y}},\mathbb {Z})\), dual to the basis \(\gamma ^a\) of \(\Lambda ^*=H_2({\mathfrak {Y}},\mathbb {Z})\). The charge \(p^a\) induces a quadratic form \(\kappa _{ab}=\kappa _{abc} p^c\) on \(\Lambda \otimes \mathbb {R}\simeq \mathbb {R}^{b_2}\) of signature \((1,b_2-1)\). This quadratic form allows to embed \(\Lambda \) into \(\Lambda ^*\), but the map \(\epsilon ^a \mapsto \kappa _{ab} \epsilon ^b\) is in general not surjective, the quotient \(\Lambda ^*/\Lambda \) being a finite group of order \(|\,\mathrm{det}\, \kappa _{ab}|\).

The holomorphic central charge, governing the mass of BPS states, is given by

$$\begin{aligned} Z_\gamma (z^a)=q_\Lambda X^\Lambda (z^a) -p^\Lambda F_\Lambda (z^a), \end{aligned}$$
(2.21)

where \(X^\Lambda (z^a)=(1,z^a)\) are the special coordinates and \(F_\Lambda =\partial _{X^\Lambda } F(X)\) is the derivative of the holomorphic prepotential F(X) on \({\mathcal {M}}_{\mathcal {K}}\). In the large volume limit \(t^a\rightarrow \infty \), the prepotential reduces to the classical cubic contribution

$$\begin{aligned} F(X)\approx F^{\mathrm{cl}}(X)=-\kappa _{abc}\, \frac{ X^a X^b X^c}{6X^0}\, , \end{aligned}$$
(2.22)

and the central charge can be approximated as

$$\begin{aligned} Z_\gamma \approx -{1\over 2}\, (pt^2)+\mathrm {i}\left( q_a t^a+(pbt)\right) +q_0+q_a b^a+{1\over 2}\,(pb^2). \end{aligned}$$
(2.23)

Note, in particular, that it always has a large negative real part. Another useful observation is that both quantities appearing in the definition of \(\Delta _{\gamma _L\gamma _R}^z\) (2.4) are independent of the last component \(q_0\) of the charge vector. Indeed,

$$\begin{aligned} \begin{aligned} \langle \gamma ,\gamma '\rangle =&\, q_a p'^a-q'_ap^a, \\ \,\mathrm{Im}\,\bigl [ Z_{\gamma }{\bar{Z}}_{\gamma '}\bigr ]=&\, -{1\over 2}\,\Bigl ((p' t^2)(q_{a} +(pb)_a)t^a - (p t^2) (q'_{a}+(p'b)_a) t^a\Bigr ). \end{aligned} \end{aligned}$$
(2.24)

The BPS index \({\bar{\Omega }}(\gamma ,z^a)\) counting D4–D2–D0 black holes is given mathematically by the generalized Donaldson-Thomas invariant, which countsFootnote 12 semi-stable coherent sheaves supported on a divisor \({\mathcal {D}}\) in the homology class \(p^a\gamma _a\), with first and second Chern numbers determined by \((q_a,q_0)\). An important property of these invariants is that they are unchanged under a combined integer shift of the Kalb-Ramond field, \(b^a\mapsto b^a +\epsilon ^a\), and a spectral flow transformation acting on the D2 and D0 charges

$$\begin{aligned} q_a \mapsto q_a - \kappa _{abc}p^b\epsilon ^c, \qquad q_0 \mapsto q_0 - \epsilon ^a q_a + \frac{1}{2}\, (p\epsilon \epsilon ). \end{aligned}$$
(2.25)

The shift of \(b^a\) is important since the DT invariants are only piecewise constant as functions of the complexified Kähler moduli \(z^a=b^a+\mathrm {i}t^a\) due to wall-crossing.

In contrast, the MSW invariants \({{\bar{\Omega }}}^{\mathrm{MSW}}(\gamma )\), defined as the generalized DT invariants \({\bar{\Omega }}(\gamma ,z^a)\) evaluated at their respective large volume attractor point (1.1), are by construction independent of the moduli, and therefore invariant under the spectral flow (2.25). As a result, they only depend on \(p^a, \mu _a\) and \({\hat{q}}_{0}\), where we traded the electric charges \((q_a,q_0)\) for \((\epsilon ^a, \mu _a,{\hat{q}}_0)\). The latter comprise the spectral flow parameter \(\epsilon ^a\), the residue class \(\mu _a\in \Lambda ^*/\Lambda \) defined by the decomposition

$$\begin{aligned} q_a = \mu _a + \frac{1}{2}\, \kappa _{abc} p^b p^c + \kappa _{abc} p^b \epsilon ^c, \qquad \epsilon ^a\in \Lambda \, , \end{aligned}$$
(2.26)

and the invariant charge (\(\kappa ^{ab}\) is the inverse of \(\kappa _{ab}\))

$$\begin{aligned} {\hat{q}}_0 \equiv q_0 -\frac{1}{2}\, \kappa ^{ab} q_a q_b\, , \end{aligned}$$
(2.27)

which is invariant under (2.25). This allows to write \({{\bar{\Omega }}}^{\mathrm{MSW}}(\gamma )={\bar{\Omega }}_{p,\mu }( {\hat{q}}_0)\).

An important fact is that the invariant charge \({\hat{q}}_0\) is bounded from above by \({\hat{q}}_0^{\mathrm{max}}=\tfrac{1}{24}((p^3)+c_{2,a}p^a)\). This allows to define two generating functions

$$\begin{aligned} h^{\mathrm{DT}}_{p,q}(\tau ,z^a)= & {} \sum _{{\hat{q}}_0 \le {\hat{q}}_0^\mathrm{max}} {\bar{\Omega }}(\gamma ,z^a)\,\mathbf{e}\left( -{\hat{q}}_0 \tau \right) , \end{aligned}$$
(2.28)
$$\begin{aligned} h_{p,\mu }(\tau )= & {} \sum _{{\hat{q}}_0 \le {\hat{q}}_0^{\mathrm{max}}} {\bar{\Omega }}_{p,\mu }({\hat{q}}_0)\,\mathbf{e}\left( -{\hat{q}}_0 \tau \right) , \end{aligned}$$
(2.29)

where we used notation \(\mathbf{e}\left( x\right) =e^{2\pi \mathrm {i}x}\). Whereas the generating function of DT invariants \(h^{\mathrm{DT}}_{p,q}\) depends on the full electric charge \(q_a\) and depends on the moduli \(z^a\) in a piecewise constant fashion, the generating function of MSW invariants \(h_{p,\mu }(\tau )\), due to the spectral flow symmetry, depends only on the residue class \(\mu _a\). This generating function will be the central object of interest in this paper, and our main goal will be to understand its behavior under modular transformations of \(\tau \).

In general, the MSW invariants \({{\bar{\Omega }}}^{\mathrm{MSW}}(\gamma )\) are distinct from the attractor moduli \({\bar{\Omega }}_\star (\gamma )\), since the latter coincide with the generalized DT invariants \({\bar{\Omega }}(\gamma ,z^a)\) evaluated at the true attractor point \(z^a_*(\gamma )\) for the charge \(\gamma \), while the former are the generalized DT invariants evaluated at the large volume attractor point \(z^a_\infty (\gamma )\) defined in (1.1). Nevertheless, we claim that in the large volume limit \(t^a\rightarrow \infty \), the tree flow formula reviewed in the previous subsections still allows to express \({\bar{\Omega }}(\gamma ,z^a)\) in terms of the MSW invariants, namely

$$\begin{aligned} {\bar{\Omega }}(\gamma ,z^a) = \sum _{\sum _{i=1}^n \gamma _i=\gamma } g_{\mathrm{tr},n}(\{\gamma _i\}, z^a)\, \prod _{i=1}^n {{\bar{\Omega }}}^{\mathrm{MSW}}(\gamma _i) \qquad (\,\mathrm{Im}\,z^a\rightarrow \infty ) \end{aligned}$$
(2.30)

The point is that the only walls of marginal stability which extend to infinite volume are those where the constituents carry no D6-brane charge, and that non-trivial bound states involving constituents with D4-brane charge are ruled out at the large volume attractor point, similarly to the usual attractor chamber. Since the r.h.s. of (2.30) is consistent with wall-crossing in the infinite volume limit and agrees with the left-hand side at \(z^a=z^a_\infty (\gamma )\), it must therefore hold everywhere at large volume. Of course, some of the states contributing to \({{\bar{\Omega }}}^{\mathrm{MSW}}(\gamma _i)\) may have some substructure, e.g. be realized as D6-\(\overline{\mathrm{D6}}\) bound states, but this structure cannot be probed in the large volume limit. Importantly, since the quantities (2.24) entering in the definition of the tree index are independent of the D0-brane charge \(q_0\), the flow tree formula (2.30) may be rewritten as a relation between the generating functions,

$$\begin{aligned} h^{\mathrm{DT}}_{p,q}(\tau ,z^a) = \sum _{\sum _{i=1}^n {{\check{\gamma }}}_i={{\check{\gamma }}}} g_{\mathrm{tr},n}(\{{{\check{\gamma }}}_i\},z^a)\,e^{\pi \mathrm {i}\tau Q_n(\{{{\check{\gamma }}}_i\})} \prod _{i=1}^n h_{p_i,\mu _i}(\tau ), \end{aligned}$$
(2.31)

where \({{\check{\gamma }}}=(p^a,q_a)\) denotes the projection of the charge vector \(\gamma \) on \(H_4\oplus H_2\), and the phase proportional to

$$\begin{aligned} Q_n(\{{{\check{\gamma }}}_i\})= \kappa ^{ab}q_a q_b-\sum _{i=1}^n\kappa _i^{ab}q_{i,a} q_{i,b} \end{aligned}$$
(2.32)

appears due to the quadratic term in the definition (2.27) of the invariant charge \({\hat{q}}_0\).

3 D3-Instantons and Contact Potential

In this section, we switch to the dual setupFootnote 13 of type IIB string theory compactified on the same CY manifold \({\mathfrak {Y}}\). The DT invariants, describing the BPS degeneracies of D4–D2–D0 black holes in type IIA, now appear as coefficients in front of the D3–D1–D(-1) instanton effects affecting the metric on the hypermultiplet moduli space \({\mathcal {M}}_H\). The main idea of our approach is that these instanton effects are strongly constrained by demanding that \({\mathcal {M}}_H\) admits an isometric action of the type IIB S-duality \(SL(2,\mathbb {Z})\). This constraint uniquely fixes the modular behavior of the generating functions introduced in the previous section. Here we recall the twistorial construction of D-instanton corrections to the hypermultiplet metric, describe the action of S-duality, and analyze the instanton expansion of a particular function on \({\mathcal {M}}_H\) known as contact potential.

3.1 \({\mathcal {M}}_H\) and twistorial description of instantons

The moduli space of four-dimensional \(N=2\) supergravity is a direct product of vector and hypermultiplet moduli spaces, \({\mathcal {M}}_V\times {\mathcal {M}}_H\). The former is a (projective) special Kähler manifold, whereas the latter is a quaternion-Kähler (QK) manifold. In type IIB string theory compactified on a CY threefold \({\mathfrak {Y}}\), \({\mathcal {M}}_H\) is a space of real dimension \(4b_2({\mathfrak {Y}})+4\), which is fibered over the complexified Kähler moduli space \({\mathcal {M}}_{\mathcal {K}}({\mathfrak {Y}})\) of dimension \(2b_2({\mathfrak {Y}})\). In addition to the Kähler moduli \(z^a=b^a+\mathrm {i}t^a\), it describes the dynamics of the ten-dimensional axio-dilaton \(\tau =c^0+\mathrm {i}/g_s\), the Ramond-Ramond (RR) scalars \(c^a,{\tilde{c}}_a,{\tilde{c}}_0\), corresponding to periods of the RR 2-form, 4-form and 6-form on a basis of \(H^{\mathrm{even}}({\mathfrak {Y}},\mathbb {Z})\), and finally, the NS-axion \(\psi \), dual to the Kalb-Ramond two-form B in four dimensions.

At tree-level, the QK metric on \({\mathcal {M}}_H\) is obtained from the Kähler moduli space \({\mathcal {M}}_{{\mathcal {K}}}\) via the c-map construction [57, 58] and thus is completely determined by the holomorphic prepotential F(X). But this metric receives \(g_s\)-corrections, both perturbative and non-perturbative. The latter can be of two types: either from Euclidean D-branes wrapping even dimensional cycles on \({\mathfrak {Y}}\), or from NS5-branes wrapped around the whole \({\mathfrak {Y}}\). In this paper we shall be interested only in the effects of D3–D1–D(-1) instantons, and ignore the effects of NS5 and D5-instantons, which are subleading in the large volume limit. Since NS5-instantons only mix with D5-instantons under S-duality, this truncation does not spoil modular invariance [21].

The most concise way to describe the D-instanton corrections is to consider type IIA string theory compactified on the mirror CY threefold \({\widehat{{\mathfrak {Y}}}}\) and use the twistor formalism for quaternionic geometries [38, 39]. In this approach the metric is encoded in the complex contact structure on the twistor space, a \(\mathbb {C}P^1\)-bundle over \({\mathcal {M}}_H\). The D-instanton corrected contact structure has been constructed to all orders in the instanton expansion in [37, 40], and an explicit expression for the metric has been derived recently in [59, 60]. Here we will present only those elements of the construction which are relevant for the subsequent analysis, and refer to reviews [61, 62] for more details.

The crucial point is that, locally, the contact structure is determined by a set of holomorphic Darboux coordinates \((\xi ^\Lambda ,{\tilde{\xi }}_\Lambda ,\alpha )\) on the twistor space, considered as functions of coordinates on \({\mathcal {M}}_H\) and of the stereographic coordinate t on the \(\mathbb {C}P^1\) fiber, so that the contact one-form takes the canonical form \(\mathrm {d}\alpha +{\tilde{\xi }}_\Lambda \mathrm {d}\xi ^\Lambda \). Although all Darboux coordinates are important for recovering the metric, for the purposes of this paper the coordinate \(\alpha \) is irrelevant. Therefore, we consider only \(\xi ^\Lambda \) and \({\tilde{\xi }}_\Lambda \) which can be conveniently packaged into holomorphic Fourier modes \({\mathcal {X}}_\gamma = \mathbf{e}\left( p^\Lambda {\tilde{\xi }}_\Lambda -q_\Lambda \xi ^\Lambda \right) \) labelled by a charge vector \(\gamma =(p^\Lambda ,q_\Lambda )\).

At tree level, the Darboux coordinates (multiplied by t) are known to be simple quadratic polynomials in t so that \({\mathcal {X}}_\gamma \) take the formFootnote 14

$$\begin{aligned} {\mathcal {X}}^{\mathrm{sf}}_\gamma (t)=\mathbf{e}\left( \frac{\tau _2}{2}\left( {\bar{Z}}_\gamma ({\bar{u}}^a)\,t-\frac{Z_\gamma (u^a)}{t}\right) +p^\Lambda {\tilde{\zeta }}_\Lambda - q_\Lambda \zeta ^\Lambda \right) , \end{aligned}$$
(3.1)

where \(Z_\gamma (u^a)\) is the central charge (2.21), now expressed in terms of the complex structure moduli \(u^a\) of the CY threefold \({\widehat{{\mathfrak {Y}}}}\) mirror to \({\mathfrak {Y}}\), \(\zeta ^\Lambda \) and \({\tilde{\zeta }}_\Lambda \) are periods of the RR 3-form in the type IIA formulation, and \(\tau _2=g_s^{-1}\) is the inverse ten-dimensional string coupling. At the non-perturbative level, this expression gets modified and the Darboux coordinates are determined by the integral equation

$$\begin{aligned} {\mathcal {X}}_\gamma (t) = {\mathcal {X}}^{\mathrm{sf}}_\gamma (t)\, \mathbf{e}\left( \frac{1}{8\pi ^2} \sum _{\gamma '} \sigma _{\gamma '} \, {\bar{\Omega }}(\gamma ')\, \langle \gamma ,\gamma '\rangle \int _{\ell _{\gamma '} }\frac{\mathrm {d}t'}{t'}\, \frac{t+t'}{t-t'}\, {\mathcal {X}}_{\gamma '}(t')\right) , \end{aligned}$$
(3.2)

where the sum goes over all charges labelling cycles wrapped by D-branes, \({\bar{\Omega }}(\gamma ')={\bar{\Omega }}(\gamma ',z^a)\) is the corresponding rational Donaldson-Thomas invariant,

$$\begin{aligned} \ell _\gamma = \{ t\in \mathbb {C}P^1\ :\ \ Z_\gamma /t\in \mathrm {i}\mathbb {R}^-\} \end{aligned}$$
(3.3)

is the so called BPS ray, a contour on \(\mathbb {C}P^1\) extending from \(t=0\) to \(t=\infty \) along the direction fixed by the central charge, and \(\sigma _\gamma \) is a quadratic refinement of the DSZ product on the charge lattice \(\Gamma \), i.e. a sign factor satisfying the defining relation

$$\begin{aligned} \sigma _{\gamma _1}\sigma _{\gamma _2}=(-1)^{\langle \gamma _1,\gamma _2\rangle }\sigma _{\gamma _1+\gamma _2}, \qquad \forall \gamma _1,\gamma _2\in \Gamma . \end{aligned}$$
(3.4)

The system of integral equations (3.2) can be solved iteratively by first substituting \({\mathcal {X}}_{\gamma '}(t')\) on the r.h.s. with its zero-th order value \({\mathcal {X}}^{\mathrm{sf}}_{\gamma '}(t')\) in the weak coupling limit \(\tau _2\rightarrow \infty \), computing the leading correction from the integral and iterating this process. This produces an asymptotic series at weak coupling, in powers of the DT invariants \({\bar{\Omega }}(\gamma )\). Using the saddle point method, it is easy to check that the coefficient of each monomial \(\prod _i {\bar{\Omega }}(\gamma _i)\) is suppressed by a factor \(e^{-\pi \tau _2 \sum _i |Z_{\gamma _i}|}\), corresponding to an n-instanton effect [41, 63]. Note that multi-instanton effects become of the same order as one-instanton effects on walls of marginal stability where the phases of \(Z_{\gamma _i}\) become aligned, and that the wall-crossing formula ensures that the QK metric on \({\mathcal {M}}_H\) is smooth across the walls [40, 41].

3.2 D3-instantons in the large volume limit

The above construction of D-instantons is adapted to the type IIA formulation because the equation (3.2) defines the Darboux coordinates in terms of the type IIA fields appearing explicitly in the tree level expression (3.1). To pass to the mirror dual type IIB formulation, one should apply the mirror map, a coordinate transformation from the type IIA to the type IIB physical fields. This transformation was determined in the classical limit in [64], but it also receives instanton corrections. In order to fix the form of these corrections, we require that the metric on \({\mathcal {M}}_H\) carries an isometric action of S-duality group \(SL(2,\mathbb {Z})\) of type IIB string theory, which acts on the type IIB fields by an element \(g={\begin{pmatrix} a &{} b \\ c &{} d \end{pmatrix}}\) in the following way

$$\begin{aligned} \begin{aligned}&\tau \mapsto \frac{a \tau +b}{c \tau + d} \, , \qquad t^a \mapsto |c\tau +d| \,t^a, \qquad \begin{pmatrix} c^a \\ b^a \end{pmatrix} \mapsto \begin{pmatrix} a &{} b \\ c &{} d \end{pmatrix} \begin{pmatrix} c^a \\ b^a \end{pmatrix} , \\&\qquad {\tilde{c}}_a\mapsto {\tilde{c}}_a - c_{2,a} \varepsilon (g) , \qquad \begin{pmatrix} {\tilde{c}}_0 \\ \psi \end{pmatrix} \mapsto \begin{pmatrix} d &{} -c \\ -b &{} a \end{pmatrix} \begin{pmatrix} {\tilde{c}}_0 \\ \psi \end{pmatrix}, \end{aligned} \end{aligned}$$
(3.5)

where \(\varepsilon (g)\) is the logarithm of the multiplier system of the Dedekind eta function [56].

For this purpose, one uses the fact that any isometric action on a quaternion-Kähler manifold (preserving the quaternionic structure) can be lifted to a holomorphic contact transformation on twistor space. In the present case, \(SL(2,\mathbb {Z})\) acts on the fiber coordinate t by a fractional-linear transformation with \(\tau \)-dependent coefficients. This transformation takes a much simpler form when formulated in terms of another coordinate z on \(\mathbb {C}P^1\) (not to be confused with the Kähler moduli \(z^a\)), which is related to t by a Cayley transformation,

$$\begin{aligned} z =\frac{t+\mathrm {i}}{t-\mathrm {i}}\, . \end{aligned}$$
(3.6)

Then the action of \(SL(2,\mathbb {Z})\) on the fiber is given by a simple phase rotationFootnote 15

$$\begin{aligned} z\mapsto \frac{c{\bar{\tau }}+d}{|c\tau +d|}\, z\, . \end{aligned}$$
(3.7)

Using the holomorphy constraint for the \(SL(2,\mathbb {Z})\) action on the twistor space, quantum corrections to the classical mirror map were computed in [21, 26, 66, 67], in the large volume limit where the Kähler moduli are taken to be large, \(t^a\rightarrow \infty \). In this limit, one finds

$$\begin{aligned} \begin{aligned} u^a=&\,b^a+\mathrm {i}t^a-\frac{\mathrm {i}}{2\tau _2}{\sum _{\gamma \in \Gamma _+}}p^a\left[ \int _{\ell _{\gamma }}\mathrm {d}z\,(1-z)\,H_{\gamma } +\int _{\ell _{-\gamma }}\frac{\mathrm {d}z}{z^3} (1-z)\,H_{-\gamma }\right] \\ \zeta ^0=&\,\tau _1, \qquad \zeta ^a=-(c^a-\tau _1 b^a) -3\sum _{\gamma \in \Gamma _+} p^a\,\mathrm{Re}\,\int _{\ell _{\gamma }} \mathrm {d}z\, z\,H_{\gamma }, \\ {\tilde{\zeta }}_a =&\,{\tilde{c}}_a+ \frac{1}{2}\, \kappa _{abc} \,b^b (c^c - \tau _1 b^c)+ \kappa _{abc}t^b \sum _{\gamma \in \Gamma _+} p^c\,\mathrm{Im}\,\int _{\ell _{\gamma }} \mathrm {d}z\,H_{\gamma }, \end{aligned} \end{aligned}$$
(3.8)

where we introduced the convenient notationFootnote 16

$$\begin{aligned} H_\gamma (t)= \frac{{\bar{\Omega }}(\gamma )}{(2\pi )^2}\,\sigma _\gamma {\mathcal {X}}_\gamma (t)\, . \end{aligned}$$
(3.9)

Similar results are known for \({\tilde{\zeta }}_0\) and the NS-axion dual to the B-field, but will not be needed in this paper.

Note that the integral contributions to the mirror map are written in terms of the coordinate z (3.6). The reason for using this variable is that, in the large volume limit, the integrals along BPS rays \(\ell _\gamma \) in (3.2) are dominated by the saddle point [21]

$$\begin{aligned} z'_\gamma \approx -\mathrm {i}\,\frac{(q_a+(pb)_a)\,t^a}{(pt^2)}\, , \end{aligned}$$
(3.10)

for \((pt^2)>0\), and \(z'_{-\gamma }=1/z'_\gamma \) in the opposite case. This shows that all integrands can be expanded in Fourier series either around \(z=0\) or \(z=\infty \), keeping constant \(t^a z\) or \(t^a/z\), respectively. This allows to extract the leading order in the large volume limit in a simple way.

Let us therefore evaluate the combined limit \(t^a\rightarrow \infty \), \(z\rightarrow 0\) of the system of integral equations (3.2), assuming that only D3–D1–D(-1) instantons contribute. As a first step, we rewrite the tree level expression (3.1) in terms of the type IIB fields. To this end, we restrict the charge \(\gamma \) to lie in the cone \(\Gamma _+\), take the central charge as in (2.21) with the cubicFootnote 17 prepotential (2.22), and substitute the mirror map (3.8). Furthermore, we change the coordinate t to z and take the combined limit. In this way one finds

$$\begin{aligned} {\mathcal {X}}^{\mathrm{sf}}_\gamma (z)={\mathcal {X}}^{\mathrm{cl}}_\gamma (z) \exp \left[ 2\pi \sum _{\gamma '\in \Gamma _+} (tpp')\int _{\ell _{\gamma '}} \mathrm {d}z'\,H_{\gamma '}\right] , \end{aligned}$$
(3.11)

where

$$\begin{aligned} {\mathcal {X}}^{\mathrm{cl}}_\gamma (z) =\mathbf{e}\left( - {\hat{q}}_0\tau \right) {\mathcal {X}}^{(\theta )}_{p,q}(z) \end{aligned}$$
(3.12)

is the classical part of the Darboux coordinates which we represented as a product of two factors: exponential of the invariant charge (2.27) and the remaining \(q_0\)-independent exponential

$$\begin{aligned} {\mathcal {X}}^{(\theta )}_{p,q}(z) = e^{-S^{\mathrm{cl}}_p}\, \mathbf{e}\left( - \frac{\tau }{2}\,(q+b)^2+c^a (q_a +\textstyle {1\over 2}(pb)_a)+\mathrm {i}\tau _2 (pt^2)(z^2-2zz_\gamma )\right) , \qquad \end{aligned}$$
(3.13)

with \(S^{\mathrm{cl}}_p\) being the leading part of the Euclidean D3-brane action in the large volume limit given by \(S^{\mathrm{cl}}_p= \pi \tau _2(pt^2) - 2\pi \mathrm {i}p^a {\tilde{c}}_a\). Next, we can approximate

$$\begin{aligned} \frac{\mathrm {d}t'}{t'}\, \frac{t+t'}{t-t'}=\frac{2\mathrm {d}z'}{1-z'^2}\, \frac{1-zz'}{z-z'}\approx \left\{ \begin{array}{c@{\quad }c} \frac{2\mathrm {d}z'}{z-z'}\, , \qquad &{} \gamma '\in \Gamma _+, \\ \frac{2(1-zz')\mathrm {d}z'}{z'^3}\, , \qquad &{} \gamma '\in -\Gamma _+. \end{array} \right. \end{aligned}$$
(3.14)

This shows that the contribution of \(\gamma '\in -\Gamma _+\) is suppressed comparing to \(\gamma '\in \Gamma _+\) and therefore can be neglected. As a result, the system of integral equations (3.2) in the large volume limit where only D3–D1–D(-1) instantons contribute reduces to the following system of integral equations for \(H_\gamma \),

$$\begin{aligned} H_\gamma (z)=H^{\mathrm{cl}}_\gamma (z) \, \exp \left[ \sum _{\gamma '\in \Gamma _+}\int _{\ell _{\gamma '}}\mathrm {d}z'\, K_{\gamma \gamma '}(z,z')\,H_{\gamma '}(z')\right] . \end{aligned}$$
(3.15)

Here \(H^{\mathrm{cl}}_\gamma \) is the classical limit of \(H_\gamma \), i.e. the function (3.9) with \({\mathcal {X}}_\gamma \) replaced by \({\mathcal {X}}^{\mathrm{cl}}_\gamma \), the integration kernel is now

$$\begin{aligned} K_{\gamma _1\gamma _2}(z_1,z_2) =2\pi \left( (tp_1p_2)+\frac{\mathrm {i}\langle \gamma _1,\gamma _2\rangle }{z_1-z_2}\right) , \end{aligned}$$
(3.16)

and the BPS ray \(\ell _{\gamma }\) effectively extends from \(z'=-\infty \) to \(z'=+\infty \), going through the saddle point (3.10) [21].

Below we shall need a perturbative solution of the integral equation (3.15). Applying the iterative procedure outlined below (3.4), or equivalently using the Lagrange inversion theorem, such solution can be written as a sum over rooted trees [41, §C],

$$\begin{aligned} H_{\gamma _1}(z_1) = H^{\mathrm{cl}}_{\gamma _1}(z_1) \, \sum _{n=1}^{\infty } \left( \prod _{i=2}^n \sum _{\gamma _i\in \Gamma _+}\, \int _{\ell _{\gamma _i}} \mathrm {d}z_i\, H^{\mathrm{cl}}_{\gamma _i}(z_i) \right) \sum _{{\mathcal {T}}\in \mathbb {T}_n^{\mathrm{r}}}\, \frac{{\mathcal {A}}({\mathcal {T}})}{|\mathrm{Aut}({\mathcal {T}})|}\, , \end{aligned}$$
(3.17)

where \(\mathbb {T}_n^{\mathrm{r}}\) is the set of rooted trees with n vertices and

$$\begin{aligned} {\mathcal {A}}({\mathcal {T}}) = \prod _{e\in E_{{\mathcal {T}}}} K_{\gamma _{s(e)},\gamma _{t(e)}}(z_{s(e)},z_{t(e)}). \end{aligned}$$
(3.18)

A rooted treeFootnote 18\({\mathcal {T}}\) consists of n vertices joined by directed edges so that the root vertex has only outgoing edges, whereas all other vertices have one incoming edge and an arbitrary number of outgoing ones. We label the vertices of \({\mathcal {T}}\) by \({\mathfrak {v}}=1,\ldots , n\) in an arbitrary fashion, except for the root which is labelled by \({\mathfrak {v}}=1\). The symmetry factor \(|\mathrm{Aut}({\mathcal {T}})|\) is the order of the symmetry group which permutes the labels \(2,\ldots , n\) without changing the topology of the tree. Each vertex is decorated by a charge vector \(\gamma _{\mathfrak {v}}\) and a complex variable \(z_{\mathfrak {v}}\in \mathbb {C}P^1\). We denote the set of edges by \(E_{{\mathcal {T}}}\), the set of vertices by \(V_{{\mathcal {T}}}\), and the source and target vertex of an edge e by s(e) and t(e), respectively. Unpacking these notations, we get, at the few leading orders,

$$\begin{aligned} H_{\gamma _1}= & {} H^{\mathrm{cl}}_{\gamma _1} + \sum _{\gamma _2} K_{12} H^{\mathrm{cl}}_{\gamma _1} \, H^{\mathrm{cl}}_{\gamma _2} + \sum _{\gamma _2,\gamma _3} \left( \tfrac{1}{2}\, K_{12} K_{13} + K_{12} K_{23} \right) H^{\mathrm{cl}}_{\gamma _1}\, H^{\mathrm{cl}}_{\gamma _2}\, H^{\mathrm{cl}}_{\gamma _3} \nonumber \\&+ \sum _{\gamma _2,\gamma _3,\gamma _4} \!\!\!\left( \tfrac{1}{6}\, K_{12} K_{13} K_{14} + \tfrac{1}{2}\, K_{12} K_{23} K_{24} \nonumber \right. \\&\left. + K_{12} K_{13} K_{24} + K_{12} K_{23} K_{34} \right) H^{\mathrm{cl}}_{\gamma _1} \, H^{\mathrm{cl}}_{\gamma _2}\, H^{\mathrm{cl}}_{\gamma _3}\, H^{\mathrm{cl}}_{\gamma _4}+ \cdots \end{aligned}$$
(3.19)

where we omitted the integrals and denoted \(K_{ij}=K_{\gamma _i,\gamma _j}(z_i,z_j)\). The expansion (3.17) is effectively a multi-instanton expansion in powers of the DT invariants \({\bar{\Omega }}(\gamma _i)\), which is asymptotic to the exact solution to (3.15) in the weak coupling limit \(\tau _2\rightarrow \infty \).

3.3 From the contact potential to the instanton generating function

Recall that our goal is to derive constraints imposed by S-duality on the DT invariants \({\bar{\Omega }}(\gamma )\) appearing as coefficients in the multi-instanton expansion. To achieve this goal, rather than studying the full metric on \({\mathcal {M}}_H\), it suffices to consider a suitable function on this moduli space which has a non-trivial dependence on \({\bar{\Omega }}(\gamma )\) and specified transformations under S-duality. There is a natural candidate with the above properties: the so-called contact potential \(e^{\phi }\), a real function which is well-defined on any quaternion-Kähler manifold with a continuous isometry [39]. Furthermore, there is a general expression for the contact potential in terms of Penrose-type integrals on the \(\mathbb {C}P^1\) fiber. In the present case, the required isometry is the shift of the NS-axion, which survives all quantum corrections as long as NS5-instantons are switched off. The contact potential is then given by the exact formula [37]

$$\begin{aligned} e^{\phi } = \frac{\mathrm {i}\tau _2^2}{16}\left( {\bar{u}}^\Lambda F_\Lambda - u^\Lambda {\bar{F}}_\Lambda \right) -\frac{\chi _{{\widehat{{\mathfrak {Y}}}}}}{192\pi } +\frac{\mathrm {i}\tau _2}{16}\,\sum _\gamma \int _{\ell _\gamma } \frac{\text {d}t}{t} \left( t^{-1} Z_\gamma (u^a)-t{\bar{Z}}_\gamma ({\bar{u}}^a)\right) H_\gamma ,\nonumber \\ \end{aligned}$$
(3.20)

where \(\chi _{{\widehat{{\mathfrak {Y}}}}}\) is the Euler characteristic of \({\widehat{{\mathfrak {Y}}}}\). This formula indeed captures contribution from D-instantons due to the last term proportional to \(H_\gamma \).

On the other hand, in the classical, large volume limit one finds \(e^\phi =\frac{\tau _2^2}{12}(t^3)\), which shows that the contact potential can be identified with the four-dimensional dilaton and in this approximation behaves as a modular form of weight \((-\tfrac{1}{2}, -\tfrac{1}{2})\) under S-duality transformations (3.5). In fact, one can show [37] that \(SL(2,\mathbb {Z})\) preserves the contact structure, i.e. it is an isometry of \({\mathcal {M}}_H\), only if the full non-perturbative contact potential transforms in this way,

$$\begin{aligned} e^\phi \mapsto \frac{e^\phi }{|c\tau +d|}\, . \end{aligned}$$
(3.21)

Furthermore, since S-duality acts by rescaling the Kähler moduli \(t^a\) and by a phase rotation of the fiber coordinate z (see (3.7)), it preserves each order in the expansion around the large volume limit. This implies that the large volume limit of the D3-instanton contribution to \(e^\phi \), which we denote by \((e^\phi )_{\mathrm{D3}}\), must itself transform as (3.21). It is this condition that we shall exploit to derive modularity constraints on the DT invariants.

To make this condition more explicit, let us extract the D3-instanton contribution to the function (3.20). The procedure is the same as the one used to get (3.15), and we relegate the details of the calculation to appendix B. The result can be written in a concise way using the complex function defined by

$$\begin{aligned} {\mathcal {G}}= & {} \sum _{\gamma \in \Gamma _+}\int _{\ell _{\gamma }} \mathrm {d}z\, H_{\gamma }(z)-{1\over 2}\,\sum _{\gamma _1,\gamma _2\in \Gamma _+} \int _{\ell _{\gamma _1}}\mathrm {d}z_1\,\int _{\ell _{\gamma _2}} \mathrm {d}z_2 \, K_{\gamma _1\gamma _2}(z_1,z_2)\,H_{\gamma _1}(z_1)H_{\gamma _2}(z_2)\nonumber \\ \end{aligned}$$
(3.22)

and the Maass raising operator

$$\begin{aligned} {\mathcal {D}}_{{\mathfrak {h}}} = \frac{1}{2\pi \mathrm {i}}\left( \partial _\tau +\frac{{\mathfrak {h}}}{2\mathrm {i}\tau _2}+ \frac{\mathrm {i}t^a}{4\tau _2}\, \partial _{t^a}\right) , \end{aligned}$$
(3.23)

which maps modular functions of weight \(({\mathfrak {h}},{\bar{{\mathfrak {h}}}})\) to modular functions of weight \(({\mathfrak {h}}+2,{\bar{{\mathfrak {h}}}})\). Then one has (generalizing [14, (4.5)] to all orders in the instanton expansion)

$$\begin{aligned} (e^\phi )_{\mathrm{D3}} =\frac{\tau _2}{2}\,\mathrm{Re}\,\left( {\mathcal {D}}_{-\frac{3}{2}}{\mathcal {G}}\right) +\frac{1}{32\pi ^2}\,\kappa _{abc}t^c\partial _{{\tilde{c}}_a}{\mathcal {G}}\partial _{{\tilde{c}}_b}{\overline{{\mathcal {G}}}}. \end{aligned}$$
(3.24)

It is immediate to see that \((e^\phi )_{\mathrm{D3}}\) transforms under S-duality as (3.21) provided the function \({\mathcal {G}}\) transforms as a modular form of weight \((-\tfrac{3}{2},\tfrac{1}{2})\). In order to derive the implications of this fact, we need to express \({\mathcal {G}}\) in terms of the generalized DT invariants.

For this purpose, we substitute the multi-instanton expansion (3.17) into (3.22). We claim that the result takes the simple form

$$\begin{aligned} {\mathcal {G}}=\sum _{n=1}^\infty \left[ \prod _{i=1}^{n} \sum _{\gamma _i\in \Gamma _+}\int _{\ell _{\gamma _i}}\mathrm {d}z_i\, H^{\mathrm{cl}}_{\gamma _i}(z_i) \right] {\mathcal {G}}_n(\{\gamma _i,z_i\}), \end{aligned}$$
(3.25)

where \({\mathcal {G}}_n(\{\gamma _i,z_i\})\) is now a sum over unrooted trees with n vertices,

$$\begin{aligned} {\mathcal {G}}_n(\{\gamma _i,z_i\})=\sum _{{\mathcal {T}}\in \, \mathbb {T}_n} \frac{{\mathcal {A}}({\mathcal {T}})}{|\mathrm{Aut}({\mathcal {T}})|}=\frac{1}{n!}\sum _{{\mathcal {T}}\in \, \mathbb {T}_n^\ell } {\mathcal {A}}({\mathcal {T}}), \end{aligned}$$
(3.26)

and in the second equality we rewrote the result as a sum over unrooted labelled trees.Footnote 19

To see why this is the case, observe that under the action of the Euler operator \({{\hat{D}}}=H^{\mathrm{cl}}\partial _{H^{\mathrm{cl}}}\) rescaling all functions \(H^{\mathrm{cl}}_\gamma \), the function \({\mathcal {G}}\) maps to the first term in (3.22), which we denote by \({\mathcal {F}}\). Namely,

$$\begin{aligned} {{\hat{D}}}\cdot {\mathcal {G}}={\mathcal {F}}, \qquad {\mathcal {F}}\equiv \sum _{\gamma \in \Gamma _+}\int _{\ell _{\gamma }} \mathrm {d}z\, H_{\gamma }, \end{aligned}$$
(3.27)

as can be verified with the help of the integral equation (3.15). The multi-instanton expansion of \({\mathcal {F}}\) follows immediately from (3.17),

$$\begin{aligned} {\mathcal {F}}= \sum _{n=1}^{\infty } \left( \prod _{i=1}^n \sum _{\gamma _i\in \Gamma _+}\, \int _{\ell _{\gamma _i}} \mathrm {d}z_i\, H^{\mathrm{cl}}_{\gamma _i}(z_i) \right) \sum _{{\mathcal {T}}\in \mathbb {T}_n^{\mathrm{r}}}\, \frac{{\mathcal {A}}({\mathcal {T}})}{|\mathrm{Aut}({\mathcal {T}})|}\, . \end{aligned}$$
(3.28)

Integrating back the action of the derivative operator \({{\hat{D}}}\), we see that the sum over rooted trees in (3.28) turns into the sum over unrooted trees in (3.26). At the first few orders we get, using the same shorthand notation as in (3.19),

$$\begin{aligned} \begin{aligned} {\mathcal {G}}=&\sum _{\gamma } H^{\mathrm{cl}}_\gamma + \frac{1}{2} \sum _{\gamma _1,\gamma _2}K_{12}H^{\mathrm{cl}}_{\gamma _1} \,H^{\mathrm{cl}}_{\gamma _2} + \frac{1}{2} \sum _{\gamma _1,\gamma _2,\gamma _3} K_{12}K_{23}H^{\mathrm{cl}}_{\gamma _1}\, H^{\mathrm{cl}}_{\gamma _2}\, H^{\mathrm{cl}}_{\gamma _3} \\&+\sum _{\gamma _1,\gamma _2,\gamma _3,\gamma _4} \left( \frac{1}{6} \, K_{12} K_{13} K_{14} + \frac{1}{2}\,K_{12} K_{23} K_{34} \right) H^{\mathrm{cl}}_{\gamma _1}\, H^{\mathrm{cl}}_{\gamma _2}\, H^{\mathrm{cl}}_{\gamma _3}\, H^{\mathrm{cl}}_{\gamma _4} + \cdots \end{aligned} \end{aligned}$$
(3.29)

The simplicity of the expansion (3.26), and the relation (3.24) to the contact potential, show that the function \({\mathcal {G}}\) is very natural and, in some sense, more fundamentalFootnote 20 than the naive instanton sum \({\mathcal {F}}\). We shall henceforth refer to \({\mathcal {G}}\) as the ‘instanton generating function’. In the following we shall postulate that \({\mathcal {G}}\) transforms as a modular form of weight \((-\frac{3}{2},\frac{1}{2})\), and analyze the consequences of this requirement for the DT invariants.

4 Theta Series Decomposition and Modularity

In this section, we use the spectral flow symmetry to decompose the instanton generating function \({\mathcal {G}}\) into a sum of indefinite theta series multiplied by holomorphic generating functions of MSW invariants. We then study the modular properties of these indefinite theta series, and identify the origin of the modular anomaly.

4.1 Factorisation

To derive modularity constraints on the DT invariants, we need to perform a theta series decomposition of the generating function \({\mathcal {G}}\) defined in (3.22). To this end, let us make use of the fact noticed in (2.24) that the DSZ products \(\langle \gamma ,\gamma '\rangle \) and hence the kernels (3.16) do not depend on the \(q_0\) charge. Choosing the quadratic refinement \(\sigma _\gamma \) as in (D.5), which is also \(q_0\)-independent, and using the factorization (3.12) of \({\mathcal {X}}^{\mathrm{cl}}_\gamma \), one can rewrite the expansion (3.25) as follows

$$\begin{aligned} {\mathcal {G}}=\sum _{n=1}^\infty \frac{1}{(2\pi )^{2n}}\left[ \prod _{i=1}^{n} \sum _{p_i,q_i}\sigma _{p_i,q_i}h^\mathrm{DT}_{p_i,q_i}\int _{\ell _{\gamma _i}}\mathrm {d}z_i\, {\mathcal {X}}^{(\theta )}_{p_i,q_i}(z_i) \right] {\mathcal {G}}_n(\{\gamma _i,z_i\}), \end{aligned}$$
(4.1)

where the sum over the invariant charges \({\hat{q}}_{i,0}\) gave rise to the generating functions of DT invariants defined in (2.28). This is not yet the desired form because these generating functions depend non-trivially on the remaining electric charges \(q_{i,a}\). If it were not for this dependence, the sum over \(q_{i,a}\) would produce certain non-Gaussian theta series, and at each order we would have a product of this theta series and n generating functions. Then the modular properties of the theta series would dictate the modular properties of the generating function.

Such a theta series decomposition can be achieved by expressing the DT invariants in terms of the MSW invariants, for which the dependence on electric charges \(q_{i,a}\) reduces to the dependence on the residue classes \(\mu _{i,a}\) due to the spectral flow symmetry. Substituting the expansion (2.31) of \(h^\mathrm{DT}_{p,q}\) in terms of \(h_{p,\mu }\), the expansion (4.1) of the function \({\mathcal {G}}\) can be brought to the following factorized form

$$\begin{aligned} {\mathcal {G}}=\sum _{n=1}^\infty \frac{2^{-\frac{n}{2}}}{\pi \sqrt{2\tau _2}}\left[ \prod _{i=1}^{n} \sum _{p_i,\mu _i}\sigma _{p_i}h_{p_i,\mu _i}\right] e^{-S^\mathrm{cl}_p}\vartheta _{{{\varvec{p}}},{\varvec{\mu }}}\bigl (\Phi ^{\mathrm{tot}}_{n},n-2\bigr ), \end{aligned}$$
(4.2)

where \(\vartheta _{{{\varvec{p}}},{\varvec{\mu }}}\) is a theta series (D.1) with parameter \(\lambda =n-2\), whose kernel has the following structure

$$\begin{aligned} \Phi ^{\mathrm{tot}}_n({{\varvec{x}}})=\,\mathrm{Sym}\, \left\{ \sum _{n_1+\cdots n_m=n \atop n_k\ge 1} \Phi ^{\scriptscriptstyle \,\int }_m({{\varvec{x}}}') \prod _{k=1}^m \Phi ^{\,g}_{n_k}(x_{j_{k-1}+1},\ldots ,x_{j_k})\right\} . \end{aligned}$$
(4.3)

Here the sum runs over ordered partitions of n, whose number of parts is denoted by m, and we adopted notations from (2.17) for indices \(j_k\). The argument \({{\varvec{x}}}\) of the kernel encodes the electric components of the charges (shifted by the B-field and rescaled by \(\sqrt{2\tau _2}\)) and lives in a vector space \(\left( \oplus _{i=1}^n \Lambda _i\right) \otimes \mathbb {R}\) of dimension \(d=nb_2\), given by \(b_2\) copies of the lattice \(\Lambda \), where the i-th copy \(\Lambda _i\) carries the bilinear form \(\kappa _{i,ab}=\kappa _{abc}p_i^c\) of signature \((1,b_2-1)\). Therefore, \(\vartheta _{{{\varvec{p}}},{\varvec{\mu }}}\) is an indefinite theta series associated to the bilinear form given explicitly in (D.4), which has signature \((n,n(b_2-1))\).

Finally, the kernel (4.3) is constructed from two other functions. The first, \(\Phi ^{\scriptscriptstyle \,\int }_n\), is the iterated integral of the coefficient \({\mathcal {G}}_n\) in the expansion (3.25),

$$\begin{aligned} \Phi ^{\scriptscriptstyle \,\int }_n({{\varvec{x}}}) = \left( \frac{\sqrt{2\tau _2}}{2\pi }\right) ^{n-1} \left[ \prod _{i=1}^n\int _{\ell _{\gamma _i}}\frac{\mathrm {d}z_i}{2\pi } \, W_{p_i}(x_i,z_i)\right] {\mathcal {G}}_n(\{\gamma _i,z_i\}), \end{aligned}$$
(4.4)

weighted with the Gaussian measure factor

$$\begin{aligned} W_{p}(x,z)=e^{-2\pi \tau _2 z^2(pt^2)-2\pi \mathrm {i}\sqrt{2\tau _2}\, z\, (pxt)} \end{aligned}$$
(4.5)

coming from the z-dependent part of (3.13). Although this function is written in terms of \({\mathcal {G}}_n\) depending on full electromagnetic charge vectors \(\gamma _i\), it is actually independent of their \(q_0\) components. Indeed, using the result (3.26), it can be rewritten as

$$\begin{aligned} \Phi ^{\scriptscriptstyle \,\int }_n({{\varvec{x}}}) = \frac{1}{n!} \left[ \prod _{i=1}^n\int _{\ell _{\gamma _i}}\frac{\mathrm {d}z_i}{2\pi } \, W_{p_i}(x_i,z_i)\right] \sum _{{\mathcal {T}}\in \, \mathbb {T}_n^\ell }\prod _{e\in E_{\mathcal {T}}} {{\hat{K}}}_{s(e) t(e)}, \end{aligned}$$
(4.6)

where we introduced a rescaled version of the kernel (3.16)

$$\begin{aligned} {{\hat{K}}}_{ij}(z_i,z_j)=\left( \left( \sqrt{2\tau _2}\,t+\mathrm {i}\,\frac{x_i-x_j}{z_i-z_j}\right) p_ip_j\right) . \end{aligned}$$
(4.7)

Note that \(\tau _2\) and \(t^a\) appear only in the modular invariant combination \(\sqrt{2\tau _2}\, t^a\). In (4.3) this function appears with the argument \({{\varvec{x}}}'\) and carries a dependence on \({{\varvec{p}}}'\) (not indicated explicitly) which are both \(mb_2\)-dimensional vectors with components (cf. (2.17))

$$\begin{aligned} p'^a_k=\sum _{i=j_{k-1}+1}^{j_k}p^a_i, \qquad x'^a_k=\kappa '^{ab}_k\sum _{i=j_{k-1}+1}^{j_k} \kappa _{i,bc} x^c_i, \end{aligned}$$
(4.8)

where \(\kappa '_{k,ab}=\kappa _{abc}p'^c_k\).

The second function, \(\Phi ^{\,g}_{n}\), appears due to the expansion of DT invariants in terms of the MSW invariants and is given by a suitably rescaled tree index

$$\begin{aligned} \Phi ^{\,g}_{n}({{\varvec{x}}})=\frac{\sigma _{\gamma }(\sqrt{2\tau _2})^{n-1}}{\prod _{i=1}^n\sigma _{\gamma _i}}\,g_{\mathrm{tr},n}(\{\gamma _i,c_i\}). \end{aligned}$$
(4.9)

It is also written in terms of functions depending on the full electromagnetic charge vectors \(\gamma _i\) (with \(\gamma =\gamma _1+\cdots \gamma _n\)). However, using (3.4), all quadratic refinements can be expressed through \((-1)^{\langle \gamma _i,\gamma _j\rangle }\) which cancel the corresponding sign factors in the tree index (see (2.7)). Furthermore, as was noticed in the end of Sect. 2.3, the tree index is independent of the \(q_0\) components of the charge vectors. Therefore, it can be written as a function of \(p_i^a\), \(\mu _{i,a}\) and \(x_i^a=\sqrt{2\tau _2}(\kappa _i^{ab} q_{i,b}+b^a)\). Then, since after cancelling the sign factors, \(g_{\mathrm{tr},n}\) becomes a homogeneous function of degree \(n-1\) in the D2-brane charge \(q_{i,a}\), all factors of \(\sqrt{2\tau _2}\) in (4.9) cancel as well.

4.2 Modularity and Vignéras’ equation

As explained in appendix D.1, the theta series \(\vartheta _{{{\varvec{p}}},{\varvec{\mu }}}\bigl (\Phi ,\lambda \bigr )\) is a vector-valued modular form of weight \((\lambda +d/2,0)\) provided the kernel \(\Phi \) satisfies Vignéras’ equation (D.3)—along with certain growth conditions which we expect to be automatically satisfied for the kernels of interest in this work. In our case \(\lambda =n-2\) and the dimension of the lattice is \(d=nb_2({\mathfrak {Y}})\) so that the expected weight of the theta series is \((n-2+nb_2/2,0)\). It is consistent with weight \((-\tfrac{3}{2},\tfrac{1}{2})\) of \({\mathcal {G}}\) given in (4.2) only if \(h_{p,\mu }\) is a vector-valued holomorphic modular form of weight \((-b_2/2-1,0)\). However for this to be true, the kernel \(\Phi ^{\mathrm{tot}}_n\) ought to satisfy Vignéras’ equation. Let us examine whether or not this is the case.

To this end, we first consider the kernel \(\Phi ^{\scriptscriptstyle \,\int }_n\) (4.6). In appendix E we evaluate explicitly the iterated integrals defining this kernel. To present the final result, let us introduce the following d-dimensional vectors \({{\varvec{v}}}_{ij}, {{\varvec{u}}}_{ij}\):

$$\begin{aligned} \begin{aligned} ({{\varvec{v}}}_{ij})_k^a&= \delta _{ki} p_j^a-\delta _{kj} p_i^a&\text{ such } \text{ that } \quad {{\varvec{v}}}_{ij}\cdot {{\varvec{x}}}=(p_ip_j(x_i-x_j)), \\ ({{\varvec{u}}}_{ij})_k^a&= \delta _{ki}(p_jt^2)t^a-\delta _{kj} (p_it^2)t^a&\text{ such } \text{ that }\quad {{\varvec{u}}}_{ij}\cdot {{\varvec{x}}}=(p_jt^2)(p_ix_it)-(p_it^2)(p_jx_jt), \end{aligned}\nonumber \\ \end{aligned}$$
(4.10)

where k labels the copy in \(\oplus _{k=1}^n \Lambda _k\), \(a=1,\ldots , b_2\), and the bilinear form is given in (D.4). The first scalar product \({{\varvec{v}}}_{ij}\cdot {{\varvec{x}}}\) corresponds to the DSZ product \(\langle \gamma _i,\gamma _j\rangle \), whereas the second product \({{\varvec{u}}}_{ij}\cdot {{\varvec{x}}}\) corresponds to \(-2\,\mathrm{Im}\,[Z_{\gamma _i}{\bar{Z}}_{\gamma _j}]\) (2.24), both rescaled by \(\sqrt{2\tau _2}\) and expressed in terms of \(x_i^a\). From these vectors we can construct two sets of vectors which are assigned to the edges of an unrooted labelled tree \({\mathcal {T}}\), such as the trees appearing in (3.26) and (4.6). Namely,

$$\begin{aligned} {{\varvec{v}}}_e=\sum _{i\in V_{{\mathcal {T}}_e^s}}\sum _{j\in V_{{\mathcal {T}}_e^t}}{{\varvec{v}}}_{ij}, \qquad {{\varvec{u}}}_e=\sum _{i\in V_{{\mathcal {T}}_e^s}}\sum _{j\in V_{{\mathcal {T}}_e^t}}{{\varvec{u}}}_{ij}, \end{aligned}$$
(4.11)

where \({\mathcal {T}}_e^s\), \({\mathcal {T}}_e^t\) are the two disconnected trees obtained from the tree \({\mathcal {T}}\) by removing the edge e. Then the kernel \(\Phi ^{\scriptscriptstyle \,\int }_n\) can be expressed as followsFootnote 21

$$\begin{aligned} \Phi ^{\scriptscriptstyle \,\int }_n({{\varvec{x}}})= \frac{\Phi ^{\scriptscriptstyle \,\int }_1(x)}{2^{n-1} n!}\sum _{{\mathcal {T}}\in \, \mathbb {T}_n^\ell } {\widetilde{\Phi }}^M_{n-1}(\{ {{\varvec{u}}}_e\}, \{{{\varvec{v}}}_{s(e) t(e)}\};{{\varvec{x}}}). \end{aligned}$$
(4.12)

Here the first factor is simply a Gaussian

$$\begin{aligned} \Phi ^{\scriptscriptstyle \,\int }_1(x)=\frac{e^{-\frac{\pi (pxt)^2}{(pt^2)}}}{2\pi \sqrt{2\tau _2(pt^2)}} \end{aligned}$$
(4.13)

which ensures the suppression along the direction of the total charge in the charge lattice. In the second factor one sums over unrooted labelled trees \({\mathcal {T}}\) with n vertices, with summand given by a function \({\widetilde{\Phi }}^M_n\) defined as in (D.17), upon replacing \(\Phi _n^E\) by \(\Phi _n^M\) in that expression and setting \(m=n\). Both \(\Phi _n^E\) and \(\Phi _n^M\) are the so-called generalized (complementary) error functions introduced in [28] and further studied in [29], whose definitions are recalled in (D.10), (D.11) and (D.14). The functions \({\widetilde{\Phi }}^M_{n-1}\) in (4.12) depend on two sets of \(n-1\)d-dimensional vectors: the vectors in the first set are given by \({{\varvec{u}}}_e\) defined above, whereas the vectors \({{\varvec{v}}}_{s(e) t(e)}\) in the second set coincide with \({{\varvec{v}}}_{ij}\) for i and j corresponding to the source and target vertices of edge e of the labelled tree.

The remarkable property of the generalized error functions \(\Phi ^M_{n-1}\) and their uplifted versions \({\widetilde{\Phi }}^M_{n-1}\) is that, away from certain loci where these functions are discontinuous, they satisfy Vignéras’ equation for \(\lambda =0\) and \(n-1\), respectively. Given that \(\Phi ^{\scriptscriptstyle \,\int }_1\) is also a solution for \(\lambda =-1\), and the vector \({{\varvec{t}}}=(t^a,\ldots ,t^a)\) (such that \({{\varvec{t}}}\cdot {{\varvec{x}}}=(pxt)\)) is orthogonal to all vectors \({{\varvec{u}}}_e\) and \({{\varvec{v}}}_{s(e) t(e)}\), the kernel (4.12) satisfies this equation for \(\lambda =n-2\).

However, as mentioned above, it fails to do so on the loci where it is discontinuous. These discontinuities arise due to dependence of the integration contours \(\ell _\gamma \) on moduli and electric charges. Of course, since the integrands are meromorphic functions, the integrals do not depend on deformations of the contours provided they do not cross the poles. But this is exactly what happens when two BPS rays, say \(\ell _\gamma \) and \(\ell _{\gamma '}\), exchange their positions, which in turn takes place when the phases of the corresponding central charges \(Z_\gamma \) and \(Z_{\gamma '}\) align, as follows from (3.3). The loci where such alignment takes place are nothing else but the walls of marginal stability. This point will play an important rôle in the next subsection since it makes it possible to recombine the discontinuities of the generalized error functions with discontinuities of the tree indices.

We now turn to the action of Vignéras’ operator on \(\Phi ^{\,g}_{n}\). To this end, it is convenient to use the representation of the tree index as a sum over attractor flow trees (2.3). Let us assign a \(nb_2\)-dimensional vector \({\tilde{{{\varvec{v}}}}}_{v}\) to each vertex v of a flow tree. Denoting by \({\mathcal {I}}_v\) the set of leaves which are descendants of vertex v, we set

$$\begin{aligned} {\tilde{{{\varvec{v}}}}}_v=\sum _{i\in {\mathcal {I}}_{L(v)}}\sum _{j\in {\mathcal {I}}_{R(v)}}{{\varvec{v}}}_{ij}. \end{aligned}$$
(4.14)

With these definitions the kernel (4.9) can be written as

$$\begin{aligned} \Phi ^{\,g}_n({{\varvec{x}}})= & {} (-1)^{n-1}\sum _{T\in \mathbb {T}_n^{\mathrm{af}}}\prod _{v\in V_T} ({\tilde{{{\varvec{v}}}}}_v,{{\varvec{x}}})\, \Delta _{\gamma _{L(v)}\gamma _{R(v)}}^{z_{p(v)}}. \end{aligned}$$
(4.15)

The factors \(\Delta _{\gamma _L\gamma _R}^z\) are locally constant and therefore, away from the loci where they are discontinuous, the action of Vignéras operator reduces to its action on the scalar products \(({\tilde{{{\varvec{v}}}}}_v,{{\varvec{x}}})\). For a single such factor one finds

$$\begin{aligned} V_\lambda ({\tilde{{{\varvec{v}}}}}_v,{{\varvec{x}}})=({\tilde{{{\varvec{v}}}}}_v,{{\varvec{x}}})V_{\lambda -1}+2{\tilde{{{\varvec{v}}}}}_v\cdot \partial _{{\varvec{x}}}. \end{aligned}$$
(4.16)

The crucial observation is that all vectors \({\tilde{{{\varvec{v}}}}}_v\) appearing in the product (4.15) for a single tree are mutually orthogonal \(({\tilde{{{\varvec{v}}}}}_v,{\tilde{{{\varvec{v}}}}}_{v'})=0\), which is clear because \(\langle \gamma _{L(v)},\gamma _{R(v)}\rangle \) is antisymmetric in charges \(\gamma _{L(v)},\gamma _{R(v)}\), whereas the factors associated with vertices which are not descendants of v either depend on their sum or do not depend on them at all. Therefore, one obtains

$$\begin{aligned} V_\lambda \Phi ^{\,g}_{n_k}({{\varvec{x}}})=\Phi ^{\,g}_{n_k}({{\varvec{x}}})V_{\lambda -n_k+1}+ 2(-1)^{n_k-1}\sum _{T\in \mathbb {T}_{n_k}^{\mathrm{af}}}\Delta (T)\sum _{v\in V_T}\left[ \prod _{v'\in V_T{\setminus } \{v\}}({\tilde{{{\varvec{v}}}}}_{v'},{{\varvec{x}}})\right] {\tilde{{{\varvec{v}}}}}_v\cdot \partial _{{\varvec{x}}}.\nonumber \\ \end{aligned}$$
(4.17)

Let us now evaluate the action of \(V_{n-2}\) on the full kernel \(\Phi ^{\mathrm{tot}}_n\). Applying the result (4.17), we observe that the second term vanishes on the other factors in (4.3) due to the same reason that they either do not depend (in the case of \(\Phi ^{\,g}_{n_{k'}}\), \(k'\ne k\)) or depend (in the case of \(\Phi ^{\scriptscriptstyle \,\int }_{m}\)) only on the sum of charges entering \(\Phi ^{\,g}_{n_k}\). Therefore, one finds that, away from discontinuities of generalized error functions and\(\Delta (T)\), one has \(V_{n-2}\cdot \Phi ^{\mathrm{tot}}_n=0\).

4.3 Discontinuities and the anomaly

Let us now turn to the discontinuities of \(\Phi ^{\mathrm{tot}}_n\) which we ignored so far and which spoil Vignéras’ equation and hence modularity of the theta series. There are three potential sources of such discontinuities:

  1. 1.

    walls of marginal stability—at these loci \(\Phi ^{\scriptscriptstyle \,\int }_{m}\) are discontinuous due to exchange of integration contours and \(\Phi ^{\,g}_{n_k}\) jump due to factors \(\Delta _{\gamma _{L(v)}\gamma _{R(v)}}^{z_{p(v)}}\) assigned to the root vertices of attractor flow trees;

  2. 2.

    ‘fake walls’—these are loci in the moduli space where \(\,\mathrm{Im}\,\bigl [ Z_{\gamma _{L(v)}}{\bar{Z}}_{\gamma _{R(v)}}(z^a_{p(v)})\bigr ]=0\), and hence the corresponding \(\Delta \)-factor jumps, where v is not a root vertex—they correspond to walls of marginal stability for the intermediate bound states appearing in the attractor flow;

  3. 3.

    moduli independent loci where \(({\tilde{{{\varvec{v}}}}}_v,{{\varvec{x}}})=0\)—at these loci the factors \(\Delta _{\gamma _{L(v)}\gamma _{R(v)}}^{z_{p(v)}}\) and hence \(\Phi ^{\,g}_{n_k}\) are discontinuous due to the second term in (2.4).

Remarkably, the two effects due to the non-trivial charge and moduli dependence of the DT invariants and the exchange of contours cancel each other and the function \({\mathcal {G}}\) turns out to be smooth at loci of the first type. This is expected because the whole construction of D-instantons has been designed to make the resulting metric on the moduli space smooth across these loci, which required the cancellation of these discontinuities [40, 41]. Moreover, in [42] it was proven that the contact potential is also smooth, which indicates that the function \({\mathcal {G}}\) must be smooth as well. In appendix C we present an explicit proof of this fact based on the representation in terms of trees.

Furthermore, in [23] it was shown that the discontinuities across ‘fake walls’ cancel in the sum over flow trees as well. In fact, this cancellation is explicit in the representation of the partial tree index given by the recursive formula (2.16) where the signs responsible for such ‘fake discontinuities’ do not arise at all. As a result, it remains to consider only the discontinuities of the third type corresponding to the moduli independent loci.

It is straightforward to check that already for \(n=2\) these discontinuities are indeed present and do spoil modularity of the theta series. For small n one can explicitly evaluate the anomaly in Vignéras’ equation. It is given by a series of terms proportional to \(\delta ({\tilde{{{\varvec{v}}}}}_v,{{\varvec{x}}})\). Note that no derivatives of delta functions or products of two delta functions arise despite the presence of the second derivative in Vignéras’ operator. This is because each \(\mathrm{sgn}({\tilde{{{\varvec{v}}}}}_v,{{\varvec{x}}})\) from \(\Delta (T)\) is multiplied by \(({\tilde{{{\varvec{v}}}}}_v,{{\varvec{x}}})\) from \(\kappa (T)\) in (2.3) and one gets a non-vanishing result only if the second order derivative operator acts on both factors. In particular, this implies that the anomaly is completely characterized by the action of \(V_\lambda \) on \(\Phi ^{\,g}_{n}\).

5 Modular Completion

Since the theta series \(\vartheta _{{{\varvec{p}}},{\varvec{\mu }}}(\Phi ^{\mathrm{tot}}_{n})\) are not modular for \(n\ge 2\), the analysis of the previous section implies that the generating function \(h_{p,\mu }\) of the MSW invariants is not modular either whenever the divisor \({\mathcal {D}}=p^a\gamma _a\) is the sum of \(n\ge 2\) irreducible divisors. However, its modular anomaly has a definite structure. In particular, in [14] it was shown that for \(n=2\), \(h_{p,\mu }\) must be a vector-valued mixed mock modular form, i.e. it has a non-holomorphic completion \({\widehat{h}}_{p,\mu }\) constructed in a specific way from a set of holomorphic modular forms and their Eichler integrals [13, 35]. In this section we generalize this result for arbitrary n, i.e. for any degree of reducibility of the divisor.

5.1 Completion of the generating function

Let us recall the notations \({{\check{\gamma }}}=(p^a,q_a)\) and \(Q_n\) from (2.32), and decompose the electric component \(q_a\) using spectral flow as in (2.26). Then we define

$$\begin{aligned} {\widehat{h}}_{p,\mu }(\tau )= h_{p,\mu }(\tau ) +\sum _{n=2}^\infty \sum _{\sum _{i=1}^n {{\check{\gamma }}}_i={{\check{\gamma }}}} R_n(\{{{\check{\gamma }}}_i\},\tau _2) \, e^{\pi \mathrm {i}\tau Q_n(\{{{\check{\gamma }}}_i\})} \prod _{i=1}^n h_{p_i,\mu _i}(\tau ). \end{aligned}$$
(5.1)

We are looking for non-holomorphic functions \(R_n\), exponentially suppressed for large \(\tau _2\), such that \({\widehat{h}}_{p,\mu }\) transforms as a modular form. The condition for this to be true can be found along the same lines as before: one needs to rewrite the expansion of the function \({\mathcal {G}}\) as a series in \({\widehat{h}}_{p,\mu }\) and require that at each order the coefficient is given by a modular covariant theta series. For such a theta series decomposition to be possible however, it is important that \({\widehat{h}}_{p,\mu }\) be invariant under the spectral flow, which implies that the functions \(R_n\) be independent of the spectral flow parameter \(\epsilon ^a\) in the decomposition (2.26) of the total charge \({{\check{\gamma }}}\).Footnote 22 This condition will be an important consistency requirement on our construction.

Rather than inverting (5.1) and substituting the result into (4.2), we can consider the generating function of DT invariants \(h^{\mathrm{DT}}_{p,\mu }\) and, as a first step, rewrite it as a series in \({\widehat{h}}_{p,\mu }\). Denoting the coefficient of such expansion by \({\widehat{g}}_n(\{{{\check{\gamma }}}_i\},z^a)\) (with \({\widehat{g}}_1\equiv 1\)), we get

$$\begin{aligned} \begin{aligned} h^{\mathrm{DT}}_{p,q}(\tau ,z^a)=&\, \sum _{\sum _{i=1}^n {{\check{\gamma }}}_i={{\check{\gamma }}}} {\widehat{g}}_n(\{{{\check{\gamma }}}_i\};z^a, \tau _2) \,e^{\pi \mathrm {i}\tau Q_n(\{{{\check{\gamma }}}_i\})} \prod _{i=1}^n {\widehat{h}}_{p_i,\mu _i}(\tau ). \end{aligned} \end{aligned}$$
(5.2)

Comparing with (2.31), we see that the coefficients \({\widehat{g}}_n\) are a direct analogue of the tree index \(g_{\mathrm{tr},n}\).Footnote 23 The expansion of \({\mathcal {G}}\) in terms of \({\widehat{h}}_{p,\mu }\) is then simply obtained by replacing \(g_{\mathrm{tr},n}\) by \({\widehat{g}}_n\) in (4.9), which affects the kernel of the corresponding theta series. Our first problem is to express these coefficients in terms of the functions \(R_n\).

The result can be nicely formulated using so-called Schröder trees, which are rooted ordered trees such that all vertices (except the leaves) have at least 2 children (see Fig. 4). Their vertices are decorated by charges in such way that the leaves have charges \(\gamma _i\), whereas the charges at other vertices are defined by the inductive rule \(\gamma _v=\sum _{v'\in \mathrm{Ch}(v)}\gamma _{v'}\) where \(\mathrm{Ch}(v)\) is the set of children of vertex v. Note that these trees should not be confused with flow trees, since they are not restricted to be binary nor do they carry moduli at the vertices. We denote the set of Schröder treesFootnote 24 with n leaves by \(\mathbb {T}_n^{\mathrm{S}}\).

Fig. 4
figure 4

An example of Schröder tree contributing to \(W_8\). Near each vertex we showed the corresponding factor using the shorthand notation \(\gamma _{i+j}=\gamma _i+\gamma _j\)

Let us also introduce a convenient notation: for any set of functions \(f_n(\{{{\check{\gamma }}}_i\})\) depending on n charges and a given Schröder tree T, we set \(f_{v}\equiv f_{k_v}(\{{{\check{\gamma }}}_{v'}\})\) where \(v'\in \mathrm{Ch}(v)\) and \(k_v\) is their number. Using these notations, the expression of \({\widehat{g}}_n\) in terms of \(R_n\) can be encoded into a recursive equation provided by the following proposition, whose proof we relegate to appendix F:

Proposition 1

The coefficients \({\widehat{g}}_n\) are determined recursively by the following equation

$$\begin{aligned} {\widehat{g}}_n(\{{{\check{\gamma }}}_i,c_i\})= & {} -{1\over 2}\,\mathrm{Sym}\, \left\{ \sum _{\ell =1}^{n-1} \Delta _{\gamma _L^\ell \gamma _R^\ell }^z\,\kappa (\gamma _{LR}^\ell )\, {\widehat{g}}_\ell (\{{{\check{\gamma }}}_i,c_i^{(\ell )}\}_{i=1}^\ell )\,{\widehat{g}}_{n-\ell }(\{{{\check{\gamma }}}_i,c_i^{(\ell )}\}_{i=\ell +1}^n)\right\} \nonumber \\&+W_n(\{{{\check{\gamma }}}_i\}), \end{aligned}$$
(5.3)

where \(\gamma _L^\ell =\sum _{i=1}^\ell \gamma _i\), \(\gamma _R^\ell =\sum _{i=\ell +1}^n\gamma _i\), \(\gamma _{LR}^\ell =\langle \gamma _L^\ell ,\gamma _R^\ell \rangle \), \(c_i^{(\ell )}\) are the stability parameters at the point where the attractor flow crosses the wall for the decay \(\gamma \rightarrow \gamma _L^\ell +\gamma _R^\ell \) (cf. (2.14)), and \(W_n\) are functions given by the sum over Schröder trees

$$\begin{aligned} W_n(\{{{\check{\gamma }}}_i\})= \,\mathrm{Sym}\, \left\{ \sum _{T\in \mathbb {T}_n^\mathrm{S}}(-1)^{n_T}\prod _{v\in V_T} R_{v}\right\} , \end{aligned}$$
(5.4)

with \(n_T\) being the number of vertices of the tree T (excluding the leaves). The same functions \(W_n\) also provide the inverse formula to (5.1), namely

$$\begin{aligned} h_{p,\mu }(\tau )= {\widehat{h}}_{p,\mu }(\tau ) +\sum _{n=2}^\infty \sum _{\sum _{i=1}^n {{\check{\gamma }}}_i={{\check{\gamma }}}} W_n(\{{{\check{\gamma }}}_i\}) \, e^{\pi \mathrm {i}\tau Q_n(\{{{\check{\gamma }}}_i\})} \prod _{i=1}^n {\widehat{h}}_{p_i,\mu _i}(\tau ). \end{aligned}$$
(5.5)

What are the conditions on \({\widehat{g}}_n\) for the corresponding theta series to be modular? Let us denote by \(\Phi ^{\,{\widehat{g}}}_{n}\) the kernel defined by \({\widehat{g}}_n\) analogously to (4.9), namely

$$\begin{aligned} \Phi ^{\,{\widehat{g}}}_{n}({{\varvec{x}}})=\frac{\sigma _{\gamma }(\sqrt{2\tau _2})^{n-1}}{\prod _{i=1}^n\sigma _{\gamma _i}}\,{\widehat{g}}_n(\{\gamma _i,c_i\}). \end{aligned}$$
(5.6)

Then the above analysis implies that the modularity requires \(\Phi ^{\,{\widehat{g}}}_{n}\) to satisfy Vignéras equation away from walls of marginal stability, whereas at these walls its discontinuities should follow the same pattern as before in order to cancel the discontinuities from the contour exchange in \(\Phi ^{\scriptscriptstyle \,\int }_m\). Thus, the completion should smoothen out the discontinuities from the moduli independent signs \(\mathrm{sgn}({\tilde{{{\varvec{v}}}}}_v,{{\varvec{x}}})\), but otherwise leave the action of Vignéras’ operator unchanged. Formally, this means that \(\Phi ^{\,{\widehat{g}}}_{n}\) must satisfy the following equation

$$\begin{aligned} V_{n-1} \cdot \Phi ^{\,{\widehat{g}}}_{n}= & {} \,\mathrm{Sym}\, \sum _{\ell =1}^{n-1} \Bigl [{{\varvec{u}}}_\ell ^2\,\Delta _{n,\ell }^{{\widehat{g}}} \,\delta '({{\varvec{u}}}_\ell \cdot {{\varvec{x}}}) + 2{{\varvec{u}}}_\ell \cdot \partial _{{\varvec{x}}}\Delta _{n,\ell }^{{\widehat{g}}} \,\delta ({{\varvec{u}}}_\ell \cdot {{\varvec{x}}})\Bigr ], \qquad \nonumber \\ \Delta _{n,\ell }^{{\widehat{g}}}= & {} \frac{1}{2}\,({{\varvec{v}}}_\ell ,{{\varvec{x}}})\,\Phi ^{\,{\widehat{g}}}_\ell \,\Phi ^{\,{\widehat{g}}}_{n-\ell }, \end{aligned}$$
(5.7)

where we introduced two sets of vectors constructed from the vectors (4.10),

$$\begin{aligned} {{\varvec{v}}}_\ell =\sum _{i=1}^\ell \sum _{j=\ell +1}^n{{\varvec{v}}}_{ij}\,, \qquad {{\varvec{u}}}_\ell =\sum _{i=1}^\ell \sum _{j=\ell +1}^n{{\varvec{u}}}_{ij}\,.\nonumber \\ \end{aligned}$$
(5.8)

Note that \(({{\varvec{v}}}_\ell ,{{\varvec{x}}})\) and \(({{\varvec{u}}}_\ell ,{{\varvec{x}}})\) correspond to the quantities \(-\Gamma _{n\ell }\) and \(-S_\ell \) (2.13), respectively.

To solve the above constraints, let us consider the following iterative ansatz

$$\begin{aligned} {\widehat{g}}_n(\{{{\check{\gamma }}}_i,c_i\})= & {} g^{(0)}_n(\{{{\check{\gamma }}}_i,c_i\})\nonumber \\&-\,\mathrm{Sym}\, \left\{ \sum _{n_1+\cdots +n_m= n\atop n_k\ge 1, \ m<n} {\widehat{g}}_m(\{{{\check{\gamma }}}'_k,c'_k\}) \prod _{k=1}^m {\mathcal {E}}_{n_k}({{\check{\gamma }}}_{j_{k-1}+1},\ldots ,{{\check{\gamma }}}_{j_{k}}) \right\} , \qquad \end{aligned}$$
(5.9)

where the notations for indices and primed variables are the same as in (2.17). This ansatz is motivated by analogy with the iterative equation for the (partial) tree index (2.16). It involves two functions to be determined below, \(g^{(0)}_n\) and \({\mathcal {E}}_{n}\). The former depend on the moduli through the variables \(c_i\) (2.6), whereas the latter are moduli independent. We set \(g^{(0)}_1={\mathcal {E}}_1=1\) and also assume that \(g^{(0)}_n\) have discontinuities only at walls of marginal stability, i.e. at \(\sum _{i\in {\mathcal {I}}} c_i=0\) for various subsets \({\mathcal {I}}\) of indices.

The unknown functions \(g^{(0)}_n\) and \({\mathcal {E}}_{n}\) together with the functions \(R_n\) defining the completion, or their combinations (5.4), are fixed by the conditions (5.3) and (5.7). In appendix F we prove the following result:

Proposition 2

Let us split \({\mathcal {E}}_n={\mathcal {E}}^{(0)}_n+{\mathcal {E}}^{(+)}_n\) into \({\mathcal {E}}^{(+)}_n\), which is the part exponentially decreasing for large \(\tau _2\), and the non-decreasing remainder \({\mathcal {E}}^{(0)}_n\). Then the ansatz (5.9) satisfies the recursive equation (5.7) provided

  1. 1.

    the functions \(g^{(0)}_n\) are subject to a similar recursive relation

    $$\begin{aligned}&\frac{1}{4}\,\mathrm{Sym}\, \left\{ \sum _{\ell =1}^{n-1} \bigl ( \mathrm{sgn}(S_\ell )-\mathrm{sgn}(\Gamma _{n\ell })\bigr )\, \kappa (\Gamma _{n\ell })\, g^{(0)}_{\ell }(\{{{\check{\gamma }}}_i,c^{(\ell )}_i\}_{i=1}^\ell )\, g^{(0)}_{n-\ell }(\{{{\check{\gamma }}}_i,c^{(\ell )}_i\}_{i=\ell +1}^n) \right\} \nonumber \\&\quad =g^{(0)}_n(\{{{\check{\gamma }}}_i,c_i\})-g^{(0)}_n(\{{{\check{\gamma }}}_i,\beta _{ni}\}), \end{aligned}$$
    (5.10)

    where \(S_k\), \(\beta _{k\ell }\), \(\Gamma _{k\ell }\) and \(c^{(\ell )}_i\) were defined in (2.13), (2.15);

  2. 2.

    the non-decreasing part of \({\mathcal {E}}_n\) is fixed in terms of \(g^{(0)}_n(\{{{\check{\gamma }}}_i,c_i\})\) as

    $$\begin{aligned} {\mathcal {E}}^{(0)}_n(\{{{\check{\gamma }}}_i\})=g^{(0)}_n(\{{{\check{\gamma }}}_i,\beta _{ni}\}); \end{aligned}$$
    (5.11)
  3. 3.

    its decreasing part is given by

    $$\begin{aligned} {\mathcal {E}}^{(+)}_n(\{{{\check{\gamma }}}_i\})=-\,\mathrm{Sym}\, \left\{ \sum _{n_1+\cdots +n_m= n\atop n_k\ge 1, \ m>1} W_m(\{{{\check{\gamma }}}'_k\}) \prod _{k=1}^m {\mathcal {E}}_{n_k}({{\check{\gamma }}}_{j_{k-1}+1},\ldots ,{{\check{\gamma }}}_{j_{k}})\right\} . \qquad \end{aligned}$$
    (5.12)

Furthermore, provided the functions \({\mathcal {E}}_n\) depend on electric charges \(q_{i,a}\) only through the DSZ products \(\gamma _{ij}\) and their kernels \(\Phi ^{\,{\mathcal {E}}}_n({{\varvec{x}}})\) defined as in (4.9) are smooth solutions of Vignéras’ equation,

$$\begin{aligned} V_{n-1}\cdot \Phi ^{\,{\mathcal {E}}}_n=0, \end{aligned}$$
(5.13)

then the ansatz (5.9) also satisfies the modularity constraint (5.7).

This proposition allows in principle to fix all unknown functions. Indeed, the recursive relation (5.10) determines all \(g^{(0)}_n\). Then equations (5.11) and (5.12) give the two parts of \({\mathcal {E}}_n={\mathcal {E}}^{(0)}_n+{\mathcal {E}}^{(+)}_n\) in terms of \(g^{(0)}_n\) and \(W_n\). At this point the latter are still undetermined and are defined in terms of the unknown functions \(R_n\). The additional constraint that \({\mathcal {E}}_n\) should satisfy Vignéras’ equation links together \({\mathcal {E}}^{(0)}_n\) and \({\mathcal {E}}^{(+)}_n\) and thus establishes a relation between \(W_n\) and \(g^{(0)}_n\). Lastly, inverting (5.4) generates a solution for \(R_n\).

We end this discussion by making an observation which will become relevant in the next subsection: by comparing (5.2) and (2.31), it is clear that \({\widehat{g}}_n\) must agree with the tree index \(g_{\mathrm{tr},n}\) in the limit \(\tau _2\rightarrow \infty \). In particular, \(g_{\mathrm{tr},n}\) satisfies a similar ansatz as (5.9), upon replacing \({\mathcal {E}}_n\) by its non-decaying part:

$$\begin{aligned} g_{\mathrm{tr},n}(\{{{\check{\gamma }}}_i,c_i\})=g^{(0)}_n(\{{{\check{\gamma }}}_i,c_i\}) -\,\mathrm{Sym}\, \left\{ \sum _{n_1+\cdots +n_m= n\atop n_k\ge 1, \ m<n} g_{\mathrm{tr},m}(\{{{\check{\gamma }}}'_k,c'_k\}) \prod _{k=1}^m {\mathcal {E}}^{(0)}_{n_k} \right\} . \qquad \end{aligned}$$
(5.14)

It follows that the function \(g^{(0)}_n\) should be independent of \(\tau _2\), or at least that any such dependence should cancel in the recursion (5.14).

5.2 Generalized error functions and the completion

From the previous discussion, the first step in the construction of the modular completion is to provide an explicit expression for \(g^{(0)}_n\). Once such an expression is known, all other functions can be determined algebraically. The problem, however, is that the solution of the recursive relation (5.10) is not unique. On the other hand, \(g^{(0)}_n\) determines the non-decaying part \({\mathcal {E}}^{(0)}_n\) of \({\mathcal {E}}_n\), which is strongly constrained by the fact that \({\mathcal {E}}_n\) must satisfy Vignéras’ equation. This restriction turns out to be strong enough to remove the redundancy in the solution of (5.10), but it shows that we have to solve simultaneously two problems: satisfy the recursive relation (5.10) and ensure that it can be promoted to a solution of Vignéras’ equation. We will do this by first constructing a solution of Vignéras’ equation with the asymptotic part possessing the properties expected from \(g^{(0)}_n\), and then proving that it does satisfy the recursive relation.

A hint towards a solution of these two problems can be found by examining the form of the kernel \(\Phi ^{\scriptscriptstyle \,\int }_n\) (4.12). The point is that both \(\Phi ^{\scriptscriptstyle \,\int }_n\) and \(g^{(0)}_n\) have discontinuities at walls of marginal stability which, as we know, must cancel each other. Furthermore, they should recombine into a smooth solution of Vignéras’ equation. Thus, \(\Phi ^{\scriptscriptstyle \,\int }_n\) is expected to encode at least part of the completion of \(g^{(0)}_n\). In addition, as explained in appendix D.2, the function \({\widetilde{\Phi }}^M_{n-1}\), from which \(\Phi ^{\scriptscriptstyle \,\int }_n\) is constructed, appears as the term with fastest decay in the expansion similar to (D.15) of the function \({\widetilde{\Phi }}^E_{n-1}\) defined in (D.17) with the arguments \({\mathcal {V}}=\{ {{\varvec{u}}}_e\}\), \({\tilde{{\mathcal {V}}}}=\{{{\varvec{v}}}_{s(e) t(e)}\}\), which is a smooth solution of Vignéras’ equation. This motivates us to consider the following functionFootnote 25

$$\begin{aligned} G_n(\{{{\check{\gamma }}}_i,c_i\};\tau _2)= \frac{(-1)^{\sum _{i<j} \gamma _{ij} }}{(\sqrt{2\tau _2})^{n-1}}\, {\widetilde{\Phi }}^{(0)}_n({{\varvec{x}}}), \end{aligned}$$
(5.15)

where \({\widetilde{\Phi }}^{(0)}_n({{\varvec{x}}})\) denotes the large \({{\varvec{x}}}\) limit of the function

$$\begin{aligned} {\widetilde{\Phi }}_n({{\varvec{x}}})= \frac{1}{2^{n-1} n!}\sum _{{\mathcal {T}}\in \, \mathbb {T}_n^\ell } {\widetilde{\Phi }}^E_{n-1}(\{ {{\varvec{u}}}_e\}, \{{{\varvec{v}}}_{s(e) t(e)}\};{{\varvec{x}}}). \end{aligned}$$
(5.16)

Our first goal will be to evaluate this limit explicitly.

Fig. 5
figure 5

An example of marked unrooted tree belonging to \(\mathbb {T}_{7,4}^\ell \) where near each vertex we showed in red an integer counting marks

To express the result, we need to introduce two new types of trees, beyond those already encountered. First, we denote by \(\mathbb {T}_{n,m}^\ell \) the set of marked unrooted labelled trees with n vertices and m marks assigned to vertices (see Fig. 5). Let \(m_{\mathfrak {v}}\in \{0,\ldots m\}\) be the number of marks carried by the vertex \({\mathfrak {v}}\), so that \(\sum _{\mathfrak {v}}m_{\mathfrak {v}}=m\). Furthermore, the vertices are decorated by charges from the set \(\{\gamma _1,\ldots ,\gamma _{n+2m}\}\) such that a vertex \({\mathfrak {v}}\) with \(m_{\mathfrak {v}}\) marks carries \(1+2m_{\mathfrak {v}}\) charges \(\gamma _{{\mathfrak {v}},s}\), \(s=1,\ldots ,1+2m_{\mathfrak {v}}\) and we set \(\gamma _{\mathfrak {v}}=\sum _{s=1}^{1+2m_{\mathfrak {v}}}\gamma _{{\mathfrak {v}},s}\). Second, we define \(\mathbb {T}_{n}^{(3)}\) to be the set of (unordered, full) rooted ternary trees with n leaves decorated by charges \(\gamma _i\) and other vertices carrying charges defined by the inductive rule \(\gamma _v=\gamma _{d_1(v)}+\gamma _{d_3(v)}+\gamma _{d_3(v)}\) where \(d_r(v)\) are the three children of vertex v (see Fig. 6). As usual, \(V_T\) denotes the set of vertices, with cardinality \(|V_T|={1\over 2}(n-1)\) (not counting the leaves).

Fig. 6
figure 6

An example of rooted ternary tree belonging to \(\mathbb {T}_{9}^{(3)}\)

In terms of these notations, we then have the following result proven, in appendix F:

Proposition 3

The function (5.15) is given by

(5.17)

where, for each edge e joining the subtrees \({\mathcal {T}}_e^s\) and \({\mathcal {T}}_e^t\),

$$\begin{aligned} S_e=\sum _{i\in V_{{\mathcal {T}}_e^s}}c_i =\sum _{i\in V_{{\mathcal {T}}_e^s}}\sum _{j\in V_{{\mathcal {T}}_e^t}}\,\mathrm{Im}\,\bigl [ Z_{\gamma _i}{\bar{Z}}_{\gamma _j}\bigr ], \end{aligned}$$
(5.18)

and \({\mathcal {P}}_m\) is the weight corresponding to the marks, given by

$$\begin{aligned} {\mathcal {P}}_{m}(\{p_s\})=\sum _{T\in \, \mathbb {T}_{2m+1}^{(3)}}\frac{1}{T!}\prod _{v\in V_T}(p_{d_1(v)}p_{d_2(v)}p_{d_3(v)}). \end{aligned}$$
(5.19)

Here T! is the tree factorial

$$\begin{aligned} T!= \prod _{v\in V_T}n_v(T)\, , \end{aligned}$$
(5.20)

where \(n_v(T)\), as in Theorem 1, denotes the number of vertices (excluding the leaves) of the subtree of T rooted at v.

To demystify the origin of these structures, note that the sum over m in (5.17) arises because of the contributions coming from the mutual action of covariant derivative operators \({\mathcal {D}}({{\varvec{v}}}_{s(e) t(e)})\) (D.16) in the definition of the function \({\widetilde{\Phi }}^E_{n-1}\) (D.17). Such action is non-vanishing for any pair of intersecting edges \((e_1,e_2)\) and is proportional to \((p_{{\mathfrak {v}}_1}p_{{\mathfrak {v}}_2}p_{{\mathfrak {v}}_3})\) where \({\mathfrak {v}}_1,{\mathfrak {v}}_2,{\mathfrak {v}}_3\) are the three vertices belonging to the edges. While in appendix E it is shown that such contributions cancel in the sum over trees defining \(\Phi ^{\scriptscriptstyle \,\int }_n\) (4.12), this is not so for \({\widetilde{\Phi }}^{(0)}_n({{\varvec{x}}})\): instead of the identity (E.5), one has to apply the sign identity (F.20) which produces a constant term. As a result, instead of the standard sign factors assigned to \((e_1,e_2)\), one finds the weight factor \((p_{{\mathfrak {v}}_1}p_{{\mathfrak {v}}_2}p_{{\mathfrak {v}}_3})\). Furthermore, the sum over trees ensures that all other factors except for this weight depend on the charges \(\gamma _{{\mathfrak {v}}_1},\gamma _{{\mathfrak {v}}_2},\gamma _{{\mathfrak {v}}_3}\) only through their sum. One can keep track of such contributions by collapsing the corresponding pairs of edges on the tree and marking the remaining vertices with weights \(m_{\mathfrak {v}}\). Essentially, the only non-trivial point is to understand the form of the weight factor \({\mathcal {P}}_m\) for \(m>1\). In this case more than one pair of joint edges collapse. The representation (5.19) in terms of rooted ternary trees is obtained by collapsing m pairs of edges successively, where the coefficient 1 / T! takes into account that such procedure leads to an overcounting of different assignments of labels.

Fig. 7
figure 7

Three unrooted trees constructed from the same three subtrees

Unfortunately, the function (5.17) cannot yet be taken as an ansatz for \(g^{(0)}_n\) because it depends non-trivially on the modulus \(\tau _2\), which is in tension with the observation made at the end of the previous subsection. Therefore, we shall modify the function (5.16) into a function which is still a smooth solution of Vignéras’ equation, but whose large \({{\varvec{x}}}\) limit is independent of \(\tau _2\). Taking cue from the structure of (5.17), we defineFootnote 26

$$\begin{aligned} {\widetilde{\Phi }}^{\,{\mathcal {E}}}_n({{\varvec{x}}})= & {} \frac{1}{2^{n-1} n!}\sum _{m=0}^{[(n-1)/2]}\sum _{{\mathcal {T}}\in \, \mathbb {T}_{n-2m,m}^\ell } \left[ \prod _{{\mathfrak {v}}\in V_{\mathcal {T}}}{\mathcal {D}}_{m_{\mathfrak {v}}}(\{{{\check{\gamma }}}_{{\mathfrak {v}},s}\})\right] \nonumber \\&\times {\widetilde{\Phi }}^E_{n-2m-1}(\{ {{\varvec{u}}}_e\}, \{{{\varvec{v}}}_{s(e) t(e)}\};{{\varvec{x}}}), \end{aligned}$$
(5.21)

where

$$\begin{aligned} {\mathcal {D}}_{m}(\{{{\check{\gamma }}}_s\})=\sum _{{\mathcal {T}}'\in \, \mathbb {T}_{2m+1}^\ell } a_{{\mathcal {T}}'}\prod _{e\in E_{{\mathcal {T}}'}}{\mathcal {D}}({{\varvec{v}}}_{s(e)t(v)}). \end{aligned}$$
(5.22)

The coefficients \(a_{\mathcal {T}}\) are rational numbers which depend (up to a sign determined by the orientation of edges) only on the topology of the tree. We fix them by requiring that they satisfy the following system of equations

$$\begin{aligned} a_{{\hat{{\mathcal {T}}}}_1}+a_{{\hat{{\mathcal {T}}}}_2}-a_{{\hat{{\mathcal {T}}}}_3}=a_{{\mathcal {T}}_1}a_{{\mathcal {T}}_2}a_{{\mathcal {T}}_3}, \end{aligned}$$
(5.23)

where \({\mathcal {T}}_r\) (\(r=1,2,3\)) are arbitrary unrooted trees with marked vertex \({\mathfrak {v}}_r\) and \({\hat{{\mathcal {T}}}}_r\) are the three trees constructed from \({\mathcal {T}}_r\) as shown in Fig. 7.Footnote 27 This system of equations is imposed in order to ensure certain properties of the operators (5.22) which are crucial for the cancellation of \(\tau _2\)-dependent terms in the asymptotics of \({\widetilde{\Phi }}^{\,{\mathcal {E}}}_n\) (see (F.29)). It is readily seen that the system (5.23) fixes all coefficients \(a_{\mathcal {T}}\) recursively starting from \(a_\bullet =1\), \(a_{\bullet \!\text{- }\!\bullet }=0\) and going to trees with \(n\ge 3\) vertices. (Starting from \(n=7\), the system (5.23) is overdetermined, but it can be checked that it does have a unique solution, with \(a_{\mathcal {T}}=0\) for trees with even number of vertices.) For a generic tree, in appendix F we prove the following

Proposition 4

For a tree \({\mathcal {T}}\) with n vertices the coefficient \(a_{\mathcal {T}}\) is given recursively by

$$\begin{aligned} a_{\mathcal {T}}=\frac{1}{n}\sum _{{\mathfrak {v}}\in V_{\mathcal {T}}} \epsilon _{\mathfrak {v}}\prod _{s=1}^{n_{\mathfrak {v}}} a_{{\mathcal {T}}_s({\mathfrak {v}})}, \end{aligned}$$
(5.24)

where \(n_{\mathfrak {v}}\) is the valency of the vertex \({\mathfrak {v}}\), \({\mathcal {T}}_s({\mathfrak {v}})\) are the trees obtained from \({\mathcal {T}}\) by removing this vertex, and \(\epsilon _{\mathfrak {v}}\) is the sign determined by the choice of orientation of edges, \( \epsilon _{\mathfrak {v}}=(-1)^{n_{\mathfrak {v}}^+} \) with \(n_{\mathfrak {v}}^+\) being the number of incoming edges at the vertex. (See Fig. 8 for an example.)

Fig. 8
figure 8

An example of calculation of the coefficient \(a_{\mathcal {T}}\) for a tree with 7 vertices. We indicated in red the only vertices which produce non-vanishing contributions to the sum over vertices. For other vertices at least one of the trees \({\mathcal {T}}_s({\mathfrak {v}})\) has even number of vertices and hence vanishing coefficient

Let us now return to the function (5.21), which is now fully specified given the prescription (5.24) for the coefficients \(a_{\mathcal {T}}\). Similarly to (5.16) (which coincides with the \(m=0\) contribution in (5.21)), it is a solution of Vignéras’ equation for \(\lambda =n-1\). We claim that in the large \({{\varvec{x}}}\) asymptotics of this function, all \(\tau _2\)-dependent contributions, coming from the mutual action of derivative operators \({\mathcal {D}}\), cancel. More precisely, the asymptotics is given by the following

Proposition 5

$$\begin{aligned} \lim _{{{\varvec{x}}}\rightarrow \infty }{\widetilde{\Phi }}^{\,{\mathcal {E}}}_n({{\varvec{x}}})= & {} \frac{1}{2^{n-1} n!}\sum _{m=0}^{[(n-1)/2]} \sum _{{\mathcal {T}}\in \, \mathbb {T}_{n-2m,m}^\ell } \prod _{{\mathfrak {v}}\in V_{\mathcal {T}}}{\mathcal {V}}_{m_{\mathfrak {v}}}(\{{{\check{\gamma }}}_{{\mathfrak {v}},s}\}) \nonumber \\&\times \prod _{e\in E_{{\mathcal {T}}}}({{\varvec{v}}}_{s(e) t(e)},{{\varvec{x}}})\,\mathrm{sgn}({{\varvec{u}}}_e,{{\varvec{x}}}), \end{aligned}$$
(5.25)

where

$$\begin{aligned} {\mathcal {V}}_{m}(\{{{\check{\gamma }}}_{s}\}) =\sum _{{\mathcal {T}}\in \, \mathbb {T}_{2m+1}^\ell } a_{\mathcal {T}}\prod _{e\in E_{\mathcal {T}}}({{\varvec{v}}}_{s(e)t(v)},{{\varvec{x}}}). \end{aligned}$$
(5.26)

Importantly the function (5.25) is locally a homogeneous polynomial of degree \(n-1\). Therefore, when written in terms of charges, the \(\tau _2\)-dependence factorizes and is cancelled after the same rescaling as in (5.15). This naturally leads us to the following ansatz for the function \(g^{(0)}_n\), which we prove in appendix F:

Proposition 6

The function

$$\begin{aligned} g^{(0)}_n(\{{{\check{\gamma }}}_i,c_i\})= & {} \frac{(-1)^{n-1+\sum _{i<j} \gamma _{ij} }}{2^{n-1} n!} \sum _{m=0}^{[(n-1)/2]}\sum _{{\mathcal {T}}\in \, \mathbb {T}_{n-2m,m}^\ell } \prod _{{\mathfrak {v}}\in V_{\mathcal {T}}}{\tilde{{\mathcal {V}}}}_{m_{\mathfrak {v}}}(\{{{\check{\gamma }}}_{{\mathfrak {v}},s}\}) \nonumber \\&\times \prod _{e\in E_{{\mathcal {T}}}}\gamma _{s(e) t(e)}\,\mathrm{sgn}(S_e), \end{aligned}$$
(5.27)

where

$$\begin{aligned} {\tilde{{\mathcal {V}}}}_{m}(\{{{\check{\gamma }}}_{s}\})=\sum _{{\mathcal {T}}'\in \, \mathbb {T}_{2m+1}^\ell } a_{{\mathcal {T}}'}\prod _{e\in E_{{\mathcal {T}}'}}\gamma _{s(e)t(e)}, \end{aligned}$$
(5.28)

satisfies the recursive equation (5.10).

Note that the same recursive equation (5.10) is also obeyed by the contribution of unmarked trees (i.e. \(m=0\)) to \(g^{(0)}_n\), which we denote by \(g^{\star }_n\) (see (F.34)). However, the latter cannot be obtained as the large \({{\varvec{x}}}\) limit of a solution of Vignéras’ equation, which is why we have to consider the more complicated function (5.27).

Given the result for \(g^{(0)}_n\) and the relation (5.11), one obtains an explicit expression for the non-decreasing part of \({\mathcal {E}}_n\),

$$\begin{aligned} {\mathcal {E}}^{(0)}_n(\{{{\check{\gamma }}}_i\})= & {} \frac{(-1)^{\sum _{i<j} \gamma _{ij} }}{2^{n-1} n!} \sum _{m=0}^{[(n-1)/2]}\sum _{{\mathcal {T}}\in \, \mathbb {T}_{n-2m,m}^\ell } \prod _{{\mathfrak {v}}\in V_{\mathcal {T}}}{\tilde{{\mathcal {V}}}}_{m_{\mathfrak {v}}}(\{{{\check{\gamma }}}_{{\mathfrak {v}},s}\}) \nonumber \\&\times \prod _{e\in E_{{\mathcal {T}}}}\gamma _{s(e) t(e)}\,\mathrm{sgn}(\Gamma _e), \end{aligned}$$
(5.29)

where

$$\begin{aligned} \Gamma _e=\sum _{i\in V_{{\mathcal {T}}_e^s}}\sum _{j\in V_{{\mathcal {T}}_e^t}}\gamma _{ij}. \end{aligned}$$
(5.30)

From Proposition 2 we know that the kernel \(\Phi ^{\,{\mathcal {E}}}_n\) corresponding to the full function \({\mathcal {E}}_n\) must satisfy Vignéras’ equation and have the asymptotics captured by (5.29). But we already know a solution of Vignéras’ equation with a very similar asymptotics, namely the function (5.21), whose asymptotics differs only in the fact that the vectors \({{\varvec{v}}}_e\) are replaced by \({{\varvec{u}}}_e\). Since this replacement does not affect the proof of Vignéras’ equation, we immediately arrive at the following result:

$$\begin{aligned} {\mathcal {E}}_n(\{{{\check{\gamma }}}_i\};\tau _2)= \frac{(-1)^{\sum _{i<j} \gamma _{ij} }}{(\sqrt{2\tau _2})^{n-1}}\, \Phi ^{\,{\mathcal {E}}}_n({{\varvec{x}}}), \end{aligned}$$
(5.31)

where

$$\begin{aligned} \Phi ^{\,{\mathcal {E}}}_n({{\varvec{x}}})= & {} \frac{1}{2^{n-1} n!}\sum _{m=0}^{[(n-1)/2]} \sum _{{\mathcal {T}}\in \, \mathbb {T}_{n-2m,m}^\ell } \left[ \prod _{{\mathfrak {v}}\in V_{\mathcal {T}}}{\mathcal {D}}_{m_{\mathfrak {v}}}(\{{{\check{\gamma }}}_{{\mathfrak {v}},s}\})\right] \nonumber \\&\times {\widetilde{\Phi }}^E_{n-2m-1}(\{ {{\varvec{v}}}_e\}, \{{{\varvec{v}}}_{s(e) t(e)}\};{{\varvec{x}}}). \end{aligned}$$
(5.32)

In words, the function \({\mathcal {E}}_n\) is a sum over marked unrooted labelled trees of solutions of Vignéras equation with \(\lambda =n-1\), obtained from the standard generalized error functions \(\Phi ^E_{n-2m-1}\) by acting with \(n-1\) raising operators.

5.3 The structure of the completion

After substituting into the iterative ansatz (5.9), the two results (5.27) and (5.32) completely specify the coefficients of the expansion (5.2) of the generating function of DT invariants in terms of \({\widehat{h}}_{p,\mu }\). The result of the iteration can in fact be written explicitly as a sum over Schröder trees. Adopting the same notations as in Proposition 1, one has

Proposition 7

The function \({\widehat{g}}_n(\{{{\check{\gamma }}}_i,c_i\})\) is given by the sum over Schröder trees with n leaves,

$$\begin{aligned} {\widehat{g}}_n= \,\mathrm{Sym}\, \left\{ \sum _{T\in \mathbb {T}_n^{\mathrm{S}}}(-1)^{n_T-1} \left( g^{(0)}_{v_0}-{\mathcal {E}}_{v_0}\right) \prod _{v\in V_T{\setminus }{\{v_0\}}}{\mathcal {E}}_{v}\right\} , \end{aligned}$$
(5.33)

where \(v_0\) is the root of the tree.

We conclude that the properties of \(g^{(0)}_n\) and \({\mathcal {E}}_n\) ensure that the theta series appearing in the corresponding decomposition of \({\mathcal {G}}\) is modular so that the modularity of \({\mathcal {G}}\) requires the function \({\widehat{h}}_{p,\mu }\) to be a vector valued (non-holomorphic) modular form of weight \((-{1\over 2}b_2-1,0)\). The functions \(R_n\) entering the non-holomorphic completion \({\widehat{h}}_{p,\mu }\), are then given by the following proposition, whose proof can again be found in appendix F:

Proposition 8

Inverting the relations (5.4) and (5.12), one obtainsFootnote 28

$$\begin{aligned} R_n= \,\mathrm{Sym}\, \left\{ \sum _{T\in \mathbb {T}_n^{\mathrm{S}}}(-1)^{n_T-1} {\mathcal {E}}^{(+)}_{v_0}\prod _{v\in V_T{\setminus }{\{v_0\}}}{\mathcal {E}}^{(0)}_{v}\right\} . \end{aligned}$$
(5.34)

It is important to check that the resulting functions \(R_n\) are invariant under the spectral flow of the total charge. This is in fact a simple consequence of the fact that the functions \({\mathcal {E}}_n\) entering their definition depend on the electric charges only through the DSZ products \(\gamma _{ij}\). As follows from (2.24), all such products are invariant under the spectral flow of the total charge, hence \(R_n\) are invariant as well.

Since \({\mathcal {E}}^{(0)}_n\) are \(\tau _2\)-independent, all non-holomorphic dependence of \({\widehat{h}}_{p,\mu }\) comes from the factor \({\mathcal {E}}^{(+)}_{v_0}\) in the expression (5.34) for \(R_n\). Expressing the holomorphic anomaly in terms of the modular functions \({\widehat{h}}_{p_i,\mu _i}\), one obtains the following

Proposition 9

The holomorphic anomaly of the completion is given by

$$\begin{aligned} \partial _{{\bar{\tau }}}{\widehat{h}}_{p,\mu }(\tau )= \sum _{n=2}^\infty \sum _{\sum _{i=1}^n {{\check{\gamma }}}_i={{\check{\gamma }}}} {\mathcal {J}}_n(\{{{\check{\gamma }}}_i\},\tau _2) \, e^{\pi \mathrm {i}\tau Q_n(\{{{\check{\gamma }}}_i\})} \prod _{i=1}^n {\widehat{h}}_{p_i,\mu _i}(\tau ), \end{aligned}$$
(5.35)

where

$$\begin{aligned} {\mathcal {J}}_n= \frac{\mathrm {i}}{2}\,\mathrm{Sym}\, \left\{ \sum _{T\in \mathbb {T}_n^{\mathrm{S}}}(-1)^{n_T-1} \partial _{\tau _2}{\mathcal {E}}_{v_0}\prod _{v\in V_T{\setminus }{\{v_0\}}}{\mathcal {E}}_{v}\right\} . \end{aligned}$$
(5.36)

Note that this result is consistent with the fact that \(\tau _2^2\partial _{{\bar{\tau }}}{\widehat{h}}_{p,\mu }\) is a modular function of weight \((-{1\over 2}b_2-3,0)\). Indeed, the sum over D2-brane charges forms a theta series for a lattice of dimension \((n-1)b_2\) (see footnote 22) and quadratic form \(-Q_n\) of signature \((n-1,(n-1)(b_2-1))\). Furthermore, since

$$\begin{aligned} 2\tau _2\partial _{\tau _2}{\mathcal {E}}_n= \frac{(-1)^{\sum _{i<j} \gamma _{ij} }}{(\sqrt{2\tau _2})^{n-1}}\left( {{\varvec{x}}}\cdot \partial _{{\varvec{x}}}-(n-1)\right) \Phi ^{\,{\mathcal {E}}}_n({{\varvec{x}}}) \end{aligned}$$
(5.37)

and \(V_{\lambda -2}\left( {{\varvec{x}}}\cdot \partial _{{\varvec{x}}}-\lambda \right) = \left( {{\varvec{x}}}\cdot \partial _{{\varvec{x}}}-(\lambda -2)\right) V_\lambda \), the function \(\tau _2{\mathcal {J}}_n\) is a solution of Vignéras’ equation with \(\lambda =n-3\). Thus, after multiplying Eq. (5.35) by \(\tau _2^2\), the theta series generated by the sum over D2-brane charges is modular of weight \((\frac{n-1}{2}\, b_2+n-3,0)\). Combining it with n factors of \({\widehat{h}}_{p_i,\mu _i}\), one recovers the correct weight for \(\tau _2^2\partial _{{\bar{\tau }}}{\widehat{h}}_{p,\mu }\).

In appendix G we present explicit expressions for various elements of our construction up to order \(n=4\). Based on these results, we conjecture a general formula for the kernel \({\widehat{\Phi }}^{\mathrm{tot}}_n\) of the theta series appearing in the expansion of \({\mathcal {G}}\) in terms of \({\widehat{h}}_{p,\mu }\):

Conjecture 1

The instanton generating function has the theta series decomposition

$$\begin{aligned} {\mathcal {G}}=\sum _{n=1}^\infty \frac{2^{-\frac{n}{2}}}{\pi \sqrt{2\tau _2}}\left[ \prod _{i=1}^{n} \sum _{p_i,\mu _i}\sigma _{p_i}{\widehat{h}}_{p_i,\mu _i}\right] e^{-S^\mathrm{cl}_p}\vartheta _{{{\varvec{p}}},{\varvec{\mu }}}\bigl ({\widehat{\Phi }}^{\mathrm{tot}}_{n},n-2\bigr ), \end{aligned}$$
(5.38)

where the kernels of the theta series are given by

$$\begin{aligned} {\widehat{\Phi }}^{\mathrm{tot}}_n= \Phi ^{\scriptscriptstyle \,\int }_1\,\mathrm{Sym}\, \left\{ \sum _{T\in \mathbb {T}_n^\mathrm{S}}(-1)^{n_T-1} \left( {\widetilde{\Phi }}^{\,{\mathcal {E}}}_{v_0}-\Phi ^{\,{\mathcal {E}}}_{v_0}\right) \prod _{v\in V_T{\setminus }{\{v_0\}}}\Phi ^{\,{\mathcal {E}}}_{v}\right\} . \end{aligned}$$
(5.39)

Note that this result automatically implies that the theta series \(\vartheta _{{{\varvec{p}}},{\varvec{\mu }}}\bigl ({\widehat{\Phi }}^{\mathrm{tot}}_{n},n-2\bigr )\) is modular, since its kernel is a solution of Vignéras’ equation.

We end the discussion of these results by observing that the formula (5.33) allows to obtain a new representation of the tree index \(g_{\mathrm{tr},n}\). Indeed, as observed at the end of Sect. 5.1, \(g_{\mathrm{tr},n}\) agrees with \({\widehat{g}}_n\) in the limit \(\tau _2\rightarrow \infty \), which amounts to replacing \({\mathcal {E}}_{v}\) by its non-decaying part \({\mathcal {E}}^{(0)}_{v}\) in (5.33). In fact, as shown in appendix F, all contributions due to trees with non-zero number of marks in (5.27) and (5.29) cancel in the resulting expression, leaving only the contributions coming from the terms with \(m=0\). Thus, one arrives at the following representation:

Proposition 10

The tree index \(g_{\mathrm{tr},n}\) defined in (2.3) can be expressed as

$$\begin{aligned} \begin{aligned} g_{\mathrm{tr},n}=&\, \,\mathrm{Sym}\, \left\{ \sum _{T\in \mathbb {T}_n^{\mathrm{S}}}(-1)^{n_T-1} \left( g^{\star }_{v_0}-{\mathcal {E}}^{\star }_{v_0}\right) \prod _{v\in V_T{\setminus }{\{v_0\}}}{\mathcal {E}}^{\star }_{v}\right\} , \end{aligned} \end{aligned}$$
(5.40)

where \(g^{\star }_n\) is defined in (F.34) and \({\mathcal {E}}^{\star }_n=g^{\star }_n(\{{{\check{\gamma }}}_i,\beta _{ni}\})\).

Note that this representation is more explicit than the one given in Sect. 2.2 since it does not require taking the limit \(y\rightarrow 1\).

In fact, the mechanism by which contributions of marked trees cancel in the sum over Schröder trees, explained in the proof of Proposition 10, is very general and applies just as well to all the above equations (5.33)–(5.39). As a result, all of them remain valid if we replace \({\widetilde{\Phi }}^{\,{\mathcal {E}}}_n\) and \(\Phi ^{\,{\mathcal {E}}}_n\), respectively, by \({\widetilde{\Phi }}_n\) (5.16) and by its cousin with the vectors \(\{{{\varvec{u}}}_e\}\) replaced by \(\{{{\varvec{v}}}_e\}\),

$$\begin{aligned} \Phi _n({{\varvec{x}}})= \frac{1}{2^{n-1} n!}\sum _{{\mathcal {T}}\in \, \mathbb {T}_n^\ell } {\widetilde{\Phi }}^E_{n-1}(\{ {{\varvec{v}}}_e\}, \{{{\varvec{v}}}_{s(e) t(e)}\};{{\varvec{x}}}). \end{aligned}$$
(5.41)

Correspondingly, \(g^{(0)}_n\) and \({\mathcal {E}}^{(0)}_n\) should then be replaced by their asymptotics at large \(\tau _2\), given by \(G_n(\{{{\check{\gamma }}}_i,c_i\})\) and \(G_n(\{{{\check{\gamma }}}_i,\beta _{ni}\})\). The proof that such replacement is possible is completely analogous to the proof of Proposition 10, and we refrain from presenting it. This shows that from the very beginning we could take the function \(G_n\) as the ansatz for \(g^{(0)}_n\) since its \(\tau _2\)-dependence cancels in the formula for the tree index. We could then avoid most of complications of Sect. 5.2. However, we cannot avoid the introduction of marked trees since they appear in the expression for \(G_n\) (5.17) anyway. Moreover, we prefer to stick to the definition (5.27) because of two reasons. Firstly, due to its \(\tau _2\)-independence, \(g^{(0)}_n\) might itself be interpretable as an index. Secondly, as we discuss in the next subsection, it is related to other potentially interesting representations, which might be at the basis of such interpretation.

5.4 Alternative representations

The construction presented above provides an explicit expression for the completion \({\widehat{h}}_{p,\mu }\) and all other relevant quantities. Roughly, it can be split into three levels:

  1. 1.

    sum over Schröder trees (5.34);

  2. 2.

    sum over marked unrooted labelled trees (5.32);

  3. 3.

    sum over unrooted labelled trees defining the weights associated to marks (5.22).

The complication due to the appearance of marks and hence the last level arises due to the non-orthogonality of the vectors \({{\varvec{v}}}_{s(e) t(e)}\) appearing as arguments of the generalized error functions uplifted to solutions of Vignéras’ equation for \(\lambda =n-1\). However, the two sums over unrooted trees are organized is such a way that all additional contributions due to this non-orthogonality cancel. This suggests that there should exist a simpler representation where the vectors appearing in the second argument of functions \({\widetilde{\Phi }}^E_{n-1}({\mathcal {V}}, {\tilde{{\mathcal {V}}}};{{\varvec{x}}})\) are mutually orthogonal from the very beginning. Below we present some results showing that such a representation does exist at least for low values of n. We then move on to present yet another representation of the functions \(g^{(0)}_n\) which is significantly simpler than (5.27), although its equivalence with the latter remains conjectural.

5.4.1 Simplified representation via flow trees

We have shown, analytically for \(n=2,3,4\) (see appendix G) and numerically for \(n=5\), that the function (5.27) can be rewritten as

$$\begin{aligned} g^{(0)}_n(\{{{\check{\gamma }}}_i,c_i\}) = \,\mathrm{Sym}\, \left\{ \frac{d_n}{2^{n-1}}\sum _{T\in \mathbb {P}_n}\kappa (T) \prod _{k=1}^{n-1}\text{ sgn }(S_k)\right\} \qquad (n\le 5), \end{aligned}$$
(5.42)

where \(\kappa (T)\) is the factor defined in (2.7), whereas \(d_n\) and \(\mathbb {P}_n\subset \mathbb {T}_n^{\mathrm{af}}\) are numerical coefficients and subsets of flow trees with n leaves, respectively, which can be chosen as follows:

$$\begin{aligned} \begin{aligned} d_1&=1, \qquad d_2={1\over 2}\, , \qquad d_3=\frac{1}{6}\, , \qquad d_4=\frac{1}{12}\, , \qquad d_5=\frac{1}{30}\, , \\ \quad \mathbb {P}_1&=\{(1)\}, \qquad \mathbb {P}_2=\{(12)\}, \qquad \mathbb {P}_3=\{((12)3),(1(23))\}, \\ \mathbb {P}_4&=\{((1(23))4),((12)(34)),(1((23)4))\}, \\ \mathbb {P}_5&= \{((((31)4)2)5),(((12)(34))5),((1((23)4))5),(((12)3)(45)), \\&\quad \ ((12)(3(45))),(1((2(34))5)),(1((23)(45))),(1(4(2(53))))\}, \end{aligned} \end{aligned}$$
(5.43)

where we labelled ordered flow trees using 2-bracketings as explained in footnote 7.

Unfortunately, the simple ansatz (5.42) fails beyond the fifth order. For instance, numerical experiments indicate that for \(n=6\), one should include an additional term given by a product of \(n-3=3\) sign functions. This suggests the following more general ansatz:

Conjecture 2

The function (5.27) can be rewritten as

$$\begin{aligned} g^{(0)}_n(\{{{\check{\gamma }}}_i,c_i\}) = \,\mathrm{Sym}\, \left\{ \sum _{n_1+\cdots +n_m= n\atop n_k\ge 1, \ n_k\mathrm{-odd}} P_{n,m}\prod _{k=1}^{m-1}\text{ sgn }(S_{j_k})\right\} , \end{aligned}$$
(5.44)

where as in (2.17) \(j_k=n_1+\cdots + n_k\) and \(P_{n,m}\) are polynomials in \(\kappa (\gamma _{ij})\) homogeneous of degree \(n-1\) which can be represented as sums over subsets \(\mathbb {P}_{n,m}\) of flow trees with n leaves

$$\begin{aligned} P_{n,m}=\frac{1}{2^{n-1}}\sum _{T\in \mathbb {P}_{n,m}}d_T\,\kappa (T) \end{aligned}$$
(5.45)

with some numerical coefficients \(d_T\).

In fact, such a representation (if it exists) is highly ambiguous since there are many linear relations between polynomials \(\kappa (T)\) induced by the identity

$$\begin{aligned} \gamma _{12}\gamma _{1+2,3}+\gamma _{23}\gamma _{2+3,1}+\gamma _{31}\gamma _{1+3,2}=0, \end{aligned}$$
(5.46)

and even more relations after multiplication by sign functions and symmetrization. Eq. (5.42) suggests that there should exist a choice of subsets \(\mathbb {P}_{n,m}\) which leads to simple values of the coefficients \(d_T\). However, we do not know of a procedure which would allow to determine it systematically beyond \(n=5\).

The main advantage of the representation (5.44) is that the factors \(\kappa (T)\) multiplying the products of sign functions are proportional to \(\prod _{v\in V_T}({\tilde{{{\varvec{v}}}}}_v,{{\varvec{x}}})\) where the vectors \({\tilde{{{\varvec{v}}}}}_v\) defined in (4.14) are all mutually orthogonal. This property allows to immediately promote the kernel corresponding to the function (5.44), or to its value at the attractor point

$$\begin{aligned} {\mathcal {E}}^{(0)}_n(\{{{\check{\gamma }}}_i\})=g^{(0)}_n(\{{{\check{\gamma }}}_i,\beta _{ni}\})=\,\mathrm{Sym}\, \left\{ \sum _{n_1+\cdots +n_m= n \atop n_k\ge 1, \ n_k\mathrm{-odd} } P_{n,m}\prod _{k=1}^{m-1}\text{ sgn }(\Gamma _{nj_k})\right\} , \end{aligned}$$
(5.47)

to a solution of Vignéras’ equation, without going through the complicated construction of Sect. 5.2. Indeed, both such kernels are linear combinations of terms, labelled by flow trees, of the type (D.18) where the vectors \({\tilde{{{\varvec{v}}}}}_i\) coincide with the vectors \({\tilde{{{\varvec{v}}}}}_v\) for a given flow tree. Due to their mutual orthogonality, the solutions of Vignéras’ equation with \(\lambda =n-1\) with such asymptotics are given by

$$\begin{aligned} \Phi ^{\,{\mathcal {E}}}_n({{\varvec{x}}})=\frac{1}{2^{n-1}} \,\mathrm{Sym}\, \left\{ \sum _{n_1+\cdots +n_m= n \atop n_k\ge 1, \ n_k\mathrm{-odd} } \sum _{T\in \mathbb {P}_{n,m}}d_T\, {\widetilde{\Phi }}_{m-1,n-1}^E(\{ {{\varvec{v}}}_{j_k}\}, \{{\tilde{{{\varvec{v}}}}}_v\};{{\varvec{x}}})\right\} , \qquad \end{aligned}$$
(5.48)

and similarly for \({\widetilde{\Phi }}^{\,{\mathcal {E}}}_n\) with exchange of \({{\varvec{v}}}_{j_k}\) by \({{\varvec{u}}}_{j_k}\). The vectors \({{\varvec{v}}}_\ell \), \({{\varvec{u}}}_\ell \) defined in (5.8) can be seen as vectors \({{\varvec{v}}}_e\), \({{\varvec{u}}}_e\) for the unrooted tree of trivial topology \(\bullet \!\text{--- }\!\bullet \!\text{-- }\cdots \text{-- }\!\bullet \!\text{--- }\!\bullet \,\). Thus, instead of a sum over marked unrooted trees with factors themselves given by another sum over unrooted trees as in (5.32), we arrive at a representation involving only a sum over a suitable subset of flow trees and a single unrooted tree.Footnote 29 It becomes particularly simple in the case \(n\le 5\) where, as follows from (5.42), one can drop the sum over partitions, take \(m=n\) and equate all coefficients \(d_T\) to \(d_n\).

5.4.2 Refinement

Finally, there is yet an alternative way of obtaining the functions \(g^{(0)}_n\), which also sheds light on the origin of the representation (5.44). This representation is inspired by the solution for the tree index presented in Sect. 2.2. As in that case, the idea is to introduce a refinement parameter y, perform manipulations keeping \(y\ne 1\) and take the limit \(y\rightarrow 1\) in the end.

Let us therefore introduce a ‘refined’ analogue of \(g^{(0)}_n\), which we call \(g^{\mathrm{(ref)}}_n\) and which satisfies the refined version of the recursive relation (5.10) where the \(\kappa \)-factor is replaced by its y-dependent version (2.8). This refined equation can be solved by the following ansatz (cf. (2.11))

$$\begin{aligned} g^{\mathrm{(ref)}}_n(\{{{\check{\gamma }}}_i,c_i\},y) = \frac{(-1)^{n-1+\sum _{i<j} \gamma _{ij} }}{(y-y^{-1})^{n-1}} \,\,\mathrm{Sym}\, \Bigl \{ F^{\mathrm{(ref)}}_n(\{{{\check{\gamma }}}_i,c_i\})\,y^{\sum _{i<j} \gamma _{ij}}\Bigr \}. \end{aligned}$$
(5.49)

Indeed, it is easy to see that \(g^{\mathrm{(ref)}}_n\) satisfies (5.10) with the y-dependent \(\kappa \)-factor provided \(F^{\mathrm{(ref)}}_n\) satisfies the recursive relation

$$\begin{aligned} \begin{aligned}&{1\over 2}\sum _{\ell =1}^{n-1}\bigl (\text{ sgn }(S_\ell )-\text{ sgn }(\Gamma _{n\ell })\bigr )\,F^{\mathrm{(ref)}}_\ell (\{{{\check{\gamma }}}_i,c^{(\ell )}_i\}_{i=1}^\ell )\, F^{\mathrm{(ref)}}_{n-\ell }(\{{{\check{\gamma }}}_i,c^{(\ell )}_i\}_{i=\ell +1}^n) \\&\quad =F^{\mathrm{(ref)}}_n(\{{{\check{\gamma }}}_i,c_i\})-F^{\mathrm{(ref)}}_n(\{{{\check{\gamma }}}_i,\beta _{ni}\}). \end{aligned} \end{aligned}$$
(5.50)

This equation is simpler than (5.10) in that it is y-independent and does not involve any \(\kappa \)-factors. Furthermore, we already know one solution —the functions \(F^{(0)}_n\) (2.18) which can be shown to satisfy (5.50) with help of the sign identity (F.37). However, this solution is not yet suitable because, starting from \(n=3\), its substitution into the r.h.s. of (5.49) does not produce a Laurent polynomial in y, but rather a rational function with a pole at \(y\rightarrow 1\).

The solution can be promoted to a Laurent polynomial by noting that the recursive equation (5.50) determines \(F^{\mathrm{(ref)}}_n\) in terms of \(F^{\mathrm{(ref)}}_k\), \(k<n\) only up to an additive constant \(b_n\). Thus, at each order one can adjust this constant so that to ensure that \(g^{\mathrm{(ref)}}_n\) given by (5.49) is regular at \(y=1\). Then we arrive at the following solution

$$\begin{aligned} F^{\mathrm{(ref)}}_n(\{c_i\})=\frac{1}{2^{n-1}}\sum _{n_1+\cdots +n_m= n\atop n_k\ge 1} \prod _{k=1}^m b_{n_k}\prod _{k=1}^{m-1}\text{ sgn }(S_{j_k}), \end{aligned}$$
(5.51)

where as usual \(j_k=n_1+ \cdots + n_k\). Remarkably, this solution depends only on the stability parameters \(c_i\), despite the fact that the recursion (5.50) also involves the DSZ products \(\gamma _{ij}\). It satisfies this recursion for arbitrary coefficients \(b_n\), as can be easily checked by extracting contributions with the same sets of \(\{n_k\}\) and applying the sign identity (F.37). Moreover, for arbitrary values of these coefficients, the numerator of (5.49) evaluated at \(y=1\) turns outFootnote 30 to be a constant, independent of the \(c_i\)’s. The coefficients \(b_n\) are then fixed uniquely by requiring that this constant vanishes, namely

$$\begin{aligned} \,\mathrm{Sym}\, F^{\mathrm{(ref)}}_n(\{c_i\})=0\, . \end{aligned}$$
(5.52)

Choosing one particular configuration of the moduli, say \(c_i>0\) for \(i=1,\ldots ,n-1\) and \(c_n=-\sum _{i=1}^{n-1} c_i<0\), one finds numerically that all coefficients \(b_n\) with n even vanish,Footnote 31 while those with n odd are given by

$$\begin{aligned} b_1=1, \quad b_3=-\frac{1}{3}, \quad b_5=\frac{2}{15}, \quad b_7=-\frac{17}{315}, \quad b_9=\frac{62}{2835}, \quad b_{11}=-\frac{1382}{155925}, \quad \ldots \nonumber \\ \end{aligned}$$
(5.53)

We observe that these coefficients coincide with the first coefficients in the Taylor series of \(\tanh x = x - \frac{1}{3} x^3+ \frac{2}{15} x^5 + \cdots \). We therefore conjecture that this identification continues to hold in general, so that \(b_n\) is expressed in terms of the Bernoulli number \(B_{n+1}\) through

$$\begin{aligned} b_{n-1}=\frac{2^{n} (2^{n} - 1)}{n!}\, B_{n} . \end{aligned}$$
(5.54)

Using the iterative equation (5.10), the constraint (5.52) and proceeding by induction, it is easy to see that \(g^{\mathrm{(ref)}}_n\) defined by (5.49) and its first \(n-2\) derivatives with respect to y vanish at \(y=1\). This ensures that \(g^{\mathrm{(ref)}}_n\) is smooth and its limit \(y\rightarrow 1\) is well-defined.

Conjecture 3

The function \(g^{\mathrm{(ref)}}_n\), defined by (5.49), (5.51) and (5.54), reproduces the function \(g^{(0)}_n\) (5.27) in the unrefined limit,

$$\begin{aligned} \lim _{y\rightarrow 1}g^{\mathrm{(ref)}}_n(\{{{\check{\gamma }}}_i,c_i\},y)=g^{(0)}_n(\{{{\check{\gamma }}}_i,c_i\}). \end{aligned}$$
(5.55)

We have checked this conjecture numerically up to \(n=6\) evaluating the limit \(y\rightarrow 1\) using l’Hôpital’s rule. Unfortunately, the new representation of \(g^{(0)}_n\) obtained in this way is not helpful for the purposes of this work because it does not lead to any new representation for the completion. Nevertheless, the comparison of (5.51) and (5.44) shows that the sum over partitions and the simple form of products of sign functions characterizing the representation discussed in the previous subsection find their origin in the formula for \(F^{\mathrm{(ref)}}_n\). Furthermore, this construction strongly suggests that the refinement may be compatible with S-duality, and that a suitably defined generating function of refined DT invariants may also possess interesting modular properties, which can even be simpler than those of the usual DT invariants.

6 Discussion

In this paper we studied the modular properties of the generating function \(h_{p,\mu }(\tau )\) of MSW invariants encoding BPS degeneracies of D4–D2–D0 black holes in Type IIA string theory on a Calabi–Yau threefold, with fixed D4-charge \(p^a\), D2-brane charge (up to spectral flow) \(\mu _a\) and invariant D0-brane charge \({\hat{q}}_0\) (defined in (2.27)) conjugate to the modular parameter \(\tau \). These properties follow from demanding that the vector multiplet moduli space in \(D=3\) (or the hypermultiplet moduli space in the dual type IIB picture) admits an isometric action of \(SL(2,\mathbb {Z})\). Our main result is an explicit formula for the non-holomorphic modular completion \({\widehat{h}}_{p,\mu }\) (5.1), where the functions \(R_n(\{\gamma _i\},\tau _2)\) are given by Eq. (5.34), with \({\mathcal {E}}_v={\mathcal {E}}_v^{(0)}+{\mathcal {E}}_v^{(+)}\) specified by (5.29) and (5.32). This result applies for D4-branes wrapping a general effective divisor which may be the sum of an arbitrary number n of irreducible divisors.

The existence of such completion was not guaranteed. We arrived at this result by cancelling the modular anomaly of an indefinite theta series of signature \((n, n b_2({\mathfrak {Y}})-n)\) with a complicated kernel (4.3). In particular, Vignéras’ equation encoding this anomaly involves Kähler moduli in a non-trivial way through the walls of marginal stability, whereas the functions \(R_n\) in our ansatz (5.1) can only depend (non-holomorphically) on the modular parameter \(\tau \) and on the charges \(\gamma _i\). Note also that the transformation (3.21) of the contact potential, which was the starting point of our analysis, is only a necessary condition for the existence of an isometric action of \(SL(2,\mathbb {Z})\) on \({\mathcal {M}}_H\). To demonstrate that this condition is sufficient, one would have to construct suitable complex Darboux coordinates on the twistor space such that, after expressing them in terms of the completed generating function \({\widehat{h}}_{p,\mu }\) found in this paper, \(SL(2,\mathbb {Z})\) acts on these coordinates by a complex contact transformation. Such coordinates were constructed at the two-instanton level in [26], and it is an interesting challenge to extend this construction to arbitrary n.

The structure of the completion suggests that, for a divisor decomposable into a sum of n effective divisors, the holomorphic generating function \(h_{p,\mu }\) is a mixed vector valued mock modular form of higher depth, equal to \(n-1\). Such objects have recently appeared in various mathematical and physical contexts [36, 44, 69,70,71] and correspond to holomorphic functions whose completion is constructed from period (or Eichler) integrals of mock modular forms of smaller depth (with depth 0 mock modular forms being synonymous with ordinary modular forms). For instance, in the case of standard mock modular forms of depth one, the completion is given by an Eichler integral of a modular function [27]. In our case this structure follows from the fact that the completion \({\widehat{h}}_{p,\mu }\) is built from the generalized error functions which have a representation in terms of iterated period integrals [28, 44]. In order to make manifest the mixed mock modular nature of \(h_{p,\mu }\), one should represent the antiholomorphic derivative of its completion \({\widehat{h}}_{p,\mu }\), computed in (5.35), as a sum of products of completions of mixed mock modular forms of lower depth and anti-holomorphic modular forms. This is a non-trivial task which involves the technique of lattice factorization for indefinite theta series, which we leave for future research.

An important caveat in our construction is that we did not establish the convergence of the various generating functions and indefinite theta series. Technically, we constructed a theta series \(\vartheta _{{{\varvec{p}}},{\varvec{\mu }}}\bigl ({\widehat{\Phi }}^{\mathrm{tot}}_{n},n-2\bigr )\) whose kernel satisfies Vignéras’ equation (D.3), but we did not demonstrate that it decays as required by Vignéras’ criterium. (For \(n=2\) this is easy to show [14] since the kernel is a product of an exponentially suppressed factor and a difference of two error functions defined by two positive vectors.) In fact, convergence issues already arise when expressing the generating function of DT invariants in terms of MSW invariants in (2.31), and are related to the problem of convergence of the BPS black hole partition function. The latter was proven to converge in the large volume limit for the case involving up to \(n\le 3\) centers in [55]. We hope that the results for the tree index obtained in [23] will allow to extend this result to arbitrary n.

We note that many of the complications in our construction originate from the occurrence of polynomial factors in the kernel of theta series, which in turn can be traced to the factors of DSZ products \(\gamma _{ij}\) in the wall-crossing formula. Presumably, most of these complications would disappear if one could find a generalization of the contact potential involving the refined DT invariants, so that all these prefactors can be traded for explicit powers of the fugacity y, as in Sect. 5.4.2. It is possible that twistorial topological strings [72] may provide the appropriate framework for finding such a refinement, at least in the context of string vacua on non-compact Calabi–Yau threefolds.

On the physics side, we expect that our results will have important implications for the physics of BPS black holes. Indeed, the mock modular property of the generating function \(h_{p,\mu }\) will affect the growth of its Fourier coefficients [73], and should be taken into account when performing precision tests of the microscopic origin of the Bekenstein-Hawking entropy. A natural question is to understand the origin of the non-holomorphic correction terms \(R_n\), in terms of the quantum mechanics of n-centered black holes [42, 74]. Another outstanding question is to understand the physical significance of the instanton generating function \({\mathcal {G}}\) defined in (3.22). Its modular properties are exactly those expected from the elliptic genus of a superconformal field theory, except for the fact that it is not holomorphic in \(\tau \). It is natural to expect that this non-holomorphy can be traced to the existence of a continuum of states with a non-trivial spectral asymmetry between bosons and fermions [75]. It would be very interesting to understand the origin of this continuum in terms of the worldvolume theory of an M5-brane wrapped on a reducible divisor. Moreover, for special \({\mathcal {N}}=2\) theories in \(D=4\) obtained by circle compactification of an \({\mathcal {N}}=1\) theory in \(D=5\), \({\mathcal {G}}\) is closely related to the index considered in [42]. It would be interesting to understand the physical origin of its modular invariance in this context.

Finally, we expect that the structure found in the context of generalized DT-invariants on Calabi–Yau threefolds will also arise in the study of other types of BPS invariants where higher depth mock modular forms are expected to occur, such as Vafa-Witten invariants and Donaldson invariants of four-folds with \(b_2^+=1\) [28, 69]. In particular, it would be interesting to determine the modular completion of the generating function of Vafa–Witten invariants on the complex projective plane computed for all ranks in [76], generalizing the rank 3 case studied in [69], and compare with the completion found in the present paper.