A topologically twisted index for three-dimensional supersymmetric theories

We provide a general formula for the partition function of three-dimensional $\mathcal{N}=2$ gauge theories placed on $S^2 \times S^1$ with a topological twist along $S^2$, which can be interpreted as an index for chiral states of the theories immersed in background magnetic fields. The result is expressed as a sum over magnetic fluxes of the residues of a meromorphic form which is a function of the scalar zero-modes. The partition function depends on a collection of background magnetic fluxes and fugacities for the global symmetries. We illustrate our formula in many examples of 3d Yang-Mills-Chern-Simons theories with matter, including Aharony and Giveon-Kutasov dualities. Finally, our formula generalizes to $\Omega$-backgrounds, as well as two-dimensional theories on $S^2$ and four-dimensional theories on $S^2 \times T^2$. In particular this provides an alternative way to compute genus-zero A-model topological amplitudes and Gromov-Witten invariants.


Introduction
In the last few years there has been a huge development in the study of supersymmetric quantum field theories on compact manifolds in various dimensions. Localization techniques [1] often allow to exactly evaluate the path-integral of the theory on a compact manifold, possibly with the insertion of local and non-local operators that respect some supersymmetry. Most of the examples studied in the last few years are not topologically twisted [2] (see [3] for a nice review and references). In this paper, instead, we consider a very simple example: the partition function of N = 2 supersymmetric gauge theories in three dimensions on S 2 × S 1 with a semi-topological A-twist on S 2 [1]. Despite the conceptual simplicity, we will see that the model presents several interesting features. We study generic three-dimensional N = 2 gauge theories with an R-symmetry (with the constraint that the R-charges be integers). The topological twist is equivalent to turning on a background for the R-symmetry, which is a quantized magnetic flux on S 2 . Similar magnetic fluxes can be turned on for all global flavor symmetries of the theory. We use localization to compute the partition function, with a method similar to that recently used to evaluate the elliptic genus of two-dimensional gauge theories [4,5] and the Witten index of quantum mechanical sigma models [6][7][8]. The path-integral localizes on a set of BPS configurations which are specified by some data of the gauge multiplet: a magnetic gauge flux m on S 2 and a complex mode u = A t + iβσ encoding the vacuum expectation value σ of the real scalar in the vector multiplet and the holonomy of the gauge field A t along S 1 (β is the radius of S 1 ). The final partition function is given by a contour integral, of a meromorphic form in the variables u, which encodes the classical and one-loop contributions around BPS configurations, summed over all magnetic gauge fluxes. Supersymmetric localization selects a particular contour of integration C, and therefore it picks some of the residues of the form Z int (u; m). The choice of the correct integration contour is one of the challenges of this computation, that we solve using the methods introduced in [4,5]. In many cases, we can formulate the result of integration in terms of a geometrical operation called the Jeffrey-Kirwan residue [9] (see also [10,11]). The final result depends on the magnetic fluxes m f and chemical potentials u f for the flavor symmetries of the theory. It is, in particular, an analytic function of the fugacities e iu f . For the reader's convenience, we summarize the main features of our formula in section 1.1.
To avoid confusion, we should stress that we are not computing the superconformal index, which is the partition function on S 2 × S 1 without twist. In fact, our partition function is not counting operators and there is no fugacity corresponding to the dimension, or R-charge, of the operators. We can still interpret our formula as a twisted index by writing the partition function as a trace over the Hilbert space H of states on a sphere, in the presence of a magnetic background for the R-and flavor symmetries, by performing a supersymmetric localization. In section 3 we provide examples in various Abelian and non-Abelian Yang-Mills-Chern-Simons-matter theories in 3d, and test our formula against known dualities. In section 4 we add a refinement for the angular momentum. In section 5 we discuss the generalizations of our formula to two and four-dimensions. Finally, in the appendices we give details about the computation of one-loop determinants. For the reader's convenience, we summarize our main finding in the next subsection: the reader not interested in its formal derivation, can read it and then safely jump to section 3.

The main result
For an N = 2 gauge theory on S 2 × S 1 with gauge group G of rank r (and Lie algebra g), the topologically twisted path-integral localizes on a set of BPS configurations specified by a gauge magnetic flux on S 2 , m = 1 2π S 2 F , a flat connection 1 A t along S 1 , and the value σ of the real scalar in the vector multiplet, all mutually commuting. Up to gauge transformations, the magnetic fluxes m live in the co-root lattice Γ h of G while the scalar zero-modes parameterize the connected components M = H × h of the BPS manifold, where H is a maximal torus in G and h is the corresponding Cartan subalgebra. Configurations connected by the Weyl group W of G are gauge-equivalent. It is convenient to combine the components of the zero-modes into the holomorphic Cartan combinations u = A t + iβσ, where β is the radius of S 1 , and define x = e iu . Here u represents r modes. For G = U (1), u ≃ u + 2π lives on a cylinder while x ∈ C * . For a generic connected group G, u ≃ u + 2πζ where ζ is an element of the co-root lattice.
The contribution of a chiral multiplet to the one-loop determinant is given by where R is the representation under the gauge group G, ρ the corresponding weights and q the R-charge of the field. The contribution of a vector multiplet to the one-loop determinant is instead given by Z gauge 1-loop = α∈G (1 − x α ) (i du) r (1.4) where α are the roots of G. Z gauge 1-loop is naturally interpreted as a middle-dimensional holomorphic form on H × h. The classical action contributes a factor where k is the Chern-Simons coupling of G (each Abelian and simple factor has its own coupling). For Abelian factors G 1 and G 2 in G, a mixed Chern-Simons coupling k 12 A (1) ∧ F (2) is possible and it contributes x k 12 m 2 1 x k 12 m 1 2 . The theory can have flavor symmetries: we denote the corresponding holonomies by y = e iv and the magnetic fluxes by n. Then the 1-loop determinant is modified as where ρ f is the weight under the flavor group. A U (1) topological symmetry with holonomy ξ = e iz and flux t contributes Z top class = x t ξ m . (1.7) The contribution of the classical action and the one-loop determinant in each sector of magnetic flux m, Z int (u; m) = Z class Z 1-loop , (1.8) is a meromorphic r-form on H × h. Z int (u; m) has pole singularities along the hyperplanes e iρ(u)+iρ f (v) = ½ G determined by the chiral fields and goes to zero or infinity at the boundaries of H × h. The path-integral reduces to an r-dimensional contour integral of Z int (u; m), summed over all magnetic fluxes in the co-root lattice Γ h . The contour C is a specific sum of r-dimensional contours going around the hyperplane singularities or living at the boundary of H × h. For a U (1) theory with chiral fields with charges Q i (and more generally when r = 1), it is easy to specify the integration contour C. The behavior at the two boundaries of H × h is determined by the effective CS coupling (1.10) The path-integral can be conveniently written as a sum of residues of the meromorphic form Z int (u; m) in the x = e iu plane. The two boundaries of H × h map to two circles around x = 0 and x = ∞. We can use one of two equivalent prescriptions and sum either • all residues at the poles created by fields with positive charge, the residue at x = 0 if k eff (+∞) < 0 and the residue at x = ∞ if k eff (−∞) > 0; or • minus the residues at the poles created by fields with negative charge, minus the residue at x = 0 if k eff (+∞) > 0 and minus the residue at x = ∞ if k eff (−∞) < 0.
This prescription can be written in a compact form by assigning charges to the boundaries at x = 0 and x = ∞, and using the Jeffrey-Kirwan residue defined as [9][10][11] JK-Res y=0 Q, η dy y = θ(Qη) sign(Q) . (1.12) Here η = 0 is a parameter. The final formula for a U (1) theory is then where M sing is the set of singular points in M where Z int has poles, and Q x * is the charge of the chiral field creating the pole. To perform the computation one has to choose a parameter η = 0, but the result is independent of such a choice. The Jeffrey-Kirwan residue appears in a similar way in the localization of the elliptic genus for 2d theories [4,5] and of the Witten index in 1d [6][7][8].
For gauge groups of rank r > 1, the choice of contour is more complicated. The path-integral is still given by a sum of Jeffrey-Kirwan residues at a finite number of points in H × h, where r or more singular hyperplanes meet, plus a boundary contribution: 14) The precise form of the contour is discussed in section 2.4. However, in all examples considered in this paper, we will be able to extrapolate the Abelian formula to the non-Abelian case without really using the complicated machinery of section 2.4.
2 Localization on S 2 × S 1 with topological twist In this section we provide a path-integral derivation of the formulae (1.13) and (1.14). The crucial technique is supersymmetric localization (see e.g. [1,2] and [3] for a modern review) which allows to exactly reduce the path-integral Z S 2 ×S 1 (t) to a finite-dimensional integral over a moduli space of BPS configurations M BPS , where the measure is provided by the one-loop determinant Z 1-loop of small quadratic fluctuations around those configurations. Schematically: There {t} is a collection of parameters of the theory on S 2 × S 1 , on which the path-integral depends. More in details, the computation will be similar to the one performed in [4,5] for the pathintegral evaluation of the elliptic genus of two-dimensional N = (0, 2) theories, and in [6,7] for the Witten index of N = 2 quantum mechanics. Localization provides a function to be integrated on the complex u-plane, with various poles corresponding to the matter fields. Because of the singularities of the integrand, we will need to use a clever regulator whose existence is naturally provided by the off-shell multiplet of zero-modes. By integrating out the gaugino zero-modes we will reduce the integral to a contour integral. We also stress that we can have generic Wilson loop insertions at points on S 2 and wrapping S 1 .
Accordingly, we first construct supersymmetry, supersymmetric actions and Wilson line operators on S 2 × S 1 , we then study the relevant moduli space of BPS configurations M BPS , and evaluate the "on-shell" action and the one-loop determinant of small quadratic fluctuations around them. It turns out that M BPS contains fermionic zero-modes as well as singular loci with extra bosonic zero-modes. With a suitable regulator, the two problems solve each other and we are left with a contour integral: this technical part occupies the second half of this section. For the sake of clarity, we present the derivation in the case of rank-one gauge groups first, and then move to the more intricate generic case. In section 4 we present a refined version of this computation, in which the spacetime geometry is a fibration of S 2 over S 1 , that can be considered as the three-dimensional Ω-background (the position of Wilson line operators will then be constrained).

Lagrangian and supersymmetry transformations
We start by writing the metric and the background fields that we need to turn on in order to preserve some supersymmetry. We write then the supersymmetry transformations corresponding to the topologically twisted theory and the supersymmetric Lagrangians for gauge and matter fields.

The supersymmetric background
We consider three-dimensional N = 2 theories on S 2 × S 1 , where supersymmetry is preserved by a topological twist on S 2 . The round metric on S 2 × S 1 is where we take t ≃ t + 1. We take vielbein e 1 = R dθ, e 2 = R sin θ dϕ, e 3 = β dt. To perform the topological twist, we turn on a background for the R-symmetry proportional to the spin connection: which corresponds to a flux 1 2π S 2 W = −1 for the R-symmetry curvature W = dV . In our notation 2 the supersymmetry spinor ǫ = ǫ + ǫ − has R-charge −1 so that the Killing spinor equation D µ ǫ = ∂ µ ǫ + 1 4 ω ab µ γ ab ǫ + iV µ ǫ = 0 is solved by Because of the R-symmetry background magnetic flux, we will restrict to theories with integer R-charges. Notice that the same setup works with a generic metric on S 2 , and when S 2 is replaced by a Riemann surface Σ g of arbitrary genus g, with the same choice of V = − 1 2 ω 12 and the same covariantly constant spinor (2.3). In general the R-symmetry field strength is related to the scalar curvature by If the metric on S 2 has a U (1) isometry, we can introduce a rotation of S 2 along the circle, which essentially gives the Ω-background on S 2 × S 1 , ds 2 = R 2 dθ 2 + sin 2 θ(dϕ − ς dt) 2 + β 2 dt 2 , (2.5) where the coordinates have the same periodicity as before: t ∼ = t + 1, ϕ ∼ = ϕ + 2π. We can still perform the topological twist with V = − 1 2 ω 12 and the covariantly constant spinor (2.3). We call this the "refined" case, and we discuss it in section 4.

Supersymmetry transformations and BPS equations
We use BPS transformations in terms of commuting spinors and anticommuting supercharges (as given in appendix B.2 of [17]). The supersymmetry parameters are two positive-chirality covariantly constant spinors ǫ,ǫ satisfying D µ ǫ = 0, γ 3 ǫ = ǫ and similarly forǫ, with the same R-charge −1. Notice that, in fact, ǫ andǫ are multiples of the unique covariantly constant spinor (2.3). The algebra has two complex supercharges Q, Q of vanishing R-charge.
We consider the following types of multiplets: vector multiplets V = (A µ , σ, λ, λ † , D) whose components in Lorentzian signature are a gauge field, two real scalars σ, D and a Dirac spinor, all in the adjoint representation of the gauge group; chiral multiplets Φ = (φ, ψ, F ) whose components are two complex scalars φ, F and a Dirac spinor, all in a representation R of the gauge group; anti-chiral multiplets Φ † = (φ † , ψ † , F † ) with the same components as a chiral multiplet, all in the conjugate representation R. In Euclidean signature all fields are complexified, and † -ed fields are not adjoints but rather independent fields.
The transformations of a vector multiplet are: We have turned on the background (2.2) for the R-symmetry and used the R-charge assignment (0, 0, −1, 1, 0) for (A µ , σ, λ, λ † , D). 3 For the chiral multiplet the supersymmetry transformations are 4 The R-charges of (φ, ψ, F ) are (q, q − 1, q − 2), and those of (φ † , ψ † , F † ) are the opposite. This transformations realize the superalgebra su(1|1), whose bosonic subalgebra u(1) generates rotations of S 1 mixed with gauge/flavor rotations: Here L A v is the gauge-covariant Lie derivative (including the R-symmetry connection) along the covariantly constant (and Killing) vector field v µ . 5 Using the flat basis e a , in the unrefined case 3 In particular, in our notation the "standard" gaugino with R-charge +1 is λ c , the charge-conjugate to λ. 4 We define charge conjugate spinors ǫ c = Cǫ * and ǫ c † = ǫ T C, where C is the charge conjugation matrix such that Cγ µ C −1 = −γ µT . We choose C = γ2 so that C = C −1 = C † = −C T = −C * . Moreover ǫ cc = −ǫ. 5 The explicit expression of the Lie derivative of fields of various spins can be found in appendix B.1 of [17] and appendix A.2 of [27].
while in the refined case v = β −1ǫ † ǫ(∂ t + ς∂ ϕ ). In order to perform localization, we will use the supercharge which behaves as an equivariant differential:

Supersymmetric Lagrangians
We now proceed with the construction of supersymmetric Lagrangians on S 2 × S 1 . We consider Yang-Mills-Chern-Simons theories with matter, therefore we construct the Yang-Mills action, the various Chern-Simons terms, the matter kinetic action and superpotential interactions. Whenever the theory has some continuous flavor symmetry G F , we couple it to an external vector multiplet and turn on background values for the bosonic fields therein. This corresponds to magnetic flavor fluxes on S 2 , flat flavor connections on S 1 , and real masses. We recall that whenever the gauge group has an Abelian factor, the flavor group includes a "topological" U (1) subgroup (possibly enhanced to a larger subgroup in the IR quantum theory). We work in Euclidean signature, therefore all fields get complexified. However, when performing the path-integral, we have to choose a middle-dimensional contour in field space. We choose the "natural" one, in which "real" fields are real while † is identified with the adjoint operation: we call such a contour the real contour. We have chosen conventions in which all Lagrangian terms have a non-negative real bosonic part, ensuring convergence of the path-integral.
The supersymmetric Yang-Mills (YM) Lagrangian is (2.10) One can verify that Q Q Tr 1 2 λ † λ + 2Dσ ∼ =ǫ † ǫ L YM (2.11) up to total derivatives, therefore the YM action is also Q-exact. The supersymmetric Chern-Simons (CS) Lagrangian is, for each simple or Abelian factor: In general one can have a different CS level k for each simple or Abelian factor in the gauge group, however we will often be schematic with our notation and use the simple expression above. The CS action is supersymmetric but not Q-exact. If there are multiple Abelian factors in the gauge group, one can introduce mixed CS terms between them: The mixed CS terms play an important role in turning on background fluxes or holonomies for the topological symmetries. Recall that in three dimensions, any U (1) gauge symmetry gives rise to a global symmetry whose current is given by J µ T = ( * F ) µ = 1 2 ǫ µνρ F νρ . The current is automatically conserved by the Bianchi identity, d * J T = dF = 0, and the corresponding global symmetry U (1) T is called topological. In order to turn on a background gauge field A (T ) for the topological symmetry, we couple it though (2.14) Here A (T ) belongs to an external vector multiplet whose other bosonic components are σ (T ) and D (T ) . In order to have a supersymmetric background, we need to set to zero the variation of the fermions in the external multiplet. From (2.6) we obtain that we should set D (T ) = iF (T ) 12 , while σ (T ) can be an arbitrary constant. The full action is the supersymmetric completion of (2.14), which is obtained from (2.13) by taking k 12 = 1 and regarding (1) as the background topological symmetry and (2) as the gauge symmetry: The three terms are separately supersymmetric. We see that σ (T ) (a real mass for the topological symmetry) is in fact a Fayet-Iliopoulos (FI) term. We can also consider a mixed CS term between the R-symmetry and an Abelian flavor (or gauge) symmetry: This term is the specialization to our background of the term in (4.19) of [28]. The supersymmetric matter kinetic action is Here W 12 should act in the correct representation, i.e. it should be meant to be qW 12 where q is the R-charge of φ. One can verify that up to total derivatives, therefore the matter kinetic action is also Q-exact. Superpotential interactions are controlled by a holomorphic function W (Φ), gauge-invariant and of R-charge 2. The two Lagrangians where are the F-terms of the chiral multiplet W (Φ) and its antichiral partner, are separately supersymmetric. Since Q iǫ c † ψ W ∼ =ǫ † ǫ L W and Q −iψ † Wǫ c ∼ =ǫ † ǫ L W up to total derivatives, the two Lagrangians lead to Q-exact actions. Notice that although in Euclidean signature the two functions W and W can be independent, since we consider the Wick rotation of real Lorentzian Lagrangians, we take them complex conjugate. 6 The covariant derivatives in (2.17) contain the gauge fields, the background field V for the R-symmetry and background fields for the flavor symmetries of the theory. A background vector multiplet for a flavor symmetry contains the bosonic components F F 12 , A F 3 , σ F and D F which should satisfy D F = iF F 12 in order to preserves supersymmetry. We see that F 12 represents a background magnetic flux for the flavor symmetry, A 3 is a flat flavor connection along S 1 , and σ F is a real mass associated with the flavor symmetry.
Finally, we can include Wilson lines in representation R defined as as in [29]. Here x µ (τ ) is the worldline of the loop, τ is a parameter on it,ẋ µ is the derivative with respect to τ and |ẋ| is the length ofẋ µ . Its supersymmetry variation is One gets QW = 0 (and QW = 0) ifẋ 1 =ẋ 2 = 0, i.e. if the loop is along the vector field e 3 . In the unrefined case e 3 = 1 β ∂ t : we can place the loop at an arbitrary point on S 2 and along t. In the refined case e 3 = 1 β (∂ t + ς∂ ϕ ) and x µ (τ ) = (θ 0 , ςτ, τ ), therefore for irrational values of ς the loop does not close; we can either tune ς to rational values, or place the loop at one of the two poles of S 2 .

Localization on S 2 × S 1
To compute the path-integral Z S 2 ×S 1 (t), we use the localization method. We deform the action S[ϕ; t] → S[ϕ; t] + uQV [ϕ], where u is a positive parameter while V has non-negative real bosonic part and Q 2 V = 0. By the standard argument, the path-integral does not depend on u. Evaluating in the u → +∞ limit, the path-integral localizes around configurations for which the real bosonic part of QV [ϕ] vanishes. Therefore Z S 2 ×S 1 reduces to a semi-classical computation around those configurations.

The BPS equations
As a deformation Lagrangian we choose L YM + L mat in (2.10) and (2.17), since each term leads to a non-negative Q-exact action. Let us start with the gauge sector. Setting to zero the real bosonic part of L YM along the real contour, one gets On the other hand, without imposing any reality condition, the BPS equations Qλ = Qλ † = 0 lead to a much larger set of complexified configurations: 6 If we stay off-shell, the matter kinetic action has the positive-definite term F † F , while the real bosonic part of LW + L W vanishes. On the other hand, if we integrate out Fi, F † i to go on-shell, we obtain the positive-definite term i ∂iW 2 .
When evaluating a standard integral in the saddle-point approximation, it is common that saddle points in the complex plane and off the original integration contour contribute to the integral; therefore we might worry that something similar happens here. In fact, with a very careful analysis, we will see that it does. It will be convenient to define M BPS as the space of BPS configurations where the reality condition is applied to all physical fields but not to the auxiliary field D: where G is the infinite dimensional group of gauge transformations. These equations are easily solved. Let us choose a gauge ∂ t A t = 0. Let g ∈ G be the holonomy around S 1 , which may depend on the position on S 2 . The Bianchi identity implies D t F 12 = 0. Single-valuedness of F 12 along S 1 implies [g, F 12 ] = 0. This in turn implies that F 12 (x) is constant on S 1 , g is constant on S 2 , and they commute. In particular, we can represent F 12 by a connection on S 2 that is constant on S 1 and, if g is connected to the identity, we can represent g by a connection on S 1 that is constant on S 2 , and they commute. 7 Integrating D 3 σ = 0 along S 1 we get [g, σ] = 0 and σ is constant on S 1 . Finally we have to solve D µ σ = 0 on S 2 , which implies [F 12 , σ] = 0 at all points on S 2 , and σ is constant on S 2 .
Summarizing, the equations are solved by where g and σ are constant, while F 12 may depend on S 2 but is constant along S 1 . This space If we further restrict F 12 to be constant (we will show how that comes out of the pathintegral), the moduli space reduces to where H is a maximal torus in G, h is the Cartan subalgebra, Γ h ⊂ h is the co-root lattice of G that parameterizes quantized fluxes, and W is the Weyl group. Let us now move to the matter sector. The BPS equations along the real contour give These equations generically imply φ = 0. However they admit extra nontrivial solutions when σ and e iAt − ½ have a common zero eigenvalue: the extra solutions are then zero-modes of D 1 + iD 2 on S 2 (or more generally on Σ g ).

The zero-modes
(2.28) We call u a complexified flat connection. Notice that u represents r modes, where r is the rank of the gauge group. For a U (1) group, u ≃ u + 2π lives on a cylinder while x ∈ C * . For a generic group G, u ≃ u + 2πζ where ζ is an element of the co-root lattice. Configurations related by the Weyl group have to be identified. We parameterize magnetic fluxes by where m ∈ Γ h satisfy e 2πim = ½ G , i.e., in physical terms, they are GNO quantized [30].
Besides the bosonic zero-modes, there are also fermionic zero-modes and together they form complete supermultiplets. Each bosonic zero-mode is paired with a fermionic zero-mode coming from the Cartan gaugini. The Cartan gaugini λ are not lifted because they are charged only under the R-symmetry, and we cannot turn on a flat connection for the R-symmetry without breaking supersymmetry. In fact the fermionic zero-modes have the same quantum numbers as ǫ and are proportional to it; we can thus define scalar fermionic zero-modes which are obtained from Qū = iλ † 0 , Qū = iλ 0 . We can close the supersymmetry algebra "offshell" if we introduce an auxiliary bosonic zero-mode D 0 : This is obtained from Qλ † 0 = D 0 or Qλ 0 = −D 0 . This zero-mode corresponds to a constant profile for D − iF 12 . In the following we will choose a normalization β ǫ † ǫ = 1 for the zero-modes. Notice that, as usual, setting to zero the auxiliary component gives BPS configurations. The supersymmetry algebra closes and we find Notice that Q 2 = Q 2 = {Q, Q} = 0 on the zero-mode subspace, since the zero-modes are translationally invariant and commute with σ. We will call "almost BPS" the configurations which satisfy the BPS conditions, except for a constant D 0 -in other words D = iF 12 + D 0 . All chiral multiplets give rise to bosonic and fermionic Landau levels on S 2 , however such potential zero-modes are charged under flavor and gauge symmetries, therefore the complexified flat connections on S 1 generically lift them. There are, however, special hyperplanes (linear submanifolds of complex codimension 1) on M where the total flat connection has zero eigenvectors, and extra zero-modes appear. In particular each chiral multiplet Φ i can give rise to a hyperplane H i such that when u ∈ H i , Φ i develops a bosonic zero-mode. The manifolds H i are determined by the poles of the one-loop determinant and are of the form where ρ i is the weight of the gauge representation, ρ f of the flavor representation, and v is the complexified holonomy for the flavor group. To each hyperplane we associate the covector Q i ≡ ρ i ∈ h * equal to the gauge weight (in the Abelian case, Q i is a list of charges). We call the singular manifold and, as we will see, we will only be interested in M \ M sing .
In the rank-one case, H i are just isolated points on M. For r > 1, instead, H i are proper hyperplanes. We define M * sing ⊂ M sing the set of isolated points in M where at least r linearly independent hyperplanes meet: Given u * ∈ M * sing , we denote by Q(u * ) the set of charges of the hyperplanes meeting at u * : For a technical reason as in [4,5], we will assume the following condition: for any u * ∈ M * sing , the set of charges Q(u * ) is contained in a half-space in h * . Notice that if the number of hyperplanes at u * is exactly r, this condition is automatically met.

The classical on-shell action
We evaluate the classical action Z cl (u,ū, D 0 ; m) on almost-BPS configurations, where u is constant, D = iF 12 + D 0 with constant D 0 , but D and F 12 are not necessarily constant. The moduli u,ū, D 0 , m control the expectation values of the bosonic fields in vector multiplets, which can be either dynamical (gauge group G) or external (flavor group G F ), in the Cartan subalgebra. There can also be global topological symmetries, whose moduli are denoted by ξ = e iz and t with z = A (T ) t + iβσ (T ) . The classical action terms in the Abelian case are the following.
• The Abelian YM action (2.10) contributes As S YM is Q-exact, it vanishes on actual BPS configurations where D 0 = 0.
• The Abelian Chern-Simons action (2.12) contributes where x = e iu . Notice that if k is half-integer, this is not a single-valued function of x. This is related to the fact that a half-integer CS level might be required to cancel a parity anomaly from the matter sector.
• The mixed CS term between two Abelian symmetries (2.13) contributes If one of the two Abelian symmetries is flavor, we drop the corresponding D 0 term.
• The topological term (2.15) contributes We recall that Im z is essentially a FI term, while Re z is a sort of 2d θ-angle on S 2 .
• The mixed CS term between the R-symmetry and an Abelian gauge or flavor symmetry (2.16) contributes The previous expressions are straightforwardly generalized to the non-Abelian case by replacing u, D 0 and m with elements of the Cartan subalgebra h and contracting all products with the Killing form. The total classical action Z cl is the product of the relevant terms. Let us also evaluate the Wilson loop defined in (2.21). Using x µ (τ ) = (θ 0 , ϕ 0 , τ ) and the fact that A t , σ are constant, the loop reduces to W = Tr R exp i dt (A t + iβσ) . Therefore (2.41) Notice that the classical action for D 0 = 0, which we denote as is a holomorphic function of u.

One-loop determinants
Next we compute the one-loop determinants from chiral and vector multiplets, obtained by integrating out all their non-zero modes and keeping the dependence on D 0 which serves as a regulator of the final expression. 8 The derivation is given in appendix A.
Chiral multiplet. Consider a chiral multiplet Φ transforming in some representation R of the gauge and flavor symmetry group G × G F , and immersed in a constant magnetic flux m on S 2 along the Cartan subalgebra. Consider a single component Φ ρ , transforming as the weight ρ ∈ R and with R-charge q ρ (to weights in different irreducible representations we can assign different R-charges). We write b ≡ ρ(m) − q ρ (2.43) for the total flux seen by the scalar component of Φ ρ . The bosonic determinant is given by (2.44) 8 While the determinants at D0 = 0 can be computed, with a cohomological method in appendix A, for generic metric on S 2 and generic supersymmetric F12, for D0 = 0 we use the round metric on S 2 and take constant F12.
Notice that for non-vanishing values of ρ(σ) or ρ(A t ), the zeros of det O φ are strictly in the half-plane Im ρ(D 0 ) > 0 in the complex D 0 -plane. The fermionic determinant is given by where s = sign(b + 1). The one-loop determinant is the ratio of the fermionic and bosonic determinants, and in general it is a function of u andū. For generic D 0 there are no cancelations among the massive modes. We will be eventually interested in the one-loop determinant for D 0 = 0. In that case all massive modes cancel out and we are left with This expression requires regularization. We use k∈Z α(u−2πk) = −2i sin u 2 , where the prefactor α is irrelevant, and find , where x = e iu and x ρ ≡ e iρ(u) . This determinant is a meromorphic function of u, and we denote it by Z chiral 1-loop (u; m) ≡ Z chiral 1-loop (u,ū, 0; m). It has a simple Hamiltonian interpretation, and our normalization was chosen accordingly. The magnetic flux on S 2 generates Landau levels, which in the quantum mechanics on S 1 are either |b + 1| Fermi multiplets for b + 1 < 0, or b + 1 chiral multiplets for b+1 > 0 (a similar phenomenon has been recently discussed in [31,32]). In the first case, the Fermi multiplet contains a spinor whose Hilbert space is a fermionic Fock space, and assigning charge − ρ 2 and fermion number 0 to the vacuum, the index is In the second case, the chiral multiplet contains a complex scalar φ and a spinor, and the Hilbert space is the product of a bosonic Fock space generated by φ, φ † and a fermionic Fock space; assigning fermion number 1 to the vacuum, the index is (− Eventually, taking into account all weights ρ of the representation R, we obtain: Notice that this one-loop determinant may have singularities when x ρ = 1, corresponding to the presence of bosonic zero-modes. Notice also that (2.48) may not be single-valued in x: this is a manifestation of the parity anomaly and, when x parameterizes gauge flat connections, must be canceled by a choice of half-integer CS level in (2.37).
At this point we would like to comment on a sign ambiguity, which originates from the ambiguity in the quantization of the fermionic Fock space (the Ramond vacuum). The determinant (2.48) gets contributions from fermionic chiral zero-modes on S 2 . The fermionic operators ψ 0 ,ψ 0 satisfy the anticommutation algebra ψ 2 0 =ψ 2 0 = 0, {ψ 0 ,ψ 0 } = 1, so we interpret them as creation and annihilation operators for a fermionic Fock space |± withψ 0 |− = 0, ψ 0 |− = |+ . The two states have opposite fermion number, and flavor charges that differ by ρ. We could decide that |− is the vacuum-a bosonic neutral state: this leads to a determinant 1 − x ρ . However the two states have the same energy, therefore we could rather decide that |+ is the vacuum, leading to −x −ρ + 1. A more democratic choice is to assign the two states flavor charges ± ρ 2 , leading to x −ρ/2 − x ρ/2 , which is our choice. These ambiguities correspond precisely to ambiguities in the regularization of the determinant. Even with our democratic choice, we are still left with a sign ambiguity in the assignment of the fermion number, leading to an ambiguity (−1) ρ(m) for the determinant. If m is for a global symmetry and so it is a fixed parameter, this is just a total sign ambiguity of the index; but if m is for a gauge symmetry and so it is summed over, it may appear that it drastically affects the partition function. However in three dimensions, if the gauge group is Abelian the ambiguity can be reabsorbed in a redefinition of the fugacity ξ for the associated topological symmetry, see (2.39); if instead the gauge group is semi-simple the ambiguity cancels out. Because of this ambiguity, in our examples we will choose the signs at our convenience.
When we integrate out a chiral multiplet with large real mass M , we obtain an effective shift of the Chern-Simons levels of all groups the chiral multiplet is charged under [33][34][35]. Let us check that this is reproduced by the one-loop determinant. Consider, for example, a chiral multiplet charged under many different U (1)s. A real mass M can be turned on by giving an expectation value to the scalar σ F in the flavor vector multiplet that rotates the chiral multiplet. The one-loop determinant of such a chiral multiplet, which we take of R-charge 1 for simplicity, 9 becomes (2.49) Comparing with (2.38), we recognize in the first term a shift of the U (1)s CS levels, which precisely reproduces the known result [35]. The sign ambiguity in (2.49) can be reabsorbed in the fugacity ξ of the topological symmetries-see (2.39)-and the exponential in M is a renormalization. For a simple group, the same computation reproduces the shift where T 2 (R) is the quadratic index of R defined by ρ∈R ρ a ρ b = T 2 (R) K ab in terms of the Killing form K ab (and h = 1 2 T 2 (adj) is the dual Coxeter number). For instance for SU (2), T 2 (spin I) = 2I(I + 1)(2I + 1)/3.
Higher genus. If we place the theory on a Riemann surface Σ g of genus g, instead of on the sphere S 2 , we can still compute the one-loop determinant (see appendix A). The only difference is the number of units of R-symmetry flux: 1 2π Σg W = g − 1. By the index theorem, the number of right-moving minus left-moving modes on Σ g is n R − n L = ρ(m) + (g − 1)(q ρ − 1), therefore the one-loop determinant is . (2.52) Notice in particular that this is independent of the flat-connection moduli on Σ g .
The gauge multiplet. The one-loop determinant for the gauge multiplet can be computed in many ways. On the round sphere with constant magnetic flux we could compute it mode by mode as in [18,19]. In the general case, we could use the cohomological argument of appendix A along the lines of [36]. More quickly, we notice that the modes along the Cartans are not charged under gauge or flavor symmetries, and so can be discarded. The off-diagonal modes contribute, possibly up to a flux-dependent sign, as chiral multiplets with R-charge 2 and transforming as the roots α of the gauge group. This can be understood from the Higgs mechanism. Suppose that a generator α is broken, then the gauge field will eat a chiral multiplet and become massive. The eaten chiral multiplet has no flavor charges, it transforms as α under the gauge group and it has R-charge zero (otherwise its VEV would break some global symmetry). Since massive fields do not contribute, we have Z gauge 1-loop Z chiral 1-loop = 1, up to a flux-dependent sign. This equation is also satisfied by two chiral multiplets of R charge two and zero which can by paired by a quadratic superpotential term and integrated out. This determines Z gauge 1-loop . Moreover, because of the bosonic zero-modes, it is natural to interpret Z gauge 1-loop as a middledimensional holomorphic form on M, therefore we attach the differential d r u to it, where r is the rank of the gauge group. We thus have: Here δ = 1 2 α>0 α is the Weyl vector, 10 and we have fixed the sign ambiguity for later convenience. We see that Z gauge 1-loop is just the Haar measure for the group G. The measure does not have any divergence: this is related to the fact that there are no flat connections on S 2 .
We define the total classical and one-loop contribution as which is a holomorphic r-form. 10 Recall that 2δ is always a weight, therefore 2δ(m) ∈ Z. For semi-simple groups also δ is a weight, but this is not true for Abelian factors. For instance for U (N ): Higher genus. We can similarly write the gauge one-loop determinant on a Riemann surface of genus g: This time there are singularities associated to Z gauge 1-loop . This is expected: when x α = 1, there is enhanced non-Abelian gauge symmetry and there are extra bosonic zero-modes parameterizing the flat connections on Σ g , which are associated to poles of the determinant.

Asymptotic behavior
In the following sections we will need the asymptotic behavior of the one-loop determinant for large values of the moduli σ, which, as we saw around (2.49), is related to a one-loop shift of the Chern-Simons levels. In an N = 2 U (1) theory with chiral multiplets of charges Q i and Chern-Simons coupling k, we can define an effective Chern-Simons coupling as a function of the vacuum expectation value of the scalar σ [35]. The shift comes from integrating out the matter fermions which have mass |Q i σ|.
The correction in (2.56) is reflected in the asymptotic behavior of the one-loop determinant for a chiral field. The bare CS term contributes like in (2.37), x km e 2ikβR 2 σD 0 , while the one-loop determinant for a field of charge Q i provides for large |σ|: The two contributions combine into and precisely reproduce the correction in (2.56). To see how this works, we need to study the asymptotic behavior of the one-loop determinant as σ → ±∞ for generic values of D 0 . For b > 1, the determinant for a chiral field of charge 1 is while for generic charge we simply have to reinstate Q i in front of A t , σ, D 0 and m. The second product becomes 1 when D 0 = 0, and the first product, after regularization, is the determinant we found in (2.48). The limit of (2.48) for large |σ| produces the first factor in (2.57). Consider now the second factor in (2.58). Its product over k is convergent and can be performed explicitly: calling F its product over k and n, we find We are interested in the behavior of F for |βσ| ≫ 1. In this limit we have It follows that log F is a linearly divergent sum over n. The divergent term can be computed with ζ-function regularization: − n≥0 iβRD 0 = i 2 βRD 0 . We can approximate the remaining convergent sum over n with an integral: Reinstating the charge Q i , we finally find The first dominant term gives the second factor in (2.57). A similar computation works for b < 1.
For a general theory we can have mixed Chern-Simons terms and the expression in (2.56) is replaced by where the indices a, b, c run over the generators of the Abelian gauge groups, i runs over the different matter fields and Q a i are the gauge charges. The correction (2.62) is correctly reproduced by the asymptotic behavior of the one-loop determinant.

The final formula: rank-one case
The last step is to integrate the classical contribution and the one-loop determinant over the moduli space of BPS configurations, taking properly into account the various zero-modes. We follow the strategy used in [4,5]. There are some new features related to the non-compactness of the moduli space and the presence of magnetic fluxes. In order to clearly explain the physical ideas, we first consider the case of rank-one gauge groups.

The integral and the dangerous regions
We place 1/e 2 in front of the Yang-Mills Lagrangian L YM and 1/g 2 in front of the matter Lagrangian L mat , and consider localization as e, g → 0. For non-zero couplings e, g, the pathintegral takes the form of an integral over the supermanifold of vector multiplet bosonic and fermionic zero-modes. We can write it as where the integration is over the bosonic zero-modes-the moduli space M ∼ = C/2π of flat connections-while F e,g is the result of the path-integral over the fermionic zero-modes and all other massive modes (we will soon see that this expression is not complete).
There are some dangerous regions in M when we take e → 0 and/or g → 0. The dangerous regions are the points u * ∈ M sing defined in (2.33) where, in the e → 0 limit, extra scalar zeromodes from chiral multiplets appear. Suppose that for u ∼ u * there are M quasi-zero-modes φ i , whose charges Q i have-by assumption-the same sign. Then the integral over the modes looks like where ζ eff is the effective FI term at the point u. Here g can be reabsorbed in the measure for the quasi-zero-modes, therefore g → 0 does not pose any problem. On the contrary, the second term comes from the D-term potential and it ensures that the integral is convergent, even at u = u * , therefore taking the limit e → 0 is problematic. Let us find an upper bound on |I| at small but fixed e. As a function of u, |I| is maximized at u = u * . By rescaling φ i → φ i In the limit that e is small, we can neglect the term in ζ eff and the integral can be performed: So, taking the limit of F e,0 (u,ū) as e → 0 at u = u * is problematic, since we remove the quartic potential and generate illusive singularities. The resolution is the same as in [4]. We first remove from M an ε-neighborhood ∆ ε of M sing and split the integral in two pieces: The second integral is bounded by ε 2 /e M up to constants, therefore in a scaling limit e, ε → 0 such that ε 2 /e M → 0 as well, the second term does not contribute. We thus have With respect to [4] we have to be more careful, though, because M is non-compact. This is similar to the setup in [6][7][8]. Since M ∼ = C/2π is a cylinder, we might have a problem when integrating over the zero-mode Im du = β dσ. Let us estimate the behavior of the integral. For σ → ±∞, all chiral multiplets are massive and their effect is to shift the bare CS level k as in (2.56). Let us call k ± the values of the effective CS for σ → ±∞. The dangerous part of the integral is then, after integrating out D: where some unimportant constants have been dropped. When k ± = 0, the integral is convergent for any e = 0 but becomes singular in the limit e → 0. The resolution is again to remove an ε-neighborhood of infinity in M by considering a large number L(ε) and including in ∆ ε the two regions |σ| ≥ L. Consider the integral on the region σ ≥ L (the case σ ≤ −L is equivalent). For e → 0 we can neglect ζ, and we are left with , it is sufficient to take a scaling limit e, 1 L → 0 such that eL grows as a negative power of e, then the integral over σ ≥ L does not contribute. In fact, we will take a stronger scaling limit in which e 2 L diverges as e → 0. When k ± = 0 the integral is potentially divergent. The trick we will employ is to introduce a Lagrangian term iκ reg σD and take the limit κ reg → 0 ± . We will verify that the result is the same for the two limits, and it is finite.
In conclusion, by using the convention that we include in the definition of ∆ ε also the two regions at infinity and we take a suitable scaling limit, the path-integral is still given by (2.65).

Configurations with flux
There is another important difference with respect to the elliptic genus computation in [4] and the quantum-mechanical index in [6][7][8]. In those cases, the superalgebra fixes F µν = D = 0 on BPS configurations independently of the real contour chosen, while in our case the superalgebra allows generic D(x) = iF 12 (x) for complex D(x). It is well-known that the saddle-point approximation to an integral along the real line can get contributions from saddle points away from the real line; therefore, let us investigate whether configurations with flux contribute.
Consider a generic real configuration F 12 (x) and D(x). As long as e > 0, this configuration is suppressed by the classical action weight This configuration is not BPS. However if F 12 (x) and D(x) are actually constant, then the configuration is on the complex orbit of the auxiliary zero-mode D 0 originating from the BPS configuration D(x) = iF 12 (x) = im 2R 2 . In other words, We have computed the effective action Z(u,ū, D 0 ; m) for the multiplet of zero-modes, obtained by integrating out all massive modes, around generic BPS configurations with complex D(x). Such an action depends on the constant mode D 0 , and it is valid for all D 0 ∈ C. We thus learn that configurations with constant F 12 are special because, starting from the BPS point and taking D 0 ∈ R − im 2R 2 , we reach the real contour D(x) ∈ R we are integrating over, even though such real configurations are no-longer BPS. Let us analyze the contribution of these almost-BPS configurations to see whether it vanishes in the limit e → 0 or not.
The contribution of configurations with flux F 12 = m 2R 2 can be written as where N is a normalization constant we will fix later. Here Z(u,ū, λ 0 , λ † 0 , D 0 ; m) is the effective action for all zero-modes (including the fermionic ones) in the multiplet, and it is the result of integration over all massive modes. We will analyze this function more in details in the next subsection. To compute the integral, we shift the D 0 integration contour along the imaginary axis until it reaches the real axis. When we do that, we can encounter poles of Z located at the zeros of det O φ in (2.44), and we should pick the residues. However such residues are weighted by the suppression factor (2.66): using the fact that the poles are at Re D 0 = 0. Therefore, all these residues are suppressed in the limit e → 0 and we can neglect them. 11 Once the contour has been shifted to the real axis, the result is no longer exponentially suppressed by (2.66), and therefore it survives in the limit What about all other configurations where F 12 (x) is not constant? The corresponding BPS configurations have imaginary D-term D(x) = iF 12 (x), and the complexified orbit of the auxiliary zero-mode D 0 spans D(x) = iF 12 (x) + C. If F 12 (x) is not constant, then the orbit never intersect the real contour D ∈ R and the BPS configurations do not play a rôle in the exact saddle-point approximation to the real path-integral.
To summarize, the full path-integral reduces to a sum/integral over the bosonic moduli space M BPS in (2.25) of BPS configurations with constant magnetic flux, as well as an integral over the fermionic zero-modes.

Reduction to a contour integral
Eventually, the expression for the path-integral that we need to evaluate is where Z m is the contribution from configurations with constant flux F 12 = m 2R 2 , the sum is over the co-root lattice, and |W | is the order of the Weyl group. In particular the normalization has been fixed comparing with one example, and Z(u,ū, λ 0 , λ † 0 , D 0 ; m) is the effective action for the complete multiplet of zero-modes, obtained by integration over the massive modes around configurations with flux m. Setting λ 0 = λ † 0 = 0 we recover the classical and oneloop expressions discussed in sections 2.2.3 and 2.2.4: while setting D 0 = 0 we obtain the holomorphic expression Z(u,ū, 0; m) ≡ Z(u; m). The function Z is holomorphic in D 0 around the origin as long as u ∈ ∆ ε . Therefore we have the freedom to shift the real integration contour on the complex D 0 -plane along the imaginary direction, as long as this shift is small: in (2.69) we have called η such a shift.
The action Z(u,ū, λ 0 , λ † 0 , D 0 ; m) depends on the gaugino zero-modes because of the Lagrangian couplings λψφ to the matter fields we have integrated out. The dependence on λ 0 and λ † 0 could be determined by an explicit computation as in [4,5], but we can use a shortcut exploiting supersymmetry. The integration over the fermionic zero-modes gives . This expression can be simplified using the fact that Z is supersymmetric. From We can thus write 12 (2.72) The same expression was found in a similar context in [4,5]. The higher-rank generalization is discussed in section 2.4.
The second expression in (2.72) seems to have a pole at D 0 = 0, however there is no pole in the first expression because ∂ūZ(u,ū, 0; m) = 0. In fact each separate connected component of ∂∆ ε gives rise to a pole, while their sum does not. Let us consider each of them separately.
where C ′ is non-negative, vanishing only for n = 0 and b ≥ 0.
If ρ < 0 the poles are in the negative half-plane. As ε → 0, the poles for n = 0 collapse towards D 0 = 0 (because |u| ∼ ε on the contour ∂∆ ε ), however the contour R + iη is safely far from them. The D 0 -integral remains finite as u → 0, and then the u-integral vanishes because its contour shrinks. On the contrary, if ρ > 0 the poles are in the upper half-plane and, as ε → 0, they would cross the contour R + iη. To avoid that, we shift the contour to R − iη and we collect minus the residue at D 0 = 0. As before, the integral along R − iη does not yield any contribution as ε → 0. Minus the residue at D 0 = 0, though, gives 12 We use d 2 u = i 2 du ∧ dū and ∂(M \ ∆ε) = −∂∆ε.
since Z(u,ū, 0; m) is holomorphic in u and there is no dependence on e anymore. Suppose, instead, that we have chosen η < 0. A similar argument goes through, and we obtain minus the residue at u = u * if ρ < 0, zero if ρ > 0.
We reach the conclusion, as in [4], that for η > 0 we collect the residues of Z(u; m) at the points u * ∈ M + sing corresponding to chiral fields with positive charges, while for η < 0 we collect minus the residues at the points u * ∈ M − sing corresponding to chiral fields with negative charges. This operation is called the Jeffrey-Kirwan residue [9]: where Q(u * ) is the set of charges of the fields responsible for the pole of Z(u; m) at u * . We can rewrite the expression in the x-plane: (2.74) • Consider the two components of ∂∆ ε around Im u = ±∞. They give a contribution Z bdy m as in (2.72), with The three terms come from (2.66), (2.37) and (2.39), respectively. We have used that the asymptotic behavior of the one-loop determinants shifts the bare CS level k as in (2.56), and we have denoted the effective CS level for Im u = ±∞.
Consider first the case that k ± = 0. We have to evaluate the integral over D 0 ∈ R + iη in the scaling limit e → 0 with e 2 σ → ∞, therefore the terms containing m and σ (T ) are negligible. We can make use of We are left with a contour integral of Z(u; m) around the two infinities, which can be written more elegantly as a Jeffrey-Kirwan residue on the x-plane, 13 13 The residue at infinity is defined with a clockwise contour: Res if we assign charge vectors to the singularities at x = 0, ∞ according to the effective Chern-Simons levels: If k + = 0 or k − = 0 we need to regularize the integral on σ: we choose to do it by adding a Lagrangian term −iκ reg σD and then taking the limit κ reg → 0 ± . We show in section 2.3.4 that the result is independent of the sign of κ reg , and in fact it is zero. Hence the prescription is that we do not take any residue at infinity when k ± = 0.
The full path-integral is obtained by summing Z bulk m and Z bdy m over all magnetic fluxes. In the rank-one case, we can elegantly write both contributions as JK residues on the complex x-plane. Moreover, the holomorphic 1-form Z(x; m) dx x is precisely the product of classical and one-loop contributions of section 2.2.3 and 2. (2.80)

Cancelation of boundary contributions
It remains to verify that our regularization of the boundary contribution through κ reg , when k ± = 0, leads to zero (and in particular it is independent of the sign of κ reg → 0 ± ). Consider one boundary component, either u = +∞ (x = 0) or u = −∞ (x = ∞). For one sign of κ reg , we simply do not collect the residue for any value of m and we obtain trivially zero. For the other sign of κ reg , instead, we should sum the residues for all values of m. Since k + = 0 or k − = 0 by assumption, the leading behavior of Z 1-loop around x = 0 or x = ∞ does not depend on m (a CS term appears as a factor x km ), although there can be a dependence on m in the subleading terms in the series expansion. It follows that, depending on the value of the external fluxes, either we have a pole (of the same order) for all values of m or for none. In the latter case we get zero. In the former case, after a suitable expansion and up to a shift in m, the residues will be sums of terms of the form m a z m . We should then evaluate the objects These sums are not convergent, but can be defined via ζ-function regularization or analytic continuation. First of all Then all s a (z) can be formally obtained by taking derivatives of s 0 (z), and therefore they all vanish. We conclude that the sum over m of the residues vanish. As a further check, we will confirm in some of our examples that, as we change η and the JK residue picks up different contributions from the singularities in the "bulk" and from the boundaries, we always find convergent and well-defined expressions which eventually do not depend on η.

The integral: higher-rank case
The generic case of a gauge group G of higher rank r can be tackled with the same physical ideas, however it becomes technically more involved because of the richer topology of the moduli space M and the singular subset M sing . The space M = H × h is the product of r complex cylinders. The singular subset M sing is a collection of hyperplanes H i . Moreover we have to decide how to regularize the non-compact manifold M at infinity. Eventually, M \ M sing has a complicated topology.

Integration domain
In section 2.2.2, to each chiral multiplet Φ i we have associated a charge covector Q i ≡ ρ i ∈ h * equal to the gauge weight, and a "singular" hyperplane (with the topology of T r−1 × R r−1 ) which is the dangerous locus where a would-be zero-mode may appear as e → 0. Since the hyperplanes are defined by an equation with real coefficients, their restriction (or imaginary projection) to h is well-defined. To each hyperplane we associate an ε-neighborhood (2.82) We also need to introduce "hyperplanes at infinity" and remove their neighbourhoods. The simplest choice would be to remove, for each a = 1, . . . , r, the locus ± Im u a > L, where L scales in a suitable way with ε. This, however, would lead to an expression difficult to evaluate. As we already saw in the rank-one case, the integral over D 0 near the boundary depends on the asymptotic value of the effective CS levels (2.62), and the formula has a jump as we cross the restriction of an hyperplane on h. When an hyperplane H i intersects a boundary locus, it divides its restriction on h into parts with different values of the effective CS levels. To avoid this complication, we cut a series of boundaries H ∞ α at infinity, defined by linear equations where L α (ε) is a large cut-off. The H ∞ α s have the topology of T r × R r−1 , and their restriction to h defines a convex polyhedron around infinity. We choose the polyhedron with the property that every face H ∞ α that intersect one or more matter hyperplanes H i , is orthogonal to all of them with respect to the Killing form K ab (actually, we could use any arbitrary positive-definite metric K ab on h): We can then associate a charge vector Q α ∈ h * to each face, in analogy with what we did in the rank-one case: If the matrix k eff K −1 k eff is positive definite, we can neglect ζ and the integral is convergent-in particular the region outside the convex polyhedron has vanishing contribution as the polyhedron is expanded. If, instead, the matrix has some zero eigenvalue, we can always introduce the regularization term σ a κ 2 reg K ab σ b . For simplicity, we will use the index i for all neighbourhoods, including those at infinity. For the hyperplanes at infinity we take cut-offs L α (ε) which suitably scale with ε. We then define and consider the integral over M \ ∆ ε .

Stoke relations
As in the rank-one case, the path-integral reduces to . (2.87) In order not to clutter formulas, we have dropped the subscript 0 from the zero-modes. Since Z is holomorphic in D around the origin, we have shifted the D integration contour by a small vector δ ∈ h. Following [5], we can use some "Stoke relations" to reduce the integral over M to the contour integral of a meromorphic r-form along a specific r-dimensional cycle. We refer to [5,6] for the detailed argument, while here we just point out the peculiarities of our case.
To absorb the zero-modes, we use the following construction. First, as in (2.70), supersymmetry guarantees that We define the following (r − n)-forms, for n = 0, . . . , r: .
(2.89) With a little algebra, one can show that (2.88) implies the relations where means omission and∂ ≡ dū a ∂ ∂ūa . Then define the forms where Q i ∈ h * are s covectors. Using the previous relation we get These forms are useful because with no vectors, is the integrand of the partition function Z m , while with r vectors, where the last term is the classical and one-loop action.

Reduction to a contour integral
The boundary of the integration domain M \ ∆ ε is separated into "tube regions" with the natural orientation which makes them antisymmetric in the indices. They satisfy as proven in [5]. Each manifold S i 1 ...is has real dimension 2r − s if not empty. Therefore the decompositions in (2.97) are almost disjoint: every intersection has dimension lower than the components, and the integral over the union is the sum of the integrals. We can construct, as in [5], a cell decomposition of M \ ∆ ε such that: and each C i 1 ...i k is associated to the set of charges Q i 1 , . . . , Q i k of the hyperplanes {H i }. Recall that we are using the index i for all hyperplanes including those at infinity. We can use repeatedly the Stokes relations to reduce the integral over M \ ∆ ε to an integral over a middle-dimensional cycle in du. The argument goes exactly as in [4,5]. We do not repeat all the steps of the argument, which has been spelled out in details in [4,5] and [6], but we simply review the logic and mention the necessary modifications to deal with the boundary components.
The partition function is given by the integration of the form µ (2.93) on a 3r-cycle given by Γ × M \ ∆ ε where Γ = h + iδ is the contour for the D-integration, shifted from the real"axis" by a small vector δ ∈ h. The integral can be manipulated by using iteratively the Stokes relations starting from the cell decomposition (2.98); for example, as in [4,5], one can derive In using the Stokes relations we generate poles in D with denominator Q i (D) and we restrict the variable u to live near the hyperplanes H i . At each step we can deform the contour on D and pick residues at the poles in analogy with what we did in the Abelian case.
Consider for example the integral µ Q i on the contour Γ × S i . We need to distinguish the case where i refers to a matter hyperplane and the case where i refers to a boundary at infinity. The latter case is the new ingredient compared to [4,5].
Near a singularity due to a chiral field with vector charge Q i , the D integral is zero if Q i (δ) < 0 because we can shrink the integration domain S i without encountering singularities, exactly as we did in the Abelian case. If Q i (δ) > 0, we modify the D contour by changing δ until we can shrink the integration domain. We are left with an integral over a contour Γ i , which consists of a circle around zero in the variable Q i (D) and is parallel to the real "axis" with an imaginary shift iδ i in the remaining r − 1 variables with Q i (D) = 0. The shift δ i must satisfy Q i (δ i ) = 0, and is different from the original δ.
Near a boundary component specified by the equation γ i (Im u) = L i , we can parameterize where η a satisfies γ(η) = 0 and spans the plane. The integral in D contains the terms where the charge of the hyperplane at infinity was introduced in (2.85). For large L i , the imaginary part of the exponent is controlled by the sign of Q i (D), and we can close the contour in the variable Q i (D) by adding a semi-circle in the lower half-plane. By rescaling D → eD, the classical and one-loop contributions become independent of D in the limit e → 0 and the only pole comes from 1/Q i (D). If Q i (δ) < 0, there are no poles in the integration contour and we obtain zero. 14 If Q i (δ) > 0, we modify the contour by changing δ and we are left with an integral over a contour Γ i which circles around zero in the variable Q i (D), and is parallel to the real "axis" but shifted by an imaginary shift iδ i , with Q i (δ i ) = 0, in the remaining variables. Each term in (2.99) can be further manipulated using the Stokes identities; for example we can derive, as in [4,5], At this point, using the same argument as above, Γ i can be deformed to a contour Γ ij which circles around Q i (D) = Q j (D) = 0. The process can be iterated until we obtain a sum of terms of the form 14 One might worry that, moving along the hyperplane at infinity, ηa can become so large to change the sign of the imaginary part. However, in the limit e → 0, the boundary integrals are dominated by the region D ∼ 0; for large ηa we are far from the matter singularities, the integrand is a regular function of D and the rescaling D → eD shows that Γ×S i 1 ,··· ,is µQ i 1 ,··· ,Q is with s < r vanishes with some power of e. It remains to analyze the terms with r = s which are r-dimensional integral in du near the intersection of r hyperplanes (we can always choose a boundary contour such that no more than r hyperplanes intersect in a point). If we are at the intersection of a boundary hyperplane with matter hyperplanes, the ηa are finite and there is no problem. If we are at the intersection of two or more boundary hyperplanes, the ηa can be large. However, we can always arrange our cut-off at infinity in a hierarchy L1 ≫ L2 · · · . On the boundary hyperplane with the largest value of Li the corresponding ηa will be necessarily smaller than Li and the argument applies.
where Γ i 1 ,...,ir is a T r contour around the origin in the D plane. The integral over D picks up the residue of the denominator 1/Q i 1 (D) · · · Q ir (D) and gives ±1. After the D integration, the integrand becomes the classical and one-loop action Z int (u; m). The difficult part of the story is to keep track of all non-vanishing contributions, or their signs and of the necessary shifts in the D contour. This can be done by the method explained in [4,5] which introduces a reference covector η ∈ h * . The final result is given, after summing over the fluxes, by and it is independent of the choice of the reference covector η.
The integrand Z int (u; m) has singular points where r or more linearly independent hyperplanes intersect and (2.102) reduces to a computation of residues. At points u * where only matter hyperplanes intersect-the set of such points was called M * sing in (2.34)-the expression in (2.102) is precisely the definition of the Jeffrey-Kirwan residue [9], as shown in [4,5]. We can thus write the partition function as In this formula, u * are intersections of the matter hyperplanes only, and Q(u * ) is the set of charges of the hyperplanes intersecting at u * . The boundary contribution refers to the intersection of hyperplanes at infinities, among themselves or with matter hyperplanes, and it should be computed using (2.102). We can simplify the evaluation of the boundary residues by choosing a convenient boundary polyhedron. With an appropriate sets of linear forms γ i , we can restrict to the case where the intersections at infinity are transverse and no more than r boundary or matter hyperplanes meet at the same point: in that case, the contour S i 1 ,...,ir is simply a r-dimensional torus. For r − s boundaries meeting s matter hyperplanes, we need to perform an integration over the r − s angles Re u of the boundary component and an integration over an s-dimensional contour which circles around the s matter hyperplane singularities, computing the residue at the corresponding pole. It would be interesting to give a proper geometrical interpretation of the boundary contribution, maybe as some generalization of the Jeffrey-Kirwan residue [9].

Examples
In this section we compute the partition function for various examples of Abelian and non-Abelian theories in order to demonstrate the use of our formula. We discuss examples of Yang-Mills-Chern-Simons theories with (anti)fundamental and adjoint matter. We will be able to recover and generalize standard results about Chern-Simons theories and to confirm various dualities between three-dimensional theories with matter. Our results can be interpreted both as a check for our prescription as well as further evidence for three-dimensional dualities.

Yang-Mills-Chern-Simons theories with fundamental matter
We first discuss in details the case of U (1) theories which nicely exemplify our prescription for computing the topologically twisted partition function and illustrate many subtleties. As non-Abelian examples we consider the Aharony [12] and Given-Kutasov [13] dual pairs.
We start considering a U (1) theory with Chern-Simons coupling k = 1 2 and one chiral multiplet X of gauge charge 1. Since this is our first example, we are pedantic and give many details.
The chiral fields and charges are: Here T,T are the monopole operators V m corresponding to magnetic fluxes m = 1 and m = −1, respectively, which play an important rôle in the identification of the dual theory [35]. Their charge Q under a generic flavor or R-symmetry is determined using the formula where the sum runs over all fermions in the theory and ρ i are their gauge charges. The same formula determines the one-loop contribution to the gauge charge of the monopole V m to be added to the classical contribution km. The only flavor symmetry in the theory is the topological one, denoted as U (1) T , under which only the monopoles are charged. We choose R-charge q = 1 for the chiral multiplet, so that the fermion has R-charge zero, and no mixed gauge-R-symmetry CS term is necessary. 15 The matter content of the theory is not invariant under charge conjugation, signalling potential parity anomalies. These are however compensated by the half-integral Chern-Simons coupling. One can see this by noticing that the effective Chern-Simons coupling (1.10), is always an integer, implying the absence of parity anomalies. According to our rules, we construct the partition function by including the following ingredients: • a measure dx 2πi x on the x plane; • the classical CS action contribution (1.5) which, for k = 1/2, reads x m/2 ; 15 The gaugino has R-charge 1 and is gauge neutral. Therefore, strictly speaking, the theory requires a halfintegral R-R CS term. However we neglect such term because it does not introduce a dependence on the parameters, and it gives at most a constant phase.
• the one-loop contribution (1.3) of a chiral multiplet of gauge charge 1 and R-charge 1 which reads • the contribution (1.7) x t ξ m for the topological symmetry, where ξ and t are the fugacity and the background flux for U (1) T .
The partition function is then given by the contour integral We included an extra (−1) m , which can be reabsorbed in the definition of ξ, for later convenience.
The contour integral should be evaluated according to formula (1.13). The integrand has singularities at x = 1, x = 0 and x = ∞. The charge vector for x = 1 is given by the charge of X, Q x=1 = 1. The charges at "infinity" are related to the asymptotic CS levels by (1.11): they In order to use formula (1.13) we need to choose a number η. If we choose η > 0, the formula instructs us to take the residues at the singularities with positive charge. We thus need to pick the residue at x = 1 which exist for m ≥ 1. We get where (x) n = n−1 j=0 (x + j) is the Pochhammer symbol (for n ∈ Z ≥0 ). We could obtain the same result by resumming the integrand over m ≥ 1 first and then taking the residue. We are interested in the poles at x = 1, which exist for m ≥ 1, and we can take a contour with |1 − x| = α as long as α < 1. The series to sum is m≥1 ξx/(x − 1) m , which converges uniformly along the contour for sufficiently small ξ. We find (3.5) We have taken the residue at x = (1 − ξ) −1 , which is the only pole inside the integration contour. If we choose η < 0, instead, we should take minus the residues at x = 0. The result is the same. The residues at zero are indeed It is well known that the theory above is dual to the theory of a free chiral multiplet, which can be identified with the monopole T [37,38]. Hence the dual theory is a free chiral T of flavor charge 1 under U (1) T and R-charge 0. The dual theory also has half-integral CS terms k T T = − 1 2 and k RT = − 1 2 . 16 We thus have: This agrees with the result (3.4) for the original theory.

SQED with one flavor
Consider a U (1) theory with two chiral multiplets of charges ±1, and no Chern-Simons couplings. The theory is parity-invariant (although turning on a background for the R-symmetry breaks parity, and indeed an R-R CS term is necessary because of the gaugino). The chiral fields are: Here T andT are monopole operators of magnetic charge ±1, respectively. According to our rules, the partition function is where ξ and t are the fugacity and background flux for the topological symmetry U (1) T , while y and n are for the flavor symmetry U (1) A . We included an extra (−1) m , which can be reabsorbed in the definition of ξ, for later convenience. We choose η > 0, and formula (1.13) instructs us to take the residues from the field Q with positive charge, whose pole is at x = 1 y . Since k eff = k = 0, we do not take any residue at x = 0, ∞. There is a pole at x = 1 y only for m ≥ 1 − n. In order to evaluate all the residues, we take a contour around 1 y and sum the integrands. The series is m ξ(y − x)/(1 − xy) m , and we 16 We can start from the duality between U (1) SQED with one fundamental Q and one antifundamentalQ, We turn on a real mass m > 0 for the axial symmetry U (1)A and for U (1)T , the latter corresponding to a FI term ζ = m. In the electric theory, the vacua are at the zeros of the effective D-term "potential" specified by v ′ D (σ) = k eff (σ), vD(0) = ζ. Q andQ are generically massive, with the exception of σ = −m where Q is massless, and σ = m whereQ is massless. Integrating them out we find k eff = 0 for |σ| > m, 1 2 for |σ| = m, 1 for |σ| < m. It follows that the vacua are at σ = −m (where Q is massless) as well as along the flat direction σ < −m parameterized by T ∼ e −σ . Integrating outQ, the effective theory at σ = −m is U (1) 1 2 with a fundamental Q.
On the magnetic side, the effective theory is the free field T with kT T = − 1 2 and kRT = − 1 2 .
have uniform convergence along the contour for sufficiently small ξ. We sum over m ≥ 1 − n and then take the residue at the unique pole inside the contour, namely at x = 1−ξy y−ξ . The result is: (3.10) The dual theory is a Wess-Zumino model with fields M, T,T and a cubic superpotential W = M TT [35]. The partition function is This agrees with (3.10), up to an ambiguous sign (−1) t+1 .

U (N c ) with N f flavors and Aharony duality
The previous example generalizes to higher gauge rank and number of flavors. Consider a U (N c ) theory, with N f chiral multiplets Q a in the fundamental andQ b in the antifundamental representations, and no CS interactions. For simplicity, we only introduce backgrounds for the R-symmetry, the topological symmetry and the U (1) A subgroup of the flavor symmetry acting with the same charge on all chiral fields. We assign R-charge 1 to the chiral fields. Hence: Here T,T are the monopole operators V m corresponding to magnetic fluxes m = (1, 0, . . . , 0) and m = (0, . . . 0, −1), respectively. Their charges under a generic flavor or R-symmetry Q are determined using the formula where the sum runs over all fermions in the theory, R i denote their representations under the gauge group and ρ i are the corresponding weights. 17 The partition function of the theory is given 17 Although the R-charge of the gaugini λ is −1, in (3.12) one should use their complex conjugate λ c with Rcharge R(λ c ) = 1. This is because the Dirac kinetic action, written in terms of λ, λ † in (2.10), has opposite sign with respect to the one for the matter fields ψ, ψ † in (2.17), and therefore the coupling to the gauge field has opposite sign as well. If we rewrite the Dirac term in (2.10) in terms of λ c , λ c † , it gets the same sign as the one in (2.17).

by
, (3.13) where ξ and t are the fugacity and background flux for the topological symmetry while y and n are for the diagonal flavor symmetry. We inserted a factor (−1) N f m i , which can be reabsorbed in a redefinition of ξ, for later convenience.
Since k eff = k = 0, we can ignore the residues at the boundaries. We should choose a vector η ∈ R Nc : we choose η i < 0, hence we have to collect minus the residues from the negatively charged fieldsQ. They are located at x i = y and they exist only for m i ≤ n − 1. In order to evaluate all the residues we can sum the geometric series in (3.13) first: (3.14) In the limit ξ → ∞ the series converges uniformly along a contour that encircles only the relevant poles. We have introduced a factor of (−1) Nc coming from our prescription for η i < 0, and the contours in the previous formula are counterclockwise.
We define the degree-N f polynomial where x α are defined to be its roots, and we easily derive: In (3.14) we should pick the residues at x i = x α i for all choices of N c integers α i ∈ {1, . . . , N f } but, due to the Vandermonde factor i =j (x i − x j ), only the residues where the integers α i are all different give a non-zero contribution. We then obtain where I runs over all combinations C For N f < N c , the expression above obviously vanishes. 18 If N f = N c , there is only one I while I c = ∅. We immediately get The dual theory for N f = N c is given by the fields M ab , T andT , coupled through the superpotential W = TT det M [35]. The partition function of the dual theory is then This agrees with (3.18), up to an ambiguous sign (−1) Nc+t . The expression (3.17) for N f > N c is more complicated but we can use it to check Aharony dualities [12]. The dual theory is a U (N f − N c ) gauge theory with N f fundamentals q a , N f antifundamentalsq b and N 2 f + 2 singlets M ab , T andT , corresponding to the mesons and monopoles of the original theory, with a superpotential W = M ab q aqb + v − T + v +T , where v ± are monopoles of the dual theory [12]. We assign the charges consistently with the original theory: Notice that the dual quarks have R-charge zero and axial flavor charge −1.
The partition function of the dual theory is obtained by multiplying the contribution of the gauge sector for the quarks q a ,q b with the contribution of the singlets M ab , T andT . The first contribution is the partition function for a U (N f − N c ) theory with quarks q a ,q b which we can read from (3.17). According to our assignment of charges, we need to replace the background charge and fugacity for the flavor symmetry by y ↔ y −1 and n ↔ 1 − n, as well as N c ↔ N f − N c . 18 When N f ≤ Nc − 2, this reflects the fact that the theory has no supersymmetric vacuum [12,35]. When N f = Nc − 1 the interpretation is more subtle. The theory has a deformed moduli space given by TT det M = 1 which is a smooth manifold, therefore the theory is IR free. However the equation forces T,T , M = 0, therefore the theory spontaneously breaks the global symmetry U (1)T ×U (1)A×U (1)R to the subgroup U (1) R ′ = U (1)R−U (1)A, which is an IR R-symmetry (it is not the superconformal one, though, which is accidental). For generic background fields, supersymmetry is broken and indeed (3.17) is zero. However supersymmetry is preserved if we set to zero the backgrounds for broken symmetries and only retain the one for U (1) R ′ , which corresponds to ξ = y = 1, t = 0, n = 1. In this case (3.17) is a formal 0/0, which could potentially lead to a finite result. Unfortunately we do not have equivariant parameters in the UV that could "compactify" the moduli space, therefore we do not expect to be able to define a finite partition function.

We find
.
(3.20) Thex β are the roots ofP(x) = ξ(y −1 −x) N f − (1 −xy −1 ) N f = 0, and in factx β = 1/x β . We can thus rewrite Z qq in terms of x β , and convert the products over J into products over J c using the full products in (3.16). We get: The contribution of the gauge singlets is Then the partition function of the dual theory, Z dual = Z qq Z M TT , equals the one of the electric theory up to (−1) Nc+t .

U (N c ) k with N f flavors and Giveon-Kutasov duality
Giveon-Kutasov (GK) duality [13] can be derived from Aharony duality giving a real mass to some of the flavors. Nevertheless, to test our formula, we check GK duality separately. Consider a U (N c ) k theory with N f fundamentals Q a and antifundamentalsQ b . As before, for simplicity we only introduce backgrounds for the R-symmetry, the topological symmetry and the U (1) A axial subgroup of the flavor symmetry, and we assign R-charge 1 to the chiral fields: The partition function is given by . (3.23) As before, we inserted a factor (−1) N f m i for later convenience. Let us choose η i < 0. First consider the case k > 0: we pick minus (introducing (−1) Nc ) the residues at x i = y which exist for m i ≤ n − 1, and minus the residues at x = 0 which exist for . It is convenient to resum over m i ≤ M − 1 for some large positive integer M , in order to include all poles. Looking at the geometric series we see that in the ξ → ∞ limit, the poles of the resummed function lie close to the poles of the separate terms. Resumming the integrand we obtain This expression has poles at x i = y −1 , which are not relevant for us, and at x i equal to one of the N f + k roots of the degree-(N f + k) polynomial in the denominator. Let us call x α , with α = 1, . . . , N f + k, its roots: Notice that as ξ → ∞, the roots converge to y and 0, therefore those are the poles inside our contour. If we remove (x−x α ) from P(x) for one α, and then substitute x → x α in the resummed expression above, the dependence on M disappears: .
We can then write the partition function. Because of the Jacobian, the contributing poles have Then consider the case k < 0: we pick minus the residues at x i = y, and minus the residues at x i = ∞ which exist for m i ≤ −N f n−Nc+t+1 |k| . As before, we can sum over m i ≤ M − 1, obtaining the same expression as before. However, in order to exhibit a polynomial in the denominator, we rewrite it as x This expression does not have poles at x i = ∞. This time the degree-(N f + |k|) polynomial is while the resummed expression, after removing (x −x α ) and substituting x →x α , can be recast asx .
Eventually the partition function reads The dual theory is U (N f +|k|−N c ) −k with N f flavors and N 2 f gauge singlets. Let us compare the two partition functions. For concreteness, let us take level k > 0 in the electric theory and level −k < 0 in the magnetic one (the other case can be obtained by a parity transformation). In the dual theory there is also a different charge assignment, obtained by y ↔ y −1 , n ↔ 1 − n, k ↔ −k, N c ↔ N f + k − N c . The partition function of the gauge sector of the dual theory is then To further massage the expression, we use β∈J, α∈J c as well as Eventually we find , (3.29) where I are combinations of N c different integers, mapping I = J c . This has to be multiplied by where the first term comes from the gauge singlets and the other ones from the global CS terms computed below. The total partition function Z dual −k<0 = Z qq −k<0 Z sing Z CS agrees with the one of the electric theory (3.25), up to an ambiguous sign (−1) Nc+(k−1)t .
Notice that for N c = N f + |k|, Z qq = 1, therefore the partition function of the electric theory equals that of the free mesons (magnetic theory).
Let us reproduce the global CS terms in the dual. To do that, we start with U (N c ) with N f + k flavors (k > 0). We divide the flavors in two groups: Q a ,Q a are N f with charge 1 under U (1) A , while Q P ,Q P are k with charge 1 under a new symmetry U (1) m : We give positive mass associated to U (1) m : then Q P ,Q P can be integrated out and we are left with U (N c ) k with N f flavors. In fact the only CS which is shifted is the gauge one: δk gg = k. By Aharony duality, the dual is U (N ′ c ) = U (N f + k − N c ) with N f + k flavors and many gauge singlets:

Yang-Mills-Chern-Simons theories with adjoint matter
We start with the case of YM-CS theories without matter. The topological twist has actually no effect on an N = 2 Chern-Simons theory without matter: the only fields charged under the R-symmetry are the gaugini that are auxiliary. We can thus compare our results with the CS literature.
Recall what happens for an N = 2 YM-CS theory with simple gauge group G and level k. For |k| < h, where h is the dual Coxeter number of G (for SU (N ), h = N ), the theory breaks supersymmetry; for |k| = h the theory confines; for k > h (we assume positive k for definiteness), the theory is equivalent to the pure bosonic CS theory at level because the extra scalars and fermions in the adjoint can be integrated out shifting the level [39,40]. The partition function for the N = 2 YM-CS theory on S 2 × S 1 is thus 1 for k ≥ h (since the Chern-Simons theory on S 2 has a single vacuum) and the Wilson loops satisfy the Verlinde algebra at levelk [41]. We will verify these well-known facts in our formalism. To compare with the CS literature, we multiply the partition function by a sign factor (−1) r , where r is the rank of the gauge group. We will also consider the case of YM-CS theories with adjoint matter which have been recently related to complex Chern-Simons theory [26].

U (1) k Chern-Simons theory
Consider a pure U (1) k CS theory, which is the same as its N = 2 version since all auxiliary fields are neutral. We introduce a background flux t and a fugacity ξ for the topological symmetry. We have then where we introduced a minus sign for later convenience. Since there are no poles in the bulk, we only have contributions from the boundary. We can choose η ≷ 0, and then we should discuss the two cases k ≷ 0 separately. Eventually we obtain Correctly, for t = 0 we find |Z| = 1 since Chern-Simons theory on S 2 has a single vacuum [41].

U (N ) k Chern-Simons theory
We can similarly consider the theory U (N ) k . The partition function is We have set t = 0 and ξ = 1. We assume k > 0 and we choose η i < 0. We should then take minus the residues at x i = 0. We have poles for m i ≤ N −1 k . We can resum the geometric series for m i ≤ M − 1 for some large positive integer M , obtaining . There are no longer poles at x = 0, but rather at  19 For the last equality we used that, for fixed α: One can explicitly check that this expression gives Z = 1, as expected.

SU (N ) versus U (N )
The partition function of an SU (N ) k YM-CS theory with matter neutral under the center of the group, and the partition function of the U (N ) k theory with the same matter content (and no flux for the topological symmetry) are equal. To see this, we rewrite the Haar measure of U (N ) in terms of those of U (1) and SU (N ) by decomposing x i = zx i with N i=1x i = 1, and use (z,x i=1,...,N −1 ) as coordinates on the Cartan subalgebra of U (1) × SU (N ). The measure factorizes: 20 The partition function of a U (N ) k theory with matter is, up to normalization, where M (x) is the matter contribution and we introduced a fugacity ξ for the topological symmetry. Under the assumption that no matter is charged under U (1), M is a function ofx i only and we can perform the U (1) integral, obtaining a Kronecker delta function: We thus find which is the partition function of an SU (N ) k theory. 21 The dependence on ξ has disappeared.

SU (N ) k Chern-Simons theory and the Verlinde algebra
The partition function of an SU (N ) k theory without matter is equal to the partition function of U (N ) k , and therefore Z = 1 for k ≥ N , as expected on general grounds [41]. It is interesting then to study correlation functions of Wilson loops: their algebra in Chern-Simons theory is known as the Verlinde algebra. In particular, the structure constants of this algebra-computable as 20 Since z N = N i=1 xi, z is only defined up to N -th roots of unit, therefore the final integral should be divided by N . This is compensated by an analogous factor of N in the Jacobian, det ∂(xi, xN )/∂(xj, z) = N z N−1x N where i, j = 1, . . . , N − 1. 21 The sub-lattice of Z N with mi = 0 is the co-root lattice of SU (N ) or, equivalently, the weight lattice of the GNO dual group SU (N )/ZN , as appropriate for a theory with gauge group SU (N ). Indeed, the weights in the U (N ) lattice Z N are also weights for U (1) and SU (N ). The U (1) weight is mi. We can restrict to the SU (N ) weight lattice by gauge fixing the translation symmetry mi → mi + 1 (∀i) of the lattice. Each weight can be brought to the form mN = 0 with this symmetry, and weights with mN = 0 correspond to the full SU (N ) weight lattice. Only those weights with mi = 0 (mod N ) can be reduced to the alternative form mi = 0. Since the SU (N ) center ZN acts with weight mi (mod N ), this is the SU (N )/ZN weight lattice.
the three-point functions of Wilson loops on S 2 × S 1 -encode the fusion rules of primary fields in the Kac-Moody algebra su(N )k [41] . We can extract general information about the Wilson loop algebra by using an argument similar to that in [42]. Consider a generic normalized integral of the form where f is a function on the Cartan subalgebra of SU (N ). Changing the summation variable m → m + δ, where δ is a generic co-root (an element of the weight lattice of SU (N )/Z N ), we find We can apply this relation to a Wilson loop χ λ (x) associated with a representation of highest weight λ and obtain where λ(δ) is determined by reflecting the weight λ + ρ + kδ into the interior of the fundamental Weyl chamber by an element w of the Weyl group W : w(λ + ρ + kδ) = λ(δ) + ρ. Here ρ is half the sum of all positive roots, also known as the Weyl vector. Whenever λ + ρ + kδ is on the boundary of the Weyl chamber and cannot be reflected into the interior, f χ λ = 0. The identities (3.43) can be derived by using the Weyl Character formula where A σ = w∈W (−1) w x w(σ) . The denominator essentially cancels the Haar measure in the correlation functions (3.42). We focus on the terms in the numerator and, using an adapted co-root for each term, we can write If λ + kδ is a dominant weight, the final expression gives the character χ λ+kδ . Otherwise, either λ + ρ + kδ is on the boundary of a Weyl chamber and A λ+ρ+kδ vanishes by definition, or we can find an element w of the Weyl group that maps λ + ρ + kδ into the interior of the fundamental Weyl chamber, w(λ + ρ + kδ) ≡ λ(δ) + ρ, and the final expression gives, up to a sign (−1) w , the character χ λ(δ) . The shifts by kδ extend the ordinary Weyl group to the affine version. The relations (3.43) induce an equivalence among representations and define the Verlinde algebra. Using the relations (3.43), every representation can be identified with one of the integrable irreducible representations of the Kac-Moody algebra su(N )k. The integrable representations are those whose Dynkin labels λ = [λ 1 , λ 2 , ..., λ N −1 ] satisfy λ i ≤k = k−N , or, equivalently, whose Young diagram have the first row of length less than or equal tok (see for example [43]). 22 22 The SU (N ) roots and weights can be written using the standard basis ei of R N and restricting it to the plane orthogonal to (1, 1, . . . , 1), i.e.êi = ei − 1 Using the relations (3.43), we can find the correlation functions of Wilson loops corresponding to integrable representations. For example, for su(2)k there arek + 1 integrable irreducible representations, corresponding to the spins from zero tok 2 . It is easy to see that the one-point functions vanish except for the trivial representation, χ λ = δ λ0 , and the two-point functions are diagonal, χ λ χ µ = δ λµ . The three-point functions can be extracted from (3.43)-or explicitly computed with (3.41)-and produce the known fusion coefficients [43] of the su(2)k algebra: (3.46) These results generalize to su(N )k and are in agreement with the general expectations for Chern-Simons theories [41].
We finish this section with an observation about the partition function itself. It is interesting to rewrite the "trivial" result Z = 1 in a different form to make contact with the representation theory of su(N )k and the Verlinde formula [44]. The last expression in (3.36) can be cast as where Ad(x i ) denotes the action of the Cartan element diag(x 1 , . . . , x N ) on the adjoint representation of SU (N ). 23 In turn, this can be written as

U (N ) k with adjoint matter
To further test our formula, we now compute the partition function of U (N ) k YM-CS with a massive adjoint chiral multiplet. As discussed in [26], this theory is related to complex Chern-Simons and the equivariant Verlinde formula. 23 The get the second equality, first rewrite the first expression in terms of unordered integers mi, introducing a factor N ! in the denominator. The terms with coinciding mi vanish. The determinant is invariant under mi → mi + 1 (simultaneous for all i): using this shift symmetry we can set mN = 0, and there are k elements in each orbit. We can then use the Weyl group SN−1 restricted to mN = 0 to order the remaining mi: this cancels a factor (N − 1)!.

The partition function is
whereñ = n − R + 1, R is the R-charge of the adjoint chiral field, and y, n are the fugacity and background flux for the U (1) flavor symmetry that assigns charge 1 to the adjoint chiral. As we discussed in section 3.2.3, this is the same as the partition function of SU (N ) k and there is no dependence on ξ, however keeping ξ will facilitate the computation. We choose η = (−1, . . . , −1) and take k > 0. The partition function has no singularities at finite points since the intersections of the planes H ij = {x i = yx j } collapse to x i = 0 for generic y. With our rules, it remains to compute an integral over an intricate structure of intersections at the boundary. We can avoid this by resuming the poles first. We write We then perform the sum over m i ≤ M − 1, where M is some large integer. Recalling that our prescription for the residues includes a further factor (−1) N , we find where we defined the quantities The presence of e iM B i (x) with a arbitrarily large M in the numerator guarantees that there are no poles at x i = 0 or x i = yx j . The only relevant poles are at ξe iB i (x) = 1 for all i, and the dependence on ξ can easily be reabsorbed in a rescaling of all x i . At these poles the dependence on M in the numerator disappears. To compute the residues, we should take the Jacobian of the denominator. We then find where the sum is over all unordered collections of solutions to the "Bethe ansatz" equations e iB i (x) = ξ −1 . It is convenient to parameterize the solutions as x j = e iθ j , then This formula with n = 0 agrees with the results in [26]. As observed there, the formula for R-charge R = 2 (ñ = −1) is an equivariant Verlinde formula and is related to complex Chern-Simons theory; for R = 0 (ñ = 1) the formula has appeared in the mathematical literature as an index formula for the moduli stack of algebraic bundles over the sphere.

The "duality appetizer"
In [46] a duality was proposed between SU (2) 1 with one adjoint chiral multiplet Φ, and the theory of a free chiral multiplet Y = Tr Φ 2 . The former theory is a special case of those considered in the previous section, however for low rank and Chern-Simons level we can write down the partition function explicitly and we can test the duality.
In the electric theory there is a flavor U (1) F symmetry that rotates the adjoint chiral with charge 1: we denote by y, n its fugacity and background flux, respectively. To cancel a parity anomaly, we introduce a CS term k F F = 1 2 . We assign R-charge 1 to Φ. The partition function of the electric theory is then (3.55) We choose η < 0, therefore we should collect minus the residues at x = 0, ± √ y. The poles at x = ± √ y exist for m ≤ (n − 1)/2, whilst the pole at x = 0 exists for m ≤ 1 − n. We can sum the series for m ≤ M − 1, where M is some large integer, in a regime y ≪ 1. The series is uniformly convergent along a contour right outside the unit circle, and such a contour includes the poles at x = 0, ± √ y and no others. The series yields the expression Now the contour includes four poles, produced by the last term in the denominator, located at x = ± (y + 1) ± y 2 + 2y − 3 /2. The residues can be explicitly computed and summed: the dependence on M drops out, and we obtain (3.56) The dual theory is given by a free chiral multiplet Y = Tr Φ 2 , with flavor charge 2 and R-charge 2 (plus a topological sector). As we infer from the partition function, there must also be an R-flavor Chern-Simons term k RF = −1. Then (3.56) precisely agrees with the partition function of the dual theory.

Refinement by angular momentum
If we choose a metric on S 2 invariant under a U (1) isometry, we can refine the partition function by adding a fugacity ζ = e iς/2 for the angular momentum on S 2 . From the path-integral point of view, this is achieved by deforming the metric on S 2 × S 1 as where ds 2 S 2 = R 2 dθ 2 + f (θ) 2 dϕ 2 is a generic metric on S 2 with U (1) isometry along ϕ. The special case of a round metric was considered in (2.5), and in fact, since the theory is quasitopological and independent of the metric on S 2 , we can do all computations using the round metric. Reducing down to S 1 , the deformed metric yields a quantum mechanical index with a fugacity ζ for the angular momentum L ϕ of rotations along ϕ, in other words Z S 2 ×S 1 computes the index Such a refined index is easily computed by noticing that the ρ(m) − q ρ + 1 Landau zero-modes on S 2 form a representation of the SU (2) group of rotations. The refined one-loop determinant for a chiral multiplet in representation R is then: The factor ζ j in the numerator cancels out and could be omitted. The determinant can be conveniently rewritten in terms of the q-Pochhammer symbol (x; q) n as Recall that, for integer values of n, the q-Pochhammer is defined as and it satisfies (x; q) n = 1 (xq n ; q) −n = (xq n−1 ; q −1 ) n , (x; q) m+n = (x; q) m (xq m ; q) n . (4.5) We can quickly derive the one-loop determinant for gauge fields using the fact that, up to a flux-dependent sign, it equals that of a chiral multiplet with R-charge 2. We get: (4.6) The classical CS actions are the same as before. A formal derivation of the above statements is given in appendix A.4.
A little bit of care has to be given to the Wilson loops. As we found at the end of section 2.1.3, to be supersymmetric a loop has to lay along the vector field e 3 = 1 β (∂ t + ς∂ ϕ ), i.e. its embedding function must be x µ (τ ) = (θ 0 , ςτ, τ ) for some θ 0 , and we have to make sure that the loop closes. One possibility is to place the loops at the poles, with θ 0 = 0, π. In this case, the classical action term-to be inserted in the localization formula-is Poles: The signs ± refer to the North and South pole of the sphere, respectively. Notice that this yields a deformation of the Verlinde algebra when we place multiple loops on top of each other, because subtle contact terms intervene. Another possibility is to choose a "rational" value ς = 2π p q , where p, q ∈ Z are coprime. Then the loops can be place at any θ 0 : they wrap q times S 1 and p times the ϕ direction. The classical action term, to insert in the localization formula, is Generic points: Notice that the refinement by angular momentum only exists on S 2 and not at higher genus (although a certain refinement, the elliptic genus, exists on T 2 as well).

U (1) 1/2 with one chiral
We would like to perform some simple checks of the refined formula. As a first example, consider again the U (1) 1/2 theory with a single chiral multiplet of charge 1. We follow the same conventions as before (and include the sign factor(−1) m ). The partition function is then It is convenient to choose η < 0 so that we have to pick minus the residue at x = 0 for all terms with m ≤ −t. We use the following two formulae: (q n ; q) j (q; q) j x j , (x; q) n = (−x) n q n(n−1) 2 (x −1 q 1−n ; q) n . (4.10) The first one is the q-binomial theorem and it is valid for |x| < 1, |q| < 1 and n ∈ Z; for n ≤ 0 only the terms with j ≤ n are non-vanishing and the right-hand-side is a finite polynomial. Expanding the integrand we find This is exactly the refinement of the partition function (3.7) of the dual theory, which, as discussed in section 3.1.1, is the theory of a free chiral field.

Pure Chern-Simons theories
As a further check, we can evaluate the refined partition function of the N = 2 U (N ) k CS theory with k =k + N > N , to verify that it is independent of ζ. In fact Chern-Simons theory is topological and should not depend on a continuous deformation of the metric. The refined partition function reads Choosing η i < 0, we should collect minus the residues at x i = 0. Since the path-integral of CS theory is saturated by flat connections, we could expect that only the sector m i = 0 contributes to the path-integral. If this is the case, the refined partition function coincides with the unrefined one-and both give Z = 1-being the average of the identity over the U (N ) Haar measure. It is easy to see that only m i = 0 contributes. Let us re-write the partition function as 13) and use N i>j The integral is non vanishing only for km i = N − σ(i) − w(i) + 1. Since σ(i) and w(i) run over σ∈S N 1 = 1. The supersymmetric Wilson loops, on the other hand, are along orbits that depend on the choice of ς. As we discussed before, in order to have room for non-coincident loops, we should choose ς = 2πp/q with p, q ∈ Z coprime. Then the loops wrap q times around S 1 and p times around S 2 : they are knotted in a topologically nontrival way, rather than continuously deformed as ς is varied. This explains why correlation functions of Wilson loops depend on ς.

The vortex partition function
Finally, we would like to make contact with the other partition functions, defined on different manifolds or supersymmetric backgrounds. As first observed in [14] and later elaborated upon in [15,16], both the S 3 partition function of [29], the S 2 ×S 1 supersymmetric index of [47,48] and the lens space index of [49] "factorize" into building elements which can be interpreted as the partition function on R 2 Ω ×S 1 in an Ω-background. For U (N c ) k theories with (anti)fundamentals, the basic elements are K-theoretic vortex partition functions. 24 A mechanism behind this factorization, called "Higgs branch localization", has been first discovered in two dimensions [18,19] and later generalized to three [17,50] and four [20] dimensions. Here we would like to show that even the twisted S 2 × S 1 partition function factorizes, in terms of the very same R 2 Ω × S 1 elements. We show it for simple theories that lead to the vortex partition function, where the computation can be carried out explicitly.
In section 5 we will discuss generalizations of our formula to two and four dimensions. Although we only show the factorization of the twisted S 2 × S 1 partition function here, the same statement is true for the twisted S 2 and S 2 × T 2 partition functions as well. In particular in four dimensions one discovers the elliptic vortex partition function [20], which is a building block of the 4d superconformal index of [51].
Consider U (1) SQED with a single flavor pair, N f = 1, i.e. with one fundamental and one antifundamental. In view of a generalization to N f > 1, it is convenient to introduce separate parameters (y, n) for the global symmetry that rotates the fundamental, and (ỹ,ñ) for the one that rotates the antifundamental, even though the two are the same flavor symmetry up to a gauge rotation. Assigning R-charge 0 to the chiral fields, the partition function is We choose η > 0, therefore we pick the residues from the fundamental at x = yζ m−n−2k , for k = 0, . . . , m − n; such poles exist only for m − n ≥ 0. We thus obtain a double sum m≥n m−n k=0 , which is more conveniently written as m 1 ,m 2 ≥0 with (4.16) In this notation the poles are at x = yζ m 1 −m 2 . Taking the residues we get (4.17) The last q-Pochhammer can be factorized into three factors: We can thus write the partition function as the product of three factors: The one-loop factor is We recognise that this is the classical action times the one-loop determinant of the antifundamental (which is not Higgsed when the FI term is positive), evaluated on the background  The last expression is the classic form of the K-theoretic vortex partition function (see for instance (2.78) in [17]). This computation can be generalized to theories with a CS term at level k, as well as N f > 1 and gauge group U (N ) with N > 1.

Other dimensions
Our three-dimensional formalism can be easily generalized to theories in two dimensions on S 2 , and in four dimensions on S 2 × T 2 . In both cases supersymmetry is preserved with a topological A-twist on S 2 , and a refinement by the angular momentum is possible. The two-dimensional formula is obtained from the one on S 2 × S 1 by shrinking the radius β of the circle to zero. Besides, we can insert twisted chiral operators at arbitrary points of S 2 (they are, in a sense, the reduction of Wilson loops on S 1 ). The four-dimensional formula, instead, is obtained by considering elliptic generalizations of our expressions. The two-dimensional result can be applied to the study of amplitudes of topologically twisted gauged linear sigma models. Our formula differs from the classic result of [52] because we do not integrate D out until the end, obtaining in this way a "Coulomb branch localization" as opposed to the "Higgs branch localization" to vortices in [52]-using the language of [18]. Here we consider the two simple cases of sigma models with target the projective space and the quintic, leaving a more general analysis for further work (see [21] for related results). One could also use our formulae to test non-perturbative dualities in two (for instance the dualities discovered in [18,[53][54][55]) and four dimensions. In this paper, we only consider a very simple example of Seiberg duality [56] in 4d N = 1 SQCD.

Two-dimensional N = (2, 2) theories on S 2
We consider two-dimensional N = (2, 2) theories with a vector-like R-symmetry, defined on S 2 with a topological A-twist. The theories do not have to be conformal, but it must be possible to choose integer R-charges. Unfortunately this excludes most Landau-Ginzburg (LG) models. 25 Therefore we will be mainly concerned with GLSMs. Very practically, the two-dimensional formula can be derived from the three-dimensional one by taking the limit in which the circle shrinks: β → 0. This corresponds to an expansion around u = 0, or x = 1. The moduli space of bosonic zero-modes reduces to M = h × h = h C and is parameterized by the complex scalar σ in the vector multiplet. Let us summarize the results. Details are given in appendix B.
The one-loop determinant for a chiral field is given by the x → 1 limit of the three-dimensional one-loop determinant in (1.3), namely (5.1) The one-loop determinant for the vector multiplet is We do not drop the sign factor in front of the determinant, because in two dimensions there are no sign ambiguities related to the regularization (see appendix B).
In two dimensions we can define a twisted superpotential W (σ), which is a holomorphic function and it leads to the following bosonic action: Of particular importance is a linear twisted superpotential, yielding a complexified FI term: Evaluated on-shell on almost-BPS configurations, the action gives Here q ≡ e −ζ−iθ , according to standard notation.
Any holomorphic function f (σ) can be inserted in the path-integral because it is supersymmetric: The computation of the partition function proceeds as in the three-dimensional case. In particular, the one-loop determinant has poles along singular hyperplanes H i , with associated charge covectors Q i . One has to choose a covector η ∈ h * . The path-integral reduces to a sum over the magnetic fluxes m on S 2 , of the JK residues evaluated at the points where r linearly independent hyperplanes meet (r = rank G). In other words: The only novelty is how to treat the boundary terms in the region at infinity of h C . The asymptotic behavior of the one-loop determinant for large |σ| is given by This corresponds to the effective twisted superpotential W eff = − 1 4π ρ(σ) log ρ(σ) − 1 . Comparing with (2.77), we see that for η > 0 we pick the residue at infinity iff ρ > 0, while for η < 0 we pick minus the residue at infinity iff ρ < 0. In other words, the rôle played by the effective CS level in 3d is played by the FI β-function in 2d. 26 Higher genus. The expressions at higher genus are derived in a similarly easy way. We find: 5.1.1 Refinement by angular momentum: the Ω-background As in three-dimensions, if we choose a metric on S 2 which has U (1) invariance, we can refine the partition function with a weight for the angular momentum. The proper supergravity background necessary for a full-fledged computation was constructed and analyzed in [27]. This is essentially the Ω-background on S 2 . On the other hand, we can more modestly obtain the relevant formula for the partition function with insertions by taking the β → 0 limit from three dimensions. After a redefinition of the variables and a rescaling that matches the unrefined case, we obtain Here ς is the parameter associated to the refinement, which can be identified with the ǫ parameter of the Ω-background. This expression could be written in a more elegant way using the Pochhammer symbol: However such an expression is not valid for ς = 0 even though the limit is not singular. For the vector multiplet we obtain Insertions of gauge-invariant twisted chiral operators constructed out of σ can only be done at the two poles. To compute a correlator involving f (σ) at the North or South pole, we include in the localization formula, where the signs ± refer to the North and South pole, respectively. This follows from the reduction of the Wilson loop in (4.7). As we show in the next example, operator insertions at coincident points introduce specific contact terms, leading to a sort of deformation of the chiral ring. We leave the question of what this deformation is to future work.

The projective spaces P N −1
In this section we compute the topological amplitudes for the projective space P N −1 . The model has U (1) gauge group and N chiral multiplets of charge 1, to which we assign R-charge 0. The topological amplitude with n insertions of the basic (1,1) class σ is We have chosen η > 0 and we have taken the residue at the singularity x = 0; had we chosen η < 0, we would have taken minus the residue at infinity. Let us understand why this reproduces the quantum cohomology of P N −1 . First, σ represents the Kähler class ω or alternatively the hyperplane divisor class, therefore σ N −1 = 1 because the intersection of N − 1 hyperplanes is a single point. Then the quantum cohomology is σ N = q, and in fact σ mN +N −1 = q m . All other correlators vanish because of axial R-symmetry charge conservation [1]. Next consider the case with masses µ j for the N chiral fields (the sum of the masses can be reabsorbed by a shift of σ). The amplitude for an insertion f (σ), which in general is the product of insertions at different points, is (5.14) By taking minus the residue at infinity (and noticing that only the sector m = 0 could contribute) one easily finds σ n = 0 for n = 0, . . . , N − 2 This is the classical result. By a shift m → m + 1 it is easy to prove which is the equivariant quantum cohomology of P N −1 .
Refined case. Let us compute the amplitudes in the case with refinement, but no masses. We can consider the insertion of σ n at the North pole. We compute First of all notice that for m ≤ −1 the integrand is a polynomial, therefore there are no residues neither at finite points nor at infinity. We reduce to By evaluating around infinity, we conclude that σ n N = 0 for n = 0, . . . , N − 2 and σ N −1 = 1, which is the classical result. Higher amplitudes are constrained by an equation obtained by shifting m → m − 1 and x → x − ς 2 : Here f (σ) is a holomorphic correlator (a polynomial). In the last equality we used that for m = 0 there are no residues, so that term can harmlessly be added. In the last expression, expanding the polynomial f we obtain relations between different amplitudes. Shifting (5.20) In this case, the correlator on the right contains an insertion of σ N at the South pole.
The equation (5.20) is just the flat-space chiral ring relation σ N = q applied at the South pole-this is independent of the insertion of f (σ) at the North pole, as it should be in the ring. On the contrary equation (5.19), where all insertions are at the North pole, represents an interesting deformation of the chiral ring.
Equation (5.19) can be used to show that σ n = 0 for n = N, . . . , 2N − 2 and σ 2N −1 = q, which again is the same as the classical result. For n ≥ 2N , though, the amplitudes are deformed by ς, for instance All other amplitudes for larger values of n can be recursively determined in a similar way.
Since the topological amplitudes should be fixed by the twisted chiral ring relations on flat space, how do we explain the deformation by ς? The reason is that we are forced to place local operators at coincident points, and the deformations that depend on ς should be attributed to contact terms. For instance, the operators in the twisted chiral ring of P N −1 are σ j with j = 0, . . . , N − 1. Therefore for n ≥ N , in (5.19) we are considering a two or higher point function, with at least two coincident operators at the North pole. It would be interesting to understand if the deformation of the amplitudes produced by our computation has a nice mathematical structure.

The quintic
This is a simple example of a compact Calabi-Yau manifold of complex dimension 3. The model has 5 chiral multiplets X i of charge 1 and R-charge 0, and one multiplet P of charge −5 and R-charge 2, as well as a superpotential W = P f 5 (X i ) where f 5 is a homogeneous polynomial of degree 5. The topological amplitude with n insertions is (5.21) The first factor of x in the denominator comes from the X i , the second from P . In principle there might be a problem because both the positively and negatively charged fields give a divergence at the some point x = 0, which is not acceptable. However, we choose η > 0 and therefore we take the residues from the X i , which give a pole for m ≥ n−4 5 . Taking into account that m ∈ Z, we see that within this range we never get a pole from P .
We can resum in m and obtain the following expression: The expression is non-vanishing only for n = 3, and in that case we summed over m ≥ 0. This expression correctly represents the quantum cohomology of the quintic CY 3 , and it exactly matches with (4.24) in [57], up to the minus sign which is a matter of convention.

Four
The last topic we cover is four-dimensional N = 1 theories placed on S 2 × T 2 , with a topological twist on S 2 . To preserve supersymmetry, the theories must possess a non-anomalous R-symmetry with integer R-charges. The one-loop determinant for a chiral multiplet on S 2 × T 2 has already been considered in [24]. We will present the complete formula for gauge theories. The result of localization is simply the elliptic generalization of our formula. The one-loop determinant is a function of q = e 2πiτ and x = e iu , where τ is the modular parameter of T 2 and u parameterizes the Wilson lines on the two direction of the torus. Let us consider the case refined by the angular momentum on S 2 ; the formula with no refinement is obtained simply setting ζ = 1. Borrowing the expressions from the elliptic genus of [4,5], the one-loop determinant for the chiral multiplet is The two elliptic functions are η(q) = q 1/24 ∞ n=1 (1 − q n ) and The three-dimensional determinant is reproduced in the q → 0 limit (i.e. τ → i∞), up to a zero-point energy: lim The one-loop for off-diagonal vector multiplets equals the one-loop for chiral multiplets with R-charge 2: This time there is also a contribution from the vector multiplets along the Cartan generators, as evicted from [4,5]: For theories with semi-simple gauge group, all action terms are Q-exact and the meromorphic form Z int (u; m) only gets contributions from the one-loop determinants (supersymmetry transformations and actions can be found in [25]). Instead, for Abelian factors one can also consider a Fayet-Iliopoulos term leading to a classical action contribution: The partition function is obtained by integrating the one-loop determinant and the classical action on the space of flat connections on T 2 and summing over the fluxes on S 2 . More precisely, we should consider the space of flat connections that commute with the constant flux on S 2 , i.e. we should look for commuting triplets Since the space of flat connections on T 2 is compact, there are no subtleties with infinity. Therefore the integration contour is simply the one provided by the Jeffrey-Kirwan residue.

Example: SU (2) SQCD
As an example, we would like to consider SQCD theories in four dimensions and check that those related by Seiberg duality [56] yield the same partition function. To keep the example simple, we look at SU (2) SQCD with N f = 3 flavors, whose dual is a Wess-Zumino model of chiral multiplets with a superpotential. In fact, SU (2) SQCD is more easily described within the U Sp family, whose Seiberg dualities have been studied in [58]. U Sp(2N c ) SQCD has 2N f chiral multiplets Q i in the fundamental, the global symmetry is SU (2N f ) × U (1) R , and the flavors are in the fundamental of SU (2N f ) and have R-charge R = (N f − N c − 1)/N f . The gauge invariants are the mesons M ij = Q i · Q j , where the contraction over gauge indices is done with the invariant tensor of U Sp(2N c ), and there is antisymmetry in ij.
We consider U Sp (2) SQCD with 2N f = 6 quarks. Their R-charges are R = 1 3 , which is not acceptable in our setup on S 2 × T 2 because the R-charges must be integers. However, we can mix U (1) R with a Cartan generator of the flavor symmetry SU (6), namely diag 2 3 , 2 3 , − 1 3 , − 1 3 , − 1 3 , − 1 3 , to form a new R-symmetry U (1) ′ R = diag(1, 1, 0, 0, 0, 0), non-anomalous and integer. For simplicity, we look at the unrefined case ζ = 1 and we do not consider the most general background for the flavor symmetry, rather we turn on a minimal background to obtain a finite partition function: we take the Cartan of SU (6) given by U (1) A = diag(−2, −2, 1, 1, 1, 1). In order to write down the partition function Z S 2 ×T 2 in a compact form, we introduce the notation f χ (g, a, r) = iη(q) θ 1 (x g y a ; q) gm+an−r+1 (5.29) for the one-loop determinant of a chiral multiplet with gauge charge g (under the Cartan of SU (2)), flavor charge a and R-charge r: this is an implicit function of (x, m) and (y, n), and, as usual, x = e iu and y = e iv . Then Z S 2 ×T 2 is The magnetic theory, which in this case is more properly interpreted as the effective IR description, is a Wess-Zumino model of fundamental fields M ij (antisymmetric in ij), subject to the cubic superpotential The partition function for these 15 mesons is simply We would like to check that the two partition functions coincide. We can check that (5.30) and (5.32) coincide at the lowest order in a q expansion. After expanding the integrand of (5.30) at the lowest order in q, we choose η > 0 and consider the poles at x = y 2 (existing for m ≥ 2n + 1) and at x = y −1 (existing for m ≥ −n). Then we follow the same strategy as in section 3.2.6. We first sum over m ≥ −M , for some large positive integer M , to be sure to pick up all residues. This produces an expression in which the relevant poles are at the two roots of the polynomial equation The residues can be computed explicitly and summed: the dependence on M disappears, and we are left with This is precisely the expansion of Z dual at the lowest order in q.

Conclusions
In this paper we have provided a general formula for the partition function of three-dimensional N = 2 gauge theories placed on S 2 × S 1 , with a topological twist along S 2 . The result depends on a collection of background magnetic fluxes and fugacities for the flavor symmetries. There are many generalizations of our result to other dimensions and different manifolds: some of these generalizations have been discussed in this paper, others are left for future work. In particular, our result can be easily extended to the case where S 2 is replaced by a Riemann surface Σ of higher genus. The new ingredient is the presence of extra zero-modes corresponding to the Wilson lines along Σ. The case Σ = T 2 would compute the Witten index of three-dimensional theories. It would be interesting to see whether our reformulation of the A-twist for supersymmetric two-dimensional sigma models in terms of Coulomb branch localization can provide new geometrical insight in the study of Gromov-Witten invariants and mirror symmetry. In particular, while the physics of Abelian GLSMs, and the mathematics of the corresponding low energy NLSMs (complete intersections in toric varieties), are very well understood, this is not the case for non-Abelian models [53,59]. The partition function on the sphere with no twist have also been computed via localization in [18,19] and has led to a re-interpretation of the Kähler geometry of the Calabi-Yau moduli space [60,61]. The topologically twisted partition function, instead, directly computes amplitudes. Some related questions are analyzed in [21].
We have not spent many words on four-dimensional N = 1 theories, although this is clearly an interesting setting. A line of investigation we would like to suggest is about correspondences a la AGT [62,63]. They put in correspondence observables in certain 4d N = 2 [64][65][66] and N = 1 [67,68] supersymmetric gauge theories with 2d conformal or topological theories, by different compactifications of the mysterious 6d N = (2, 0) theory. With a new observable at our disposal-the index with twist-it is natural to ask what is the 2d theory that computes it.
Finally, we should mention that this paper grew originally from the attempt to understand in microscopical terms the entropy of AdS 4 static black holes. Regular static black holes have been recently found in four-dimensional N = 2 gauged supergravity [69][70][71]. They have magnetic charges and an AdS 2 × Σ horizon and can be interpreted as a dual description of a threedimensional CFT placed on Σ × S 1 with a topological twist along Σ and various background magnetic fluxes for the global symmetries [72]. They thus perfectly fit in the framework of our paper. We hope to report on the subject soon.

A One-loop determinants
In this appendix we give the details of the computation of one-loop determinants on S 2 × S 1 : we perform an explicit computation with the round metric, we provide an alternative cohomological argument valid when D 0 = 0 with any metric, and we extend the computation to the refined case.

A.1 Reduction on S 2
We consider the round sphere with constant magnetic field: The flux is quantized, b ∈ Z, the spin connection is ω 12 = − cos θ dϕ and we choose a gauge potential A = b 2 ω 12 . The covariant derivative for a particle of charge 1 and spin s z ∈ Z/2 is We define the effective spin The particle transforms as a section of a line bundle with c 1 = b − 2s z = −2s, therefore we can regard it as a scalar particle in a magnetic flux −2s, or as a neutral particle of effective spin s.
The gauge-covariant Laplace operator is 27 Its eigenfunctions are the well-known monopole harmonics [73]. Let us quickly review their construction. We introduce the following operators: They are constructed in such a way to satisfy the same commutation relations as the standard angular momentum, [J 3 ,J ± ] = ±J ± and [J + ,J − ] = 2J 3 , and to be related to the Laplace operator in a simple way, We can then diagonalize D 2 andJ 3 simultaneously, usingJ ± as ladder operators forJ 3 . The states in a representation satisfy −j ≤ j 3 ≤ j, in terms of a quantum number j so defined. We use the notation Y s j,j 3 , then the spectrum is Positivity of −R 2 D 2 implies j ≥ |s|. This becomes clear working out the highest weight eigenfunctions: Y s j,j = e ijϕ tan θ 2 −s (sin θ) j annihilated byJ + . They are well-defined for j ≥ |s| and j − s ∈ N (see footnote 27). The other wavefunctions can be obtained by acting withJ − . We also have bundle-changing operators D ± : which map s → s ± 1 keeping j, j 3 fixed. 28  it has minimal s) has −R 2 D 2 = −s, therefore j = −s; a state annihilated by D + (maximal s) has −R 2 D 2 = s, therefore j = s. The eigenfunctions annihilated by D − are Y −j j,j 3 = e ij 3 ϕ tan θ 2 j 3 (sin θ) j , then Y s j,j 3 with −j ≤ s ≤ j can be obtained by acting with D + . Finally, starting with Y −j j,j 3 and acting with D + , or starting with Y j j,j 3 and acting with D − , we get the relations We can use the spectral analysis on S 2 to compute the one-loop determinant on S 2 × S 1 for a chiral multiplet Φ ρ , transforming as the weight ρ of a representation R, and with R-charge q. 27 The total connection (spin plus gauge) is A = s cos θ dϕ, which is in a singular gauge because A is singular at the poles. Moreover, for s ∈ Z + 1 2 a gauge transformation is required as we go around the poles, as it becomes clear computing the Wilson line very close to the poles which should vanish. Thus, for s ∈ Z + 1 2 the wavefunctions get a minus sign as ϕ → ϕ + 2π. They become single-valued using standard smooth gauges on two patches. 28 When acting with the operators D±, one has to be careful to keep track of the value of s, as they change it. The field is immersed in a magnetic field m ∈ g, there is a flat connection A t along S 1 , and the D-term has expectation value D = im 2R 2 + D 0 . Notice that in this computation we do not distinguish between gauge and flavor symmetries. We define the integer b ≡ ρ(m) − q . (A.9) We now compute the determinants for the scalar and the Dirac field in the chiral multiplet, while the full one-loop determinant is assembled in the main text.
The scalar φ. This field has R-charge q and spin s z = 0, therefore, recalling that there are −1 units of R-symmetry flux on S 2 besides the magnetic flux, the effective spin is s = − b 2 . The action follows from the quadratic expansion of (2.17) around the background, that we write as φ † O φ φ. The eigenfunctions are Y s j,j 3 e 2πikt with j = |s| + n and n ∈ Z ≥0 , k ∈ Z. We immediately get the determinant The Dirac spinor ψ. The operator from the quadratic expansion of (2.17) is . (A.11) The spinor ψ has the same gauge/flavor charge ρ as the scalar φ, but its R-charge is q − 1. Therefore the flux experienced by ψ is ρ(m) − q + 1 = b + 1. A Dirac spinor on S 2 has generically two components with s z = ± 1 2 : If both components exist, the matrix is , and its determinant is Now we should distinguish a few cases. For b ≥ 0, at j = b 2 only the right-moving (RM) mode exists, while for j = b 2 + n and n ≥ 1 both modes exist. We then obtain for det O ψ : For b ≤ −2, at j = − b 2 − 1 only the left-moving (LM) mode exists, while for j = − b 2 − 1 + n and n ≥ 1 both modes exist. We then obtain for det O ψ : Finally, for b = −1 there are no special cases with chiral modes, because even with the smallest possible angular momentum, j = 1 2 , both modes exist. Then we set j = 1 2 + n and we obtain k∈Z n≥0 The three cases can be summarized by the following formula for the fermionic determinant: where s = sign(b + 1).

A.3 The cohomological argument
For D 0 = 0 (i.e. D = iF 12 ) we can reproduce the one-loop determinant with an alternative cohomological argument, similar to that in [36]. We consider a generic metric on S 2 and a generic profile F 12 (x) for the magnetic field. We will need the identity On the other hand, suppose we have a scalar mode Φ with O φ Φ = −λ λ + 2ρ(σ) Φ. Then we can construct the two fermionic modes The action of O ψ on the two-dimensional vector space is 18) and the eigenvalues are λ and − λ + 2ρ(σ) . We conclude that the modes in all these eigenspaces do not contribute to the one-loop determinant because their eigenvalues cancel out. The only modes that contribute to the determinant are the unpaired ones. Let us find them. If ǫ † Ψ = 0, we do not have a partner scalar mode. This only happens if γ 3 Ψ = −Ψ. Then the defining equation splits into γ a D a Ψ = 0 summed over a = 1, 2 , −D 3 Ψ − ρ(σ)Ψ = λΨ .
(A. 19) This implies that Ψ is a LM chiral zero-mode of the twisted Dirac operator on S 2 and it depends on t as e 2πikt for k ∈ Z. In the unrefined case D 3 = ∂t−iρ(At) β , therefore If on S 2 (with the chosen metric and gauge flux) there are n L LM chiral zero-modes, the contribution to the index is λ n L 0 . The refined case is discussed in section 4 and appendix A.4. If the two modes Ψ 1 and Ψ 2 are actually parallel (including the case that Ψ 2 = 0), the scalar mode is paired to one fermionic partner only. Let us write D / Ψ 1 = αΨ 1 for some α. Since γ 3 Ψ 1 = Ψ 1 , the equation splits into γ a D a Ψ 1 = 0 summed over a = 1, 2 , This implies that Ψ 1 is a RM chiral zero-mode on S 2 . Then O ψ Ψ 1 = λΨ with λ = α − ρ(σ). In the unrefined case we find However recall that we also have the scalar, therefore the contribution to the determinant is from each of these modes. If on S 2 there are n R RM chiral zero-modes, the contribution to the index is λ −n R 0 . By the index theorem we have n R − n L = ρ(m) − q + 1, therefore we are led to the same determinant (2.47) as before.

A.4 Refined one-loop determinant
We now give some details about the computation of the refined one-loop determinant for a chiral multiplet. With round metric, the vielbein and its inverse are whereÃ t is the constant zero-mode part that commutes with m. This connection, though, is singular at the poles and therefore one should be very careful in using it to compute the Wilson loop. It is clearer to consider two patches, North and South, and two smooth connections: The bosonic zero-mode is defined as To evaluate the classical CS actions, we should first extend A to a connection on a fourmanifold whose boundary is S 2 × S 1 . We choose S 2 × D 2 , with r the radius of D 2 , and extend A = − m 2 cos θ (dϕ − ς r 2 dt) +Ã t r 2 dt F = m 2 sin θ dθ ∧ (dϕ − ς r 2 dt) + Ã t + m 2 ς cos θ dr 2 ∧ dt . (A.27) The extension satisfiesF S 2 ×S 1 = F , D 2F = S 1 A. Then S 2 ×D 2F ∧F = 4πmÃ t independently of ς, therefore the on-shell CS actions are not affected by ς.
A supersymmetric Wilson loop must be along the vector field e 3 = 1 β (∂ t + ς∂ ϕ ), as found after (2.21), i.e. it must lay along the embedding x µ (τ ) = (θ 0 , ςτ, τ ) with parameter τ . The Wilson loop equals W = Tr R Pexp i dτ β(A 3 + iσ). If we place the loop at the North (θ 0 = 0) or South (θ 0 = π) pole of the sphere, the direction ϕ is immaterial, the loop only winds once around t, and there is no constraint on ς. We obtain from (A.25): where the signs ± refer to the North and South pole, respectively. On the other hand, for generic values of θ 0 = 0, π, the loop closes only if ς = 2π p q with p, q ∈ Z coprime: in this case the loop winds p times around ϕ and q times around t. Combining the two integrals in (A.25), we find W = Tr R e iqu + iπpm = ρ∈R (−1) pρ(m) x qρ . (A.29) To compute the one-loop determinant, we follow the cohomological argument and count the fermionic zero-modes. For a given weight ρ, the flux seen by the fermions is B = ρ(m) − q ρ + 1. If with j = B−1 2 and j 3 = −j, −j+1, . . . , j, whose dependence on ϕ is e ij 3 ϕ . On S 2 ×S 1 , these modes Ψ 1 have a dependence e 2πikt . Each mode contributes a factor − 1 α+ρ(σ) , where D 3 Ψ 1 = αΨ 1 . We thus find 1 − x ρ ζ 2j 3 x ρ/2 ζ j 3 .
This reproduces the one-loop determinant given in (4.2).

B The two-dimensional partition function
In this appendix we give some details on localization in the two-dimensional case. The background is a generic metric on S 2 with volume 4πR 2 . The spin connection ω 12 satisfies dω 12 = Rs 2 dvol and 1 2π dω 12 = 2. We take a background vector V = − 1 2 ω 12 coupled to the R-symmetry. Then the SUSY parameters satisfy D µ ǫ = 0, γ 3 ǫ = ǫ and similarly forǫ .
The SUSY transformations are easily derived from the three-dimensional case by mapping A 3 → σ 1 , σ → σ 2 and then σ 1 + iσ 2 → −iσ, σ 1 − iσ 2 → iσ. Using F µ3 → D µ σ 1 , D 3 → −i[σ 1 , · ] and [σ 1 , σ 2 ] → i 2 [σ,σ], we get the following. For the vector multiplet: (B.1) The BPS equations for complexified fields are D = iF 12 , [σ,σ] = 0 and D µ σ = 0. Restricting to configurations where the gauge field is real,σ is the complex conjugate to σ but D remains complex, we get Up to gauge transformations, the moduli space of bosonic zero-modes is M = h × h = h C (to be divided by the Weyl group W together with the magnetic fluxes m ∈ Γ h ) parameterized by a diagonal complex σ which becomes our integration variable. The transformations of the chiral multiplet are The BPS equations for complexified fields are (D 1 + iD 2 )φ = (D 1 − iD 2 )φ † = 0, σφ = φ † σ = 0, F = F † = 0. Going to the real contour, they are complex conjugate pairs and reduce to (D 1 + iD 2 )φ = 0 , σφ = 0 , The points (hyperplanes) of M where σφ = 0 for some chiral multiplet φ form the subset M sing : at those points, the BPS equations would allow for extra zero-modes. The action terms that we consider are the standard ones, as in [18,19]: YM action, matter action and superpotential, which are Q-exact. More interesting is a twisted superpotential, which is not Q-exact. First, any holomorphic function f (σ) can be inserted in the path-integral because it is supersymmetric: in particular this allows us to make local insertions at arbitrary points on S 2 . A twisted superpotential action must be real in Lorentzian signature, but we cannot insert f * (σ) because this is not supersymmetric, even after integration. The twisted superpotential Lagrangian is in fact where W (σ) and W * (σ) are gauge-invariant holomorphic functions of their arguments. The two terms are separately supersymmetric, therefore the two functions W and W * could be independent, however in order for the action to be real in Lorentzian signature, they should be complex conjugate. In the non-Abelian case it should be read as where A, B are indices of the adjoint representation, and similarly for L W . Both terms are annihilated by Q, Q. The bosonic part of the twisted superpotential Lagrangian is Of particular importance is a linear twisted superpotential, leading to a complexified FI term: Tr Here q ≡ e −ζ−iθ , according to standard notation.
The computation of the one-loop determinants is essentially the same as in the threedimensional case, but without the sum over the KK modes on S 1 that we labeled by k. In particular, there is no longer any regularization to do and no sign ambiguity in the final answer (besides, there are no topological symmetries nor the path-integral has a Hamiltonian interpretation as a trace, although a sign ambiguity could still be reabsorbed in the θ-angle). To give some details, consider the round S 2 and the chiral multiplet. The scalar operator is and its spectrum is (2n + 1)|b| − b + 2n(n + 1) This time, we do not drop the sign factor in front because there are no ambiguities. This sign was noted in [74] for the background on S 2 constructed in [18,19]. 29 One performs the localization, which proceeds as in the three-dimensional case. The only novelty is how to treat the region at infinity of h C , i.e. the complex σ-plane. For that, we need the asymptotic dependence of the one-loop determinant on D 0 . Let us perform the analysis for b ≥ 0. We want to compute 29 Although this sign seems not to be present in [18], in fact there is a small mistake in the last appendix of that paper, and correcting it the sign is present in [18] too.