\documentclass[a4paper,12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[flushmargin]{footmisc}
\usepackage{setspace}
\usepackage[comma]{natbib}
\usepackage{float}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{ae}
\usepackage{caption}
\usepackage[a4paper,top=3cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}

\begin{document} \doublespacing \pagestyle{plain}
This gives
\begin{equation}
\begin{array}{rl}
E[Y_1(0,1)|\tau=c] =  \displaystyle \frac{p_{1|1}}{p_{1|1}-p_{1|0}}E[Q_{01}(Y_0)|D=1,M=1] \\
 \displaystyle \quad - \frac{p_{1|0}}{p_{1|1}-p_{1|0}}E[Y_1|D=0,M=1],
\end{array}
\end{equation}
with $p_a = p_{1|0}$, and $p_c +p_a =p_{1|1}$.
\subsection{Quantile direct effect
under $\mathbf{d = 1}$ on compliers}
We show that
\begin{align*}
 F_{Y_{1}(1,1)|\tau=c}(y) =  \frac{p_{1|1}}{p_{1|1} - p_{1|0}} F_{Y_{1}|D=1,M=1}(y) - \frac{p_{1|0} }{p_{1|1} - p_{1|0}}F_{Q_{11}(Y_0)|D=0,M=1}(y) \mbox{ and} \\
F_{Y_{1}(0,1)|\tau=c}(y) = \frac{p_{1|1}}{p_{1|1} - p_{1|0}}  F_{Q_{01}(Y_{0})|D=1,M=1}(y) - \frac{p_{1|0}}{ p_{1|1} - p_{1|0}}  F_{Y_1|D=0,M=1}(y)  ,
\end{align*}
which proves that $\theta_1^{c}(q,1) = F_{Y_{1}(1,1)|c}^{-1}(q)-F_{Y_{1}(0,1)|c}^{-1}(q)$ is identified.
In analogy to (), the outcome distribution under $D=0$ and $M=0$ equals:
\begin{equation*}
F_{Y_{1}|D=1,M=1}(y)=\frac{p_a}{p_a + p_c}F_{Y_{1}(1,1)|\tau=a}(y)  + \frac{p_c}{p_a + p_c}F_{Y_{1}(1,1)|\tau=c}(y).
\end{equation*}
Using () and rearranging the equation gives
\begin{equation}
F_{Y_{1}(1,1)|\tau=c}(y)= \frac{p_{1|1}}{p_{1|1} - p_{1|0}} F_{Y_{1}|D=1,M=1}(y) - \frac{p_{1|0} }{p_{1|1} - p_{1|0}}F_{Q_{11}(Y_0)|D=0,M=1}(y) .
\end{equation}
From (), we have $F_{Y_{1}(0,1)|D=1,M(1)=1}(y)  =F_{Q_{01}(Y_{0})|D=1,M=1}(y)$. Applying the law of iterative expectations gives
\begin{align*}
F_{Y_{1}(0,1)|D=1,M(1)=1}(y)   =\frac{p_a}{p_a + p_c} F_{Y_{1}(0,1)|D=1,M(1)=1,\tau=a}(y)
\\  +\frac{p_c}{p_a + p_c} F_{Y_{1}(0,1)|D=1,M(1)=1,\tau=c}(y),\\
 \stackrel{A7}{=} \frac{p_a}{p_a + p_c} F_{Y_{1}(0,1)|\tau=a}(y) +\frac{p_c}{p_a + p_c} F_{Y_{1}(0,1)|\tau=c}(y).
\end{align*}
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[flushmargin]{footmisc}
\usepackage{setspace}
\usepackage[comma]{natbib}
\usepackage{float}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{ae}
\usepackage{caption}
\usepackage[a4paper,top=3cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}

\begin{document} \doublespacing \pagestyle{plain}
Using () and rearranging the equation gives
\begin{equation}
F_{Y_{1}(1,1)|\tau=c}(y)= \frac{p_{1|1}}{p_{1|1} - p_{1|0}} F_{Y_{1}|D=1,M=1}(y) - \frac{p_{1|0} }{p_{1|1} - p_{1|0}}F_{Q_{11}(Y_0)|D=0,M=1}(y) .
\end{equation}
From (), we have $F_{Y_{1}(0,1)|D=1,M(1)=1}(y)  =F_{Q_{01}(Y_{0})|D=1,M=1}(y)$. Applying the law of iterative expectations gives
\begin{align*}
F_{Y_{1}(0,1)|D=1,M(1)=1}(y)   =\frac{p_a}{p_a + p_c} F_{Y_{1}(0,1)|D=1,M(1)=1,\tau=a}(y)
\\  +\frac{p_c}{p_a + p_c} F_{Y_{1}(0,1)|D=1,M(1)=1,\tau=c}(y),\\
 \stackrel{A7}{=} \frac{p_a}{p_a + p_c} F_{Y_{1}(0,1)|\tau=a}(y) +\frac{p_c}{p_a + p_c} F_{Y_{1}(0,1)|\tau=c}(y).
\end{align*}
Using () and rearranging the equation gives,
\begin{equation}
F_{Y_{1}(0,1)|\tau=c}(y) = \frac{p_{1|1}}{p_{1|1} - p_{1|0}}  F_{Q_{01}(Y_{0})|D=1,M=1}(y) - \frac{p_{1|0}}{ p_{1|1} - p_{1|0}}  F_{Y_1|D=0,M=1}(y).
\end{equation}
\section{Proof of Theorem 5 }
\subsection{Average treatment effect on the compliers}
In () and (), we show that
\begin{align*}
\theta_1^c=  E[Y_1(1,1) -Y_1(0,0)|\tau=c], \\ = \frac{p_{1|1}}{ p_{1|1} - p_{1|0}} E[Y_1|D=1,M=1] -\frac{p_{1|0}}{p_{1|1} - p_{1|0}}E[Q_{11}(Y_0)|D=0,M=1] \\
 − \frac{p_{0|0}}{ p_{0|0} - p_{0|1}} E[Y_1|D=0,M=0] +\frac{p_{0|1}}{p_{0|0} - p_{0|1}}E[Q_{00}(Y_0)|D=1,M=0] .
\end{align*}
\subsection{Quantile treatment effect on the compliers}
In () and (), we show that $F_{Y_{1}(1,1)|c}(y)$ and $F_{Y_{1}(0,0)|c}(y)$ are identified. Accordingly, $\Delta_1^{c}(q) = F_{Y_{1}(1,1)|c}^{-1}(q)-F_{Y_{1}(0,0)|c}^{-1}(q)$ is identified.
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[flushmargin]{footmisc}
\usepackage{setspace}
\usepackage[comma]{natbib}
\usepackage{float}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{ae}
\usepackage{caption}
\usepackage[a4paper,top=3cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}

\begin{document} \doublespacing \pagestyle{plain}
\subsection{Average indirect effect
under $d = 0$ on compliers}
In () and (), we show that
\begin{align*}
\delta_{1}^{c}(0) = E[Y_1(0,1) -Y_1(0,0)|\tau=c],\\
= \frac{p_{1|1}}{p_{1|1}-p_{1|0}}E[Q_{11}(Y_0)|D=1,M=1] - \frac{p_{1|0}}{p_{1|1}-p_{1|0}}E[Y_1|D=0,M=1]\\
- \frac{p_{0|0}}{ p_{0|0} - p_{0|1}} E[Y_1|D=0,M=0] +\frac{p_{0|1}}{p_{0|0} - p_{0|1}}E[Q_{00}(Y_0)|D=1,M=0].
\end{align*}
\subsection{Quantile indirect effect
under $d = 0$ on compliers}
In () and (), we show that $F_{Y_{1}(0,1)|c}(y)$ and $F_{Y_{1}(0,0)|c}(y)$ are identified. Accordingly, $\delta_1^{c}(q,0) = F_{Y_{1}(0,1)|c}^{-1}(q)-F_{Y_{1}(0,0)|c}^{-1}(q)$ is identified.
\subsection{Average indirect effect
under $d = 1$ on compliers}
In () and (), we show that
\begin{align*}
\delta_1^{c}(1) = E[Y_1(1,1) -Y_1(1,0)|\tau= c],\\
= \frac{p_{1|1}}{ p_{1|1} - p_{1|0}} E[Y_1|D=1,M=1] -\frac{p_{1|0}}{p_{1|1} - p_{1|0}}E[Q_{11}(Y_0)|D=0,M=1]\\
- \frac{p_{0|0}}{p_{0|0} - p_{0|1}}E[Q_{00}(Y_0)|D=0,M=0] + \frac{p_{0|1}}{p_{0|0} - p_{0|1}}E[Y_1|D=1,M=0].
\end{align*}
\subsection{Quantile indirect effect
under $d = 1$ on compliers}
In () and (), we show that $F_{Y_{1}(1,1)|c}(y)$ and $F_{Y_{1}(1,0)|c}(y)$ are identified. Accordingly,  $\delta_1^{c}(q,1) = F_{Y_{1}(1,1)|c}^{-1}(q)-F_{Y_{1}(1,0)|c}^{-1}(q)$ is identified.
\end{document}


\documentclass[a4paper,extrafontsizes,article]{memoir}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{siunitx}
\usepackage{hyperref}
\counterwithout{section}{chapter}
\makeatletter
\let\@fnsymbol\@arabic
\makeatother
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}
\begin{document}
At each simulation step $t$ and for each $\iota$, the path length reflected by the $\iota$-th scatter $l^{(\iota)}_t =\left\vert(x_t^\iota,y_t^\iota)-(0,0)\right\vert + \left\vert(x_t^*,y_t^*)-(x_t^\iota,y_t^\iota)\right\vert$ and its derivative with respect to time $\frac{d}{dt}l_t^{(\iota)}$ are computed. The corresponding transmission delay time $\sigma_t^{(\iota)}$, the constant phase offset $\theta_t^{(\iota)}$,  and the Doppler frequency $f_{D_t}^{(\iota)}$ caused by the $\iota$-th scatterer following the rules $\sigma_t^{(\iota)}=l_t^{(\iota)}/c_0$, $\theta_t^{(\iota)}=((-l_t^{(\iota)}f_{\text{carrier}}/c_0) \bmod 1)\cdot 2\pi$, and $f_{D_t}^{(\iota)}=-\frac{d}{dt}l_t^{(\iota)}f_{\text{carrier}}/{c_0}$, respectively, as well as the received signal amplitude $a_t^{(\iota)}$ computed using the free-space propagation model   $a_t^{(\iota)}=c_0/(4\pi f_{\text{carrier}} l_t^{(\iota)})$ (cf.) are recorded for each scatterer $\iota$. (Here, $c_0$ refers to the speed of light in vacuum.)
In a setting without line of sight, using linearisation of the phase offset with respect to the Doppler frequency, the time-variant channel impulse response evaluated at time $t+\tau$ for each simulation step $t$ and small $\tau$ resulting from the multipath transmission simulated using the above parameters can be approximated by
\[
h(\cdot,t+\tau)=\frac{1}{\sqrt{\sum_{\iota=0}^{255} (a_t^{(\iota)}) ^2}}\sum_{\iota=0}^{255} a_t^{(\iota)}\exp(i\theta_t^{(\iota)}+i2\pi f_{D_t}^{(\iota)}\tau)\delta_{\sigma_t^{(\iota)}}(\cdot).
\]
For any signal $\{S_\tau\}_{0\leq\tau< T}$ being transmitted in the block beginning at time step $t$ through the simulated channel, this consideration leads to a received signal $\{R_\tau\}_{0\leq\tau< T}$ in the form of
\begin{align}
\nonumber R_\tau &= (h(\cdot,t+\tau) *S_\cdot)(\tau)\\
& = \frac{1}{\sqrt{\sum_{\iota=0}^{255} (a_t^{(\iota)}) ^2}}\sum_{\iota=0}^{255} a_t^{(\iota)}\exp(i\theta_t^{(\iota)}+i2\pi f_{D_t}^{(\iota)}\tau)(\delta_{\sigma_t^{(\iota)}}(\cdot)*S_\cdot)(\tau).
\end{align}
This parametrisation is used in  and delivers a realistic approximation of real-world scenarios for numbers of summands greater than $100$ . In order to allow continuous time delays to be applied to discrete time signals, the impulse function $\delta_{\sigma_t^{(\iota)}}(\cdot)$ in () is convolved with a windowed $\text{sinc}(\cdot)$ function scaled with a given bandwidth.  Overall, the channel transmission including pulse shaping with bandwidth restricted to half the sample rate\linebreak and additive noise is approximated by replacing the $\delta_{\sigma_t^{(\iota)}}(\cdot)$ in () by\linebreak $\sin(\pi(\cdot/2))/(\pi(\cdot/2))\mathbf{1}_{[-8,8]}$ and adding independent and identically distributed Gaussian white noise $\sim\mathcal{N}(0,\sigma^2)$ to the transmitted signal with power $\sigma^2$ resulting in a signal-to-noise ratio of $12\text{dB}$.
\section{Channel Estimation}
The time-variant channel transfer functions $\mathcal{F}h(\cdot,t+\tau)$ for $t=0,\dots, 4095T$ and $0\leq \tau<T$ simulated in Section are approximated by a time series of block wise time-invariant transfer functions $\{\mathcal{F}h^t\}_{t=0,\dots, 4095}$ based on which the estimation and prediction of the channel transmission are conducted.
For each transmission block beginning at time step $t$, in order to estimate the corresponding channel transfer function $\mathcal{F}h^{t}$, a complex-valued (white noise) test signal $\{\tilde{S}_\tau^t\}_{\tau=0,\dots,N-1}$
whose Fourier transform has constant amplitude and random phases $\sim\mathcal{U}(-\pi,\pi)$ is generated
and then transmitted through the channel simulated in Section resulting in a received signal $\{R_\tau^t\}_{\tau=0,\dots,N-1}$.
\end{document}


\documentclass[conference]{IEEEtran}
\usepackage{cite}
\usepackage[pdftex]{graphicx}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
  \usepackage[caption=false,font=footnotesize]{subfig}
\usepackage{url}
\usepackage{xcolor}
\usepackage{eurosym}

\begin{document}
ZENIT (Zero Emission Neighborhood Investment Tool) is a tool for minimizing the cost of investing and operating the energy system of a Zero Emission Neighborhood (ZEN). It uses a MILP model to find the optimal type and size of technology needed to provide heat and electricity to a ZEN.
The concept contains much more than only the energy system (materials and architecture to name two examples) but this tool's focus is energy systems.
The idea behind ZEN is to limit emissions and that it is possible to compensate for the various emissions of $CO_2$ in the neighborhood by exporting electricity to the grid. Indeed, by exporting electricity produced from on-site renewable to the grid, we assume that the production in the system is reduced by the corresponding amount and thus reduces the emission of the total system.
The model used in this paper is based on the model presented in . In this section, the main elements of the model will be repeated and the differences with the model from  presented. For the details on the model not repeated, one can refer to that paper. Then the implementation and case chosen will be presented.
The optimization is written in Python and uses Gurobi as a solver. In this paper, we interpret the definition of a ZEN as a neighborhood that has 0 emissions over its lifetime, which is set to 60 years. However due to practical reasons and to reduce the computational time, different periods of the lifetime can be defined using one representative year for each. In this study we use a single period.
The different decision variables are the amount of investment in each technology for heat, power and energy storage as well as the operation related variables defined for each hour (e.g. amount of electricity produced, amount of fuel consumed).
Multiple constraints are used, to enforce the $CO_2$ limitations necessary in the ZEN context and to represent the operation of the neighborhood and in particular of each technology. It is important to note that part load limitations and start up/shutdown constraints are not implemented.
The objective function of the optimization is the following:
\textit{Minimize}:
\begin{multline}
    \sum_{i} C_i^{disc}\cdot x_i + b_{hg} \cdot C_{hg} + \frac{1}{\varepsilon^{tot}_{r,D}} \sum_{i} C_i^{maint} \cdot x_i\\+\frac{1}{\varepsilon^{tot}_{r,D}}\bigg(\sum_{t}\Big(\sum_{f}f_{f,t}\cdot P_{f}^{fuel} + (P_{t}^{spot}+P^{grid}\\+P^{ret})\cdot (y_{t}^{imp}+\sum_{est}y_{t,est}^{gb\_imp})-P_{t}^{spot}\cdot y_{t}^{exp}\Big)\bigg)
\end{multline}
Where $C_i^{disc}$ is the discounted investment cost in technology $i$ including re-investments and salvage value, $x_i$ the capacity of technology $i$, $b_{hg}$ the binary variable for investment in a heating grid, $C_{hg}$ the cost of the heating grid, $\varepsilon^{tot}_{r,D}$ the discount factor for the whole lifetime of the neighborhood with discount rate r, $C_i^{maint}$ the annual maintenance cost, $f_{f,t}$ the fuel consumption, $P_{f}^{fuel}$ the fuel price, $P_{t}^{spot}$ the electricity spot price, $P^{grid}$ and $P^{ret}$ the grid and retailer tariffs, $y_{t}^{imp}$ and $y_{t}^{exp}$ the import and export of electricity from the neighborhood and $y_{t,est}^{gb\_imp}$ the import of electricity to the storage. The subscript $t$ represent timesteps, $i$ the technologies with in particular $f$ for the technologies using other fuel than electricity and $est$ for energy storages.
It minimizes the cost of investing in the different technologies and the operating costs, fuels, electricity and O\&M costs and contains the costs of the heating grid and a binary associated with it that also gives access to technologies at a neighborhood level.
The most important constraint in the case of ZENs is the $CO_2$ balance \eqref{co2bal}, whose principle was explained earlier. In \eqref{co2bal}, $y_{t,est}^{gb\_imp}$, $y_{t,est}^{gb\_exp}$ and $y_{t,est}^{pb\_exp}$ are respectively the import and export on the grid side battery and the export from the on-site technologies producing electricity, $\varphi^{CO_2}_{e}$ and $\varphi^{CO_2}_{f}$ the $CO_2$ factors for electricity and other fuels, $\eta_{est}$ the efficiency of battery and $y_{t,g}^{exp}$ the export of electricity from the on-site technologies.
\begin{multline}
    \sum_{t}((y_{t}^{imp}+\sum_{est}y_{t,est}^{gb\_imp}) \cdot \varphi^{CO_2}_{e}) \\+ \sum_{t}\sum_{f} (\varphi^{CO_2}_{f} \cdot f_{f,t}) \leq \sum_{t}(\sum_{est}(y_{t,est}^{gb\_exp}\\+y_{t,est}^{pb\_exp})\cdot \eta_{est} +\sum_{g}y_{t,g}^{exp}) \cdot \varphi^{CO_2}_{e}
\end{multline}
Fig.  presents graphically the electricity balance and the different equations associated.
Different technologies are included in the study; some of them are only available at the building level and others at the neighborhood level in a centralized production plant. The different technologies are: at the building level : Solar Panels (PV), Solar Thermal (ST), Heat Pumps (HP), Biomass Boiler (BB), Electric Boiler (EB), Gas Boiler (GB); and at the neighborhood levels: CHP (nCHP), Gas Boiler (nGB), Electric Boiler (nEB), Heat Pumps (nHP). In addition, Batteries (Bat) and Heat Storage (HS) are available at both levels. Different subcategories can be available to choose from within each category, for instance air-water or water-water heat pumps. In parenthesis is the notation used for the rest of the study for each technology.
Unlike the model in , the model used for this paper uses a disaggregrated heat load. The buildings' load are not summed, but types of buildings are identified and the loads are aggregated per building type. It is possible to use a completely disaggregated heat load but the lack of available data motivated not doing it.
The input data necessary to run ZENIT are the electric and heating loads (ideally separated between domestic hot water and space heating), the outside and ground temperatures, the solar insolation and the electricity prices. Hourly timeseries for each representative years are necessary. A description of the neighborhood and its buildings with the floor and the roof area, and the layout of the neighborhoods is also needed.
In this study we assume the heating grid is there (and set the corresponding binary to 1) because there is one in the location that inspired this case. Its characteristics (layout, losses and cost) are then necessary but a module can be used to provide an estimate of the losses and cost based on the layout of the neighborhood.
The $CO_2$ factors used were 17 g$CO_2$/kWh for electricity, 277 g$CO_2$/kWh for gas  and 7 g$CO_2$/kWh for wood chips . The electricity produced via solar panels or
\end{document}


\documentclass[conference]{IEEEtran}
\usepackage{cite}
\usepackage[pdftex]{graphicx}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
  \usepackage[caption=false,font=footnotesize]{subfig}
\usepackage{url}
\usepackage{xcolor}
\usepackage{eurosym}

\begin{document}
 solar thermal on-site do not have $CO_2$ associated. Embedded emissions were not included.
For additional details on the model and the references of the input data used in the model, refer to .
\section{Grid Tariffs Description}
The Norwegian electricity consumption's recent trend is a consumption where peak demand increases relatively more than annual demand. This trend must be met by new incentives to shave peak load in order to avoid costly distribution grid investments. Grid tariffs are one effective way to solve this issue. In this paper we suggest three new grid tariffs and compare the results with the current grid tariff.
The first analyzed grid tariff is energy based and is the current tariff in Norway. It consists of an annual fixed price and a grid energy cost per kWh consumed. As this rate is flat, it does not incentivize flexible resources nor consumption patterns which results in lower peak demand. The annual cost can be calculated using \eqref{energytarifftotal}.
\begin{equation}
    C^{tot} = 137 + 0,0225\cdot \sum_t y_{t}^{imp\_tot}
\end{equation}
The second grid tariff is a time-of-use based tariff which penalizes import when there is typically scarcity in the grid. The tariff has a basic cost, which is double during peak load hours (7-10am and 6-9pm) and reduced to half during low load hours (11pm-5am). The effect of increasing electric vehicle and demand response penetration on the peak hours is ignored. The total costs are given by \eqref{TOUtotal}.
\begin{multline}
    C^{tot} = \sum_t \big( 0,0123\cdot y_{t}^{imp\_low} + 0,0246\cdot y_{t}^{imp\_med} \\
    + 0,0492\cdot y_{t}^{imp\_peak} \big)
\end{multline}
The third tariff was originally described in , and is called capacity subscription. It contains a fixed annual cost (\euro/year), a capacity cost (\euro/kW), an energy cost (\euro/kWh) and an excess demand charge (\euro/kWh). The energy cost is significantly higher when the imports are above the subscription. The main advantage of this tariff is that it incentivizes peak shaving and creates a market for capacity where consumers pay for the resource which in fact is scarce in the distribution grid: capacity. Disadvantages are complexity and the uncertainty in consumer behaviour. In addition, the optimal subscribed capacity is unknown in advance. Finding its value is further discussed in . In this paper, the subscribed capacity is a variable in the optimization. In reality, the consumer would have to choose it and it would most likely not be the optimal value.
The costs are calculated with \eqref{subcaptotal}.
\begin{equation}
   C^{tot} = 108 \cdot c^{sub} + \sum_t \big( 0,005\cdot y_{t}^{imp\_below} + 0,1\cdot y_{t}^{imp\_above} \big)
\end{equation}
The fourth tariff is a dynamic tariff where grid scarcity is taken into account. As an extra incentive to reduce impacts on the grid, a penalization $C^{sc}$ is given for consumption in hours with grid scarcity. Scarcity $\delta _{t}^{sc}$ in the system is defined as the 5\% of hours in the region (NO1) when the load is the highest. The percentage chosen is arbitrary and could be tuned or changed into a threshold by the regulator. The total costs are given by \eqref{dynamictotal}. In addition, as an added incentive to help the grid, a bonus for exporting in those hours is added, at the same cost as the scarcity tariff. In \eqref{dynamictotal}, $\delta _{t}^{sc}$ is a binary parameter defining for each hour if there is scarcity in the grid.
\begin{multline}
    C^{tot} = \sum_t \Big( \big( 0,0225\cdot(1-\delta _{t}^{sc}) + \delta _{t}^{sc} \cdot 0,1 \big) \cdot y_{t}^{imp\_tot} \\ - 0,1 \cdot  \delta _{t}^{sc} \cdot y_{t}^{exp\_tot} \Big)
\end{multline}
\section{Results}
In Norway, the legislation regarding prosumers is changing, moving from a situation where exports are limited to 100kW to a situation of unrestrained export. For this reason, both cases are investigated to explore the consequences on the design of ZENs of the different grid tariffs in these cases.
The investment in the energy system can be seen in Table  and in Table , respectively for the case without and with limitation on exports. The results are presented in the format Prod Plant/ Student Housing/ Normal Offices/ Passive Offices.
The investments stay similar, no new technology is introduced or replaced. However, small variations in the amount of each technology appear, in particular heat storage. The difference between the energy system with and without export limit is greater, namely due to storages. A large battery pack is necessary in order to store the PV production while it waits to be exported, i.e. to accommodate the bottleneck. In addition, large investments in heat storages and electric boilers are done.
The subscribed capacity resulting of the optimization is of 134,5kW for the case with no export limit, and of 124kW in the case with export limits.
Fig.  presents the total cost of the neighborhood's energy system (investment and operation) and the total revenue for the DSO, both over the lifetime and discounted to the start of the study.
There are small variations in the cost in all cases. Subscribed capacity and dynamic pricing cause an increase in the total cost for the ZEN between 3 and 5\% compared with the energy case. On the other hand, the time of use scheme allows for a cost reduction of around 12\% in the case without export limit and 5\% with export limit.
The DSO revenue from the ZEN are higher when using the other pricing schemes than with the energy scheme when there is no export limit. When there is export limits, the DSO revenue stays the same because the battery allows to self-consume more and "anticipates" the higher price periods and buys electricity when the price is lower. The revenue in the case of export limits are about half of the revenue of the case of no export limit except in the case of subscribed capacity where the subscription tariff allows to maintain the revenue.
The cost increase in the ZEN is of the same order of magnitude as the increase in revenue for the DSO except for ToU where the cost of the ZEN decreases while the revenue for the DSO increases. ToU has a beneficial effect from both points  of view in this aspect.
The duration curves Fig. , in the case of no export limit, are not affected much by the tariff scheme in place.
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{authblk}
\usepackage{amsfonts}
\usepackage{natbib}
\bibliographystyle{plainnat}
\usepackage{xr}
\usepackage{hyperref}
\usepackage[toc,page]{appendix}
\usepackage{enumitem}

\begin{document}
Let $\bf{X}$ be a $\mathbb{R}^p$-valued random variable with distribution function $F$. For a point $\bf{x} \in \mathbb{R}^p$, we consider the statistical data depth of $\bf{x}$ with respect to $F$ be $d(\bf{x};F)$ such that $d$ satisfies the four properties given in \citet{Liu1990} and \citet{Zuo2000a} and reported in Appendix  of the Supplementary Material. Given an independent and identically distributed sample $\bf{X}_1, \ldots, \bf{X}_n$ of size $n$, we denote $\hat{F}_n(\cdot)$ its empirical distribution function and by $d(\bf{x}; \hat{F}_n)$ the sample depth. We assume that, $d(\bf{x}; \hat{F}_n)$ is a uniform consistent estimator of $d(\bf{x}; F)$, that is,
\begin{equation*}
\sup_{\bf{x}}| d(\bf{x}; \hat{F}_n) - d(\bf{x}; F) | \stackrel{a.s.}{\rightarrow} 0 \qquad n \rightarrow \infty ,
\end{equation*}
a property enjoined by many statistical data depth functions, e.g., among others simplicial depth \citep{Liu1990}, half-space depth \citep{Tukey1975}. One important feature of the depth functions is the $\alpha$-depth trimmed region given by $R_\alpha(F) = \{ \bf{x} \in \mathbb{R}^p: d(\bf{x}; F) \ge \alpha\}$; for any $\beta \in [0,1]$, we will denote $R^\beta(F)$ the smallest region $R_\alpha(F)$ that has probability larger that or equal to $\beta$ according to $F$. Throughout, subscripts and superscripts for depth regions are used for depth levels and probability contents, respectively. Let $C^\beta(F)$ be the complement in $\mathbb{R}^p$ of the set $R^\beta(F)$. Let $m = \max_{\bf{x}} d(\bf{x};F)$, be the maximum of the depth, for simplicial depth $m \le 2^{-p}$, for half-space depth $m \le 1/2$.
Given a high order quantile $\beta$, we define a filter of dimension $p$ based on
\begin{equation}
d_n = \sup_{\bf{x} \in C^\beta(F)} \{ d(\bf{x}; \hat{F}_n) - d(\bf{x}; F) \}^+ ,
\end{equation}
where $\{a\}^+$ represents the positive part of $a$, and we mark as outliers all the $\lfloor n d_n/m \rfloor$ observations with the smallest population depth (where $\lfloor a \rfloor$ is the largest integer less then or equal to $a$). This define a filter in the general dimension $p$.
We have the following result, with obvious proof.
If $\sup_{\bf{x}}| d(\bf{x}; \hat{F}_n) - d(\bf{x}; F) | = o(n)$ (a.s.) then $n d_n \rightarrow 0$ as $n \rightarrow \infty$.
If the above result holds, then the filter would be consistent. In the next subsection we are going to illustrate this approach using the half-space depth.
\subsection{Filters based on Half-space Depth}
Let $\bf{X}$ be a $\mathbb{R}^p$-valued random variable with distribution function $F$. For a point $\bf{x} \in \mathbb{R}^p$, the half-space depth of $\bf{x}$ with respect to $F$ is defined as the minimum probability of all closed half-spaces including $\bf{x}$:
\begin{equation*}
d_{HS} (\bf{x};F) = \min_{H \in \mathcal{H}(\bf{x})} P_F(\bf{X} \in H).
\end{equation*}
where $\mathcal{H}(\bf{x})$ indicates the set of all half-spaces in $\mathbb{R}^p$ containing $\bf{x} \in \mathbb{R}^p$.
A random vector $\bf{X} \in \mathbb{R}^p$ is said elliptically symmetric distributed, denoted by
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{authblk}
\usepackage{amsfonts}
\usepackage{natbib}
\bibliographystyle{plainnat}
\usepackage{xr}
\usepackage{hyperref}
\usepackage[toc,page]{appendix}
\usepackage{enumitem}

\begin{document}
$\bf{X} \sim E_p(h, \bf{\mu}, \bf{\Sigma})$, if it has a density function given by
\begin{equation*}
f_0(\bf{x}) \propto |\bf{\Sigma}^{-1/2}| h((\bf{x}-\bf{\mu})^\top\bf{\Sigma}^{-1}(\bf{x}-\bf{\mu})) .
\end{equation*}
where $h$ is a non-negative scalar function, $\bf{\mu}$ is the location parameter and $\bf{\Sigma}$ is a $p \times p$ positive definite matrix.
Denote by $F_0$ the corresponding distribution function and by $\Delta_{\bf{x}} = (\bf{x} - \bf{\mu})^\top \bf{\Sigma}^{-1} (\bf{x} - \bf{\mu})$ the squared Mahalanobis distance of a $p$-dimensional point $\bf{x}$. By Theorem 3.3 of \citet{Zuo2000b} if a depth is affine equivariant () and has maximum at $\bf{\mu}$ () (see Appendix ) then a depth is such that $d(\bf{x}; F_0) = g(\Delta_{\bf{x}})$ for some non increasing function $g$ and we can restrict ourselves without loss of generality, to the case $\bf{\mu} = \bf{0}$ and $\bf{\Sigma} = \bf{I}$ where $\bf{I}$ is the identity matrix of dimension $p$. Under this setting, it is easy to see that the half-space depth of a given point $\bf{x}$ is given by $d_{HS}(\bf{x}; F_0) = 1 - F_{0,1}(\sqrt{\Delta_{\bf{x}}})$, where $F_{0,1}$ is a marginal distribution of $\bf{X}$.
If the function $h$ is such that
\begin{equation*}
\frac{\exp(-\frac{1}{2} \Delta)}{h(\Delta)} \rightarrow 0 , \qquad \Delta \rightarrow \infty ,
\end{equation*}
then, there exists a $\Delta^\ast$ such that for all $\bf{x}$ so that $\Delta_{\bf{x}} > \Delta^\ast$, $d_{HS}(\bf{x}; F_0) \ge d_{HS}(\bf{x}; \Phi)$, where $\Phi$ is the distribution function of the standard normal. Hence,
\begin{equation*}
\sup_{\{\bf{x}: \Delta_{\bf{x}} > \Delta^\ast\}} [d_{HS}(\bf{x}; \Phi) - d_{HS}(\bf{x}; F_0)] < 0
\end{equation*}
and therefore, for all $\beta > 1 - 2 F_{0,1}(-\sqrt(\Delta^{\ast}))$,
\begin{equation*}
\sup_{C^\beta(F_0)} [d_{HS}(\bf{x}; \Phi) - d_{HS}(\bf{x}; F_0)] < 0 \ .
\end{equation*}
Given an independent and identically distributed sample $\bf{X}_1, \ldots, \bf{X}_n$, we define the filter in general dimension $p$ introduced previously, where here we use the half-space depth
\begin{equation*}
d_n = \sup_{\bf{x} \in C^\beta(F)} \{ d_{HS}(\bf{x}; \hat{F}_n) - d_{HS}(\bf{x}; F(\bf{T}_{0n}, \bf{C}_{0n})) \}^+ ,
\end{equation*}
where $\beta$ is a high order quantile, $\hat{F}_n(\cdot)$ is the empirical distribution function and $F(\bf{T}_{0n}, \bf{C}_{0n})$ is a chosen reference distribution which depends on a pair of initial location and dispersion estimators, $\bf{T}_{0n}$ and $\bf{C}_{0n}$. Hereafter, we are going to use the normal distribution $F = N(\bf{T}_{0n}, \bf{C}_{0n})$. For $\bf{T}_{0n}$ and $\bf{C}_{0n}$ one might use, e.g., the coordinate-wise median and the coordinate-wise MAD for a univariate filter as in \citet{Zamar2017}. In order to compute the value $d_n$, we have to identify the set $C^\beta(F) = \{ \bf{x} \in \mathbb{R}^p | d_{HS}(\bf{x},F) \le d_{HS}(\eta_\beta,F) \}$ where $\eta_\beta$ is a large quantile of $F$. By Corollary 4.3 in  and denoting with
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{authblk}
\usepackage{amsfonts}
\usepackage{natbib}
\bibliographystyle{plainnat}
\usepackage{xr}
\usepackage{hyperref}
\usepackage[toc,page]{appendix}
\usepackage{enumitem}

\begin{document}
$\Delta_x = (\bf{x} - \bf{T}_{0n})^\top \bf{C}_{0n}^{-1}(\bf{x} - \bf{T}_{0n})$ the squared Mahalanobis distance of $\bf{x}$ using the initial location and dispersion estimates, the set can be rewritten as $C^\beta(F) = \{ \bf{x} \in \mathbb{R}^p | \Delta_x > (\chi^2_p)^{-1}(\beta) \}$, where $(\chi^2_p)^{-1}(\beta)$ is a large quantile of a chi-squared distribution with $p$ degrees of freedom.
Now we want to show that the result given by Proposition  holds for this particular case.
Consider a random vector $(\bf{X}_1, \ldots , \bf{X}_n) \sim F_0(\bf{\mu}_0, \bf{\Sigma}_0)$ and suppose that $F_0$ is an elliptically symmetric distribution. Also consider a pair of location and dispersion estimators $\bf{T}_{0n}$ and $\bf{C}_{0n}$ such that $\bf{T}_{0n} \rightarrow \bf{\mu}_0$ and $\bf{C}_{0n} \rightarrow \bf{\Sigma}_0$ a.s.. Let $F$ be a chosen reference distribution and $\hat{F}_n$ the empirical distribution function. If the reference distribution satisfies
\begin{equation*}
\sup_{\bf{x} \in C^\beta(F_0)} [d_{HS}(\bf{x}; F) - d_{HS}(\bf{x}; F_0)] < 0
\end{equation*}
where $\beta$ is some large quantile of $F_0$, then
\begin{equation*}
n d_n \rightarrow 0 \mbox{ as } n \rightarrow \infty
\end{equation*}
\begin{proof}
In \citet{Donoho1992}, it is proved that for i.i.d. $\bf{X}_1, \bf{X}_2, ... , \bf{X}_n$ with distribution $F_0$, as $n \rightarrow \infty$
\begin{equation*}
\sup_{\bf{t} \in \mathbb{R}^d} |d_{HS}(\bf{t},F_0) - d_{HS}(\bf{t},\hat{F}_n)| \rightarrow 0   \mbox{   a.s.}
\end{equation*}
Note that, by the continuity of $F$, $F(\bf{T}_{0n}, \bf{C}_{0n}) \rightarrow F(\bf{\mu}_0, \bf{\Sigma}_0)$ a.s..
Hence, for each $\varepsilon > 0$ there exists $n_0$ such that for all $n > n_0$ we have
\begin{align*}
  \sup_{\bf{x} \in C^\beta(F_0)} \{ d_{HS}(\bf{x};  \hat{F}_n) - d_{HS}(\bf{x}; F(\bf{T}_{0n}, \bf{C}_{0n})) \} \le \\
   \sup_{\bf{x} \in C^\beta(F_0)} \{ d_{HS}(\bf{x}; \hat{F}_n) - d_{HS}(\bf{x}; F_0(\bf{\mu}_0, \bf{\Sigma}_0)) \} + \\
															 \sup_{\bf{x} \in C^\beta(F_0)} \{ d_{HS}(\bf{x}; F_0(\bf{\mu}_0, \bf{\Sigma}_0)) - d_{HS}(\bf{x}; F(\bf{\mu}_0, \bf{\Sigma}_0)) \} + \\
															 \sup_{\bf{x} \in C^\beta(F_0)} \{ d_{HS}(\bf{x}; F(\bf{\mu}_0, \bf{\Sigma}_0)) - d_{HS}(\bf{x}; F(\bf{T}_{0n}, \bf{C}_{0n})) \}  \\
															\le     \frac{\varepsilon}{2} + 0 + \frac{\varepsilon}{2} = \varepsilon
\end{align*}
\end{proof}
In the next example, we illustrate a univariate filter based on half-space depth that controls independently the left and the right tail of the distribution.
In the univariate case, given a point $x$ there exist only two halfspaces including it, hence the half-space depth assumes the explicit form
\begin{align*}
d_{HS}(x;F)  =  \min (P_F((-\infty,x]),P_F([x,\infty))) \\
		    = \min (F(x) , 1 - F(x) + P_F(X = x)),
\end{align*}
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{authblk}
\usepackage{amsfonts}
\usepackage{natbib}
\bibliographystyle{plainnat}
\usepackage{xr}
\usepackage{hyperref}
\usepackage[toc,page]{appendix}
\usepackage{enumitem}

\begin{document}
and considering the empirical distribution function $\hat{F}_n(\cdot)$, the halfspace depth will be
\begin{equation*}
d_{HS}(x,\hat{F}_n) = \min \biggl( \frac{1}{n} \sum_{i=1}^n I(X_i \leq x) , \frac{1}{n} \sum_{i=1}^n I(X_i \geq x) \biggr).
\end{equation*}
Consider $\bf{T}_{0n} = (T_{0n,1}, \ldots, T_{0n,p})$ and $\bf{S}_{0n} = (S_{0n,1}, \ldots, S_{0n,p})$, a pair of initial location and dispersion estimators. Here we choose for  $\bf{T}_{0n}$ and $\bf{S}_{0n}$ respectively the coordinate-wise median and the median absolute deviation (MAD).
For each variable $(X_{1j}, X_{2j}, \ldots, X_{nj})$ ($j=1, \ldots, p$), we denote the standardized version of $X_{ij}$ by $Z_{ij}= \frac{X_{ij} - T_{0n,j}}{S_{0n,j}}$. Let $F_j$ a chosen reference distribution for $Z_{ij}$; here we use the standard normal distribution, i.e., $F_j = \Phi$.
Let $\hat{F}_{n,j}$ be the empirical distribution for the standardized values, that is
\begin{equation*}
\hat{F}_{n,j}(t) = \frac{1}{n} \sum_{i=1}^{n} I(Z_{ij} \leq t) \qquad j = 1, \ldots, p.
\end{equation*}
We define the proportion of flagged outliers by
\small
\begin{equation*}
d_{n,j} = \max \biggl( \sup_{t \leq -\eta_{\beta,j}} \{d_{HS}(t,\hat{F}_{n,j}) - d_{HS}(t, F_j)\}^+ ; \sup_{t \geq \eta_{\beta,j}} \{d_{HS}(t,\hat{F}_{n,j}) - d_{HS}(t, F_j)\}^+ \biggr),
\end{equation*}
\normalsize
where $\eta_{\beta,j} = F_j^{-1}(\beta)$ is a large quantile of $F_j$. Note that, according to (), we are considering the set $C^\beta(F_j) = \{x \in \mathbb{R} : d_{HS}(x,F_j) < d_{HS}(\eta_{\beta,j})\}$, which results in the simpler form written above considering the definition of the half-space depth in the univariate case.
Here, if we consider the order statistics $Z_{(i),j}$, define $i_- = \min \{ i : Z_{(i),j} > -\eta_{\beta,j} \}$  and $i_+ = \max \{ i : Z_{(i),j} < \eta_{\beta,j} \}$. Using the definition of half-space depth function in the univariate case, presented above, the previous expression can be written as
\begin{equation}
d_{n,j} = \max \biggl( \sup_{i < i_-} \{\frac{i}{n} -  F_j(Z_{(i),j})\}^+ , \sup_{i > i_+} \{ F_j(Z_{(i),j}) - \frac{i-1}{n}\}^+ \biggr).
\end{equation}
Then, we flag $\lfloor nd_{n,j} \rfloor$ observations with the smallest depth value as cell-wise outliers and replace them by NA's.
\subsection{A consistent univariate, bivariate and $p$-variate filter}
Given a sample $\bf{X}_1, \ldots, \bf{X}_n$ where $\bf{X}_i \in \mathbb{R}^p, i = 1, \ldots, n$, we first apply the univariate filter described in the previous example to each variable separately. Filtered data are indicated through an auxiliary matrix $\bf{U}$ of zeros and ones,
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{authblk}
\usepackage{amsfonts}
\usepackage{natbib}
\bibliographystyle{plainnat}
\usepackage{xr}
\usepackage{hyperref}
\usepackage[toc,page]{appendix}
\usepackage{enumitem}

\begin{document}
with zero corresponding to a NA value. Next we want to identify the bivariate outliers by iterating the filter over all possible pairs of variables. Consider a pair of variables $\bf{X}^{(jk)} = \{ (X_{ij},X_{ik}) \}, i = 1, \ldots, n$. The initial location and dispersion estimators are, respectively, the coordinate-wise median and the $2 \times 2$ sub-matrix $S^{(jk)}$ of the estimate $S$ computed by the generalized S-estimator on non-filtered data. Note that, this ensure the positive definiteness property for $S$ and each $d \times d$ sub-matrix corresponding to a subset of $d$ variables. For bivariate points with no flagged components by the univariate filter we compute the squared Mahalanobis distance $\Delta^{(jk)}_i$ and hence apply the bivariate filter, for all $1 < j < k < p$. At the end we want to identify the cells $(i,j)$ which have to be flagged as cell-wise outliers. The procedure used for this purpose is described in \citet{Zamar2017} and reported here. Let
\begin{equation*}
J = \{ (i,j,k) : \Delta_i^{(jk)} \mbox{ is flagged as bivariate outlier} \}
\end{equation*}
be the set of triplets which identifies the pairs of cells flagged by the bivariate filter in rows $i = 1, \ldots, n$. For each cell $(i,j)$ in the data, we count the number of flagged pairs in the $i$-th row in which the considered cell is involved:
\begin{equation*}
m_{ij} = \#\{ k : (i,j,k) \in J\}.
\end{equation*}
In absence of contamination, $m_{ij}$ follows approximately a binomial distribution $Bin(\sum_{k \not = j}\bf{U}_{jk},\delta)$ where $\delta$ represents the overall proportion of cell-wise outliers undetected by the univariate filter. Hence, we flag the cell $(i,j)$ if $m_{ij} > c_{ij}$, where $c_{ij}$ is the $0.99$-quantile of $Bin(\sum_{k \not = j}\bf{U}_{jk},0.1)$.
Finally, we perform the $p$-variate filter as described in subsection  to the full data matrix. Detected observations (rows) are directly flagged as $p$-variate (case-wise) outliers. We denote the procedure based on univariate, bivariate and $p$-variate filters, HS-UBPF.
\subsection{A  sequencing filtering procedure}
Suppose we would like to apply a sequence of $k$ filters with different dimension $1 \le d_1 \le d_2 \le \ldots \le d_k \le p$. For each $d_i$, $i = 1, \ldots, k$, the filter updates the data matrix adding NA values to the $d_i$-tuples identified as $d_i$-variate outliers. In this way, each filter applies only those $d_i$-tuples that have not been flagged as outliers by the filters with lower dimension.
Initial values for each procedures rather than $d_1$ would be obtained by applying the GSE to the actual filtered values.
This procedure aims to be a valid alternative to that used in the presented HS-UBPF filter to perform a sequence of filters with different dimensions. However, this is a preliminary idea, indeed it has not been implemented yet.
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{authblk}
\usepackage{amsfonts}
\usepackage{natbib}
\bibliographystyle{plainnat}
\usepackage{xr}
\usepackage{hyperref}
\usepackage[toc,page]{appendix}
\usepackage{enumitem}

\begin{document}
\section{Gervini-Yohai $d$-variate filter}
In this Section we are going to show that the filters introduced in  are a special case of our approach, using the following Gervini-Yohai depth
\begin{equation*}
d_{GY}(\bf{t}, F, G) = 1 - G(\Delta(\bf{t},\bf{\mu}(F),\bf{\Sigma}(F))) ,
\end{equation*}
where $G$ is a continuous distribution function, $\bf{\mu}(F)$ and $\bf{\Sigma}(F)$ are the location and scatter matrix functionals and $\Delta(t, F) = \Delta(\bf{t}, \bf{\mu}(F), \bf{\Sigma}(F)) = (\bf{t} - \bf{\mu}(F))^\top \bf{\Sigma}(F)^{-1} (\bf{t} - \bf{\mu}(F))$ is the squared Mahalanobis distance. Appendix  shows that this is a statistical data depth function. Let $\{ G_n \}_{n=1}^\infty$ be a sequence of discrete distribution functions that might depends on $\hat{F}_n$ and such that $\sup_{t} |G_n(t) - G(t)| \stackrel{a.s.}{\rightarrow} 0$, we might define the finite sample version of the Gervini-Yohai depth as
\begin{equation*}
d_{GY}(\bf{t}, \hat{F}_n, G_n) = 1 - G_n(\Delta(\bf{t},\bf{\mu}(\hat{F}_n),\bf{\Sigma}(\hat{F}_n))) \ ,
\end{equation*}
however for filtering purpose we will use two alternative definitions later on.
The use of $G_n$, that might depend on the data, instead of $G$ makes this sample depth semiparametric. We notice that the Mahalanobis depth, which is completely parametric, cannot be used for the purpose of defining a filter in a similar fashion.
Let $1 \le d \le p$, $j_1, \ldots, j_d$ be an $d$-tuple of the integer numbers $1, \ldots, p$ and, for easy of presentation, let $\bf{Y}_i = (X_{ij_1}, \ldots , X_{ij_d})$ be a subvector of dimension $d$ of $\bf{X}_i$. Consider a pair of initial location and scatter estimators
\begin{equation*}
 \bf{T}_{0n}^{(d)} =  \left (
				\begin{array}{ll}
				T_{0n,j_1} \\
 				\ldots \\
				T_{0n,j_d}
				\end{array}
			\right )
			\quad \mbox{ and } \quad
        \bf{C}_{0n}^{(d)} =  \left (
				\begin{array}{lll}
				C_{0n,j_1j_1}  \ldots    C_{0n,j_1j_d} \\
 				\ldots             \ldots       \ldots            \\
				C_{0n,j_dj_1} \ldots     C_{0n,j_dj_d}
				\end{array}
			\right ) \ .
\end{equation*}
Now, define the squared Mahalanobis distance for a data point $\bf{Y}_i$ by $\Delta_i = \Delta(\bf{Y}_i, \hat{F}_n) = \Delta(\bf{Y}_i, \bf{T}_{0n}^{(d)}, \bf{C}_{0n}^{(d)})$. Consider $G$ the distribution function of a $\chi_d^2$, $H$ the distribution function of $\Delta = \Delta(\cdot, F)$ and let $\hat{H}_n$ be the empirical distribution function of $\Delta_i$ ($1 \le i \le n$). We consider two finite sample version of the Gervini-Yohai depth, i.e.,
\begin{equation*}
d_{GY}(\bf{t}, \hat{F}_n, G) = 1 - G(\Delta(\bf{t}, \hat{F}_n)) ,
\end{equation*}
and
\begin{equation*}
d_{GY}(\bf{t}, \hat{F}_n, \hat{H}_n) = 1 - \hat{H}_n(\Delta(\bf{t}, \hat{F}_n)) .
\end{equation*}
The proportion of flagged $d$-variate outliers is defined by
\begin{equation*}
d_n = \sup_{\bf{t} \in A} \{ d_{GY}(\bf{t}, \hat{F}_n, \hat{H}_n) - d_{GY}(\bf{t}, \hat{F}_n, G) \}^+ .
\end{equation*}
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{authblk}
\usepackage{amsfonts}
\usepackage{natbib}
\bibliographystyle{plainnat}
\usepackage{xr}
\usepackage{hyperref}
\usepackage[toc,page]{appendix}
\usepackage{enumitem}

\begin{document}
Here $A = \{ \bf{t} \in \mathbb{R}^d: d_{GY}(\bf{t}, F, G) \leq d_{GY}(\bf{\zeta}, F, G) \}$, where $\bf{\zeta}$ is any point in $\mathbb{R}^d$ such that $\Delta(\bf{\zeta}, F)  = \eta$ and $\eta = G^{-1}(\alpha)$ is a large quantile of $G$. Then, we flag $\lfloor nd_{n} \rfloor$ observations. It is easy to see that,
\begin{align*}
d_n  = \sup_{\bf{t} \in A} \{ [1 - \hat{H}_n(\Delta(\bf{t}, \hat{F}_n))] - [1 - G(\Delta(\bf{t}, \hat{F}_n))] \}^+ \\
 =  \sup_{\bf{t} \in A} \{ G(\Delta(\bf{t}, \hat{F}_n)) - \hat{H}_n(\Delta(\bf{t}, \hat{F}_n)) \}^+ \\
 = \sup_{\Delta \ge \eta} \{ G(\Delta) - \hat{H}_n(\Delta) \}^+
\end{align*}
since $d_{GY}$ is a non increasing function of the squared Mahalanobis distance of the point $\bf{t}$.
We can rephrase Proposition 2. in \citet{Zamar2017}, that states the consistency property of the filter as follows.
Consider a random vector $\bf{Y} = (X_{1}, \ldots, X_{d}) \sim F_0$ and a pair of location and scatter estimators $\bf{T}_{0n}$ and $\bf{C}_{0n}$ such that $\bf{T}_{0n} \rightarrow \bf{\mu}_0 = \bf{\mu}(F_0) \in \mathbb{R}^d$ and $\bf{C}_{0n} \rightarrow \bf{\Sigma}_0 = \bf{\Sigma}(F_0)$ a.s.. Consider any continuous distribution function $G$ and let $\hat{H}_n$ be the empirical distribution function of $\Delta_i$ and $H_0(t) = \Pr ((\bf{Y} - \bf{\mu}_0)^t \bf{\Sigma}_0^{-1}(\bf{Y} - \bf{\mu}_0) \le t )$. If the distribution $G$ satisfies:
\begin{equation}
\max_{\bf{t} \in A} \{ d_{GY}(\bf{t},F_0,H_0) - d_{GY}(\bf{t},F_0,G) \} \le 0 ,
\end{equation}
where $A = \{ \bf{t} \in \mathbb{R}^d: d_{GY}(\bf{t}, F_0, G) \leq d_{GY}(\bf{\zeta}, F_0, G) \}$, where $\bf{\zeta}$ is any point in $\mathbb{R}^d$ such that $\Delta(\bf{\zeta}, F_0)  = \eta$ and $\eta = G^{-1}(\alpha)$ is a large quantile of $G$, then
\begin{equation*}
\frac{n_0}{n} \rightarrow 0 \qquad \text{a.s.}
\end{equation*}
where
\begin{equation*}
n_0 = \lfloor nd_{n} \rfloor .
\end{equation*}
\begin{proof}
Note that
\begin{equation*}
d_{GY}(\bf{t},\hat{F}_n,\hat{H}_n) - d_{GY}(\bf{t},\hat{F}_n, G) = G(\Delta(\bf{t},\bf{T}_{0n},\bf{C}_{0n})) - \hat{H}_n(\Delta(\bf{t},\bf{T}_{0n},\bf{C}_{0n}))
\end{equation*}
and condition in equation () is equivalent to
\begin{equation*}
\max_{\Delta \ge \eta} \{G(\Delta) - H_0(\Delta) \} \le 0 ,
\end{equation*}
The rest of the proof is the same as in Proposition 2. of \citet{Zamar2017}.
\end{proof}
Figure  shows the bivariate scatter plot of WTS versus HTLD, HTLD versus WSBC and WSBC versus SUR where the GY-UBF and HS-UBF filters are applied, respectively. The bivariate observations with at least one component flagged as outlier are in blue, and outliers detected by the bivariate filter are in orange. We see that the HS-UBF identifies less outliers with respect to the GY-UBF.
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{authblk}
\usepackage{amsfonts}
\usepackage{natbib}
\bibliographystyle{plainnat}
\usepackage{xr}
\usepackage{hyperref}
\usepackage[toc,page]{appendix}
\usepackage{enumitem}

\begin{document}
\section{Monte Carlo results}
We performed a Monte Carlo simulation to assess the performance of the proposed filter based on halfspace depth. After the filter flags the outlying observations, the generalized S-estimator is applied to the data with added missing values. Our simulation study is based on the same setup described in \citet{Zamar2017} to compare significantly the performance of our filter with respect to the filter introduced in their work.
We considered samples from a $N_p(\bf{0}, \bf{\Sigma}_0)$, where all values in  $diag(\bf{\Sigma}_0)$ are equal to $1$, $p = 10, 20, 30, 40, 50$ and the sample size is $n = 10p$. We consider the following scenarios:
\begin{itemize}
\item Clean data: data without changes.
\item Cell-Wise contamination: a proportion $\epsilon$ of cells in the data is replaced by $X_{ij} \sim N(k,0.1^2)$, where $k = 1, \ldots, 10$.
\item Case-Wise contamination: a proportion $\epsilon$ of cases in the data matrix is replaced by $\bf{X}_i \sim 0.5N(c\bf{v},0.1^2\bf{I}) + 0.5N(-c\bf{v},0.1^2\bf{I})$, where $c = \sqrt{k(\chi^2_p)^{-1}(0.99)}$, $k = 1, 2, \ldots,20$ and $\bf{v}$ is the eigenvector corresponding to the smallest eigenvalue of $\bf{\Sigma}_0$ with length such that $(\bf{v}-\bf{\mu}_0)^\top\bf{\Sigma}_0^{-1}(\bf{v}-\bf{\mu}_0) = 1$.
\end{itemize}
The proportions of contaminated rows chosen for case-wise contamination are $\epsilon = 0.1, 0.2$, and $\epsilon = 0.02,0.05$ for cell-wise contamination. The number of replicates in our simulation study is $N=200$.
We measure the performance of a given pair of location and scatter estimators $\hat{\bf{\mu}}$ and $\hat{\bf{\Sigma}}$ using the mean squared error (MSE) and the likelihood ratio test distance (LRT), as in:
\begin{align*}
 MSE = \frac{1}{N}\sum_{i=1}^N (\hat{\bf{\mu}}_i - \bf{\mu}_0)^\top (\hat{\bf{\mu}}_i - \bf{\mu}_0) \\
 LRT(\hat{\bf{\Sigma}},\bf{\Sigma}_0) = \frac{1}{N}\sum_{i=1}^N D(\hat{\bf{\Sigma}}_i,\bf{\Sigma}_0)
\end{align*}
\section{Statistical data depth properties}
A \textbf{depth function} $d(\cdot; F)$ measures the centrality of a point w.r.t. a probability distribution $F$.
\begin{equation*}
d = \mathbb{R}^{p} \rightarrow \mathbb{R}^+ \cup \{ 0 \}, \qquad \bf{x} \rightarrow d(\bf{x}; F)
\end{equation*}
A statistical depth function should satisfy the following Properties
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{authblk}
\usepackage{amsfonts}
\usepackage{natbib}
\bibliographystyle{plainnat}
\usepackage{xr}
\usepackage{hyperref}
\usepackage[toc,page]{appendix}
\usepackage{enumitem}

\begin{document}
\begin{enumerate}[label=\textbf{P\arabic*}]
\item  Affine invariance: $d(\bf{x}; F)=d(\bf{A} \bf{x}+ \bf{b}; F_{\bf{A},\bf{b}})$;
\item  Maximality at center: if $F$ is ``symmetric'' around $\bf{\mu}$ then $d(\bf{x}; F) \leq d(\bf{\mu}; F)$ for all $\bf{x}$; for a more detailed discussion on symmetry see \citet{Serfling2006}.
\item  Monotonicity: if () holds, then
\begin{equation*}
d(\bf{x}; F) \le d(\bf{\mu} + \alpha (\bf{x} - \bf{\mu}); F) \qquad \alpha \in [0,1] \ ;
\end{equation*}
\item  Approaching zero: $\parallel \bf{x} \parallel \rightarrow \infty \Rightarrow d(\bf{x}; F) \rightarrow 0$.
\end{enumerate}
\section{Gervini-Yohai depth}
Here we want to show that the Gervini-Yohai depth, defined as $d_{GY}(\bf{t}, F, G) = 1 - G(\Delta(\bf{t},\bf{\mu}(F),\bf{\Sigma}(F)))$, is a proper statistical depth function, i.e., it satisfies the four properties introduced above.
\begin{enumerate}
\item Affine invariance: it follows directly from the affine invariance property of the Mahalanobis distance;
\item  Maximality at center: if $F$ is elliptically symmetric around $\bf{\mu}(F)$,
\begin{equation*}
d_{GY}(\bf{\mu}(F), F, G) = 1 - G(\Delta(\bf{\mu}(F),\bf{\mu}(F),\bf{\Sigma}(F))) = 1 - G(0) .
\end{equation*}
For any $\bf{t} \not= \bf{\mu}(F)$ we have
\begin{align*}
\Delta(\bf{t},\bf{\mu}(F),\bf{\Sigma}(F))  > 0 \\
G(\Delta(\bf{t},\bf{\mu}(F),\bf{\Sigma}(F)))  \ge G(0) \\
1-G(\Delta(\bf{t},\bf{\mu}(F),\bf{\Sigma}(F)))  \le 1- G(0) \\
d_{GY}(\bf{t}, F, G)   \le d_{GY}(\bf{\mu}(F), F, G) ,
\end{align*}
when $G$ is strictly monotone then strict inequality holds, and $\bf{\mu}(F)$ is the unique maximizer of the Gervini-Yohai depth.
\item  Monotonicity:
\begin{align*}
\Delta(\bf{\mu}(F) + \alpha(\bf{t}-\bf{\mu}(F)),\bf{\mu}(F),\bf{\Sigma}(F))  = (\alpha(\bf{t} - \bf{\mu}(F)))^\top \bf{\Sigma}(F)^{-1}(\alpha(\bf{t} - \bf{\mu}(F))) \\
														 = \alpha^2 (\bf{t} - \bf{\mu}(F))^\top \bf{\Sigma}(F)^{-1}(\bf{t} - \bf{\mu}(F)) \\
														 = \alpha^2 \Delta(\bf{t},\bf{\mu}(F),\bf{\Sigma}(F)) \\
														 \le \Delta(\bf{t},\bf{\mu}(F),\bf{\Sigma}(F))
\end{align*}
Then  $d_{GY}(\bf{\mu}(F) + \alpha(\bf{t}-\bf{\mu}(F)), F, G) \ge d_{GY}(\bf{t}, F, G)$.
\item Approaching zero: if $\parallel \bf{t} \parallel \rightarrow \infty $ we have that $\Delta(\bf{t},\bf{\mu}(F),\bf{\Sigma}(F)) \rightarrow \infty$ and consequently  $G(\Delta(\bf{t},\bf{\mu}(F),\bf{\Sigma}(F))) \rightarrow 1$.
Then
\begin{equation*}
d_{GY}(\bf{t}, F, G) = 1 - G(\Delta(\bf{t},\bf{\mu}(F),\bf{\Sigma}(F))) \rightarrow 0
\end{equation*}
\end{enumerate}
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}
\pagestyle{plain}
\usepackage{fancybox}
\usepackage{bm}
\begin{document}
\allowdisplaybreaks
The models have a subgroup of $E_8$ as the symmetry. The subgroup is determined by the choice of the flux and punctures, that is it is the subgroup of $E_8$ commuting with the choice of flux in the case of closed Riemann surface. For properly quantized flux this has rank eight, for fractional values of flux the rank might be smaller. Every puncture is associated with additional factor of ${\rm SU}(2)$ symmetry. The punctures come in different types which we refer to as different colors.
Models corresponding to different surfaces can be glued together by gauging a symmetry corresponding to punctures of the same color. The color of the punctures determines what are the details of the gluing. The punctures break the $E_8$ symmetry of the six dimensional model to ${\rm U}(1)\times {\rm SU}(8)$ sub group. The flux might break the symmetry further. In particular the color is determined by the ${\rm U}(1)\times {\rm SU}(8)$ subgroup of $E_8$ which the puncture keeps. The subgroup preserved by given puncture is parametrized by fugacity $t$ for ${\rm U}(1)$ and fugacities $a_i$ for ${\rm SU}(8)$ ($i=1,\dots, 8$ and $\prod\limits_{i=1}^8 a_i=1$). For different colors of punctures the fugacities of one are expressible in terms of monomial products of the other. When we glue two punctures together the index of the theory is
\begin{gather*}
T_{\rm combined}=T_{\mathfrak J}^{A}(u)\times_u T_{\mathfrak J}^{B}(u)\equiv (q;q)(p;p)\oint\frac{{\rm d}u}{4\pi i u} \frac{\prod\limits_{j=1}^8\Gamma_e\big((q p)^{\frac12 }\frac1{t^{\mathfrak J}} \big(a^{\mathfrak J}_j\big)^{-1} u^{\pm1}\big)}{\Gamma(u^{\pm2})} .
\end{gather*}
Here the indices $A$ and $B$ stand for {\it Theory A} and {\it Theory B}. The gamma functions appearing in the denominator correspond to ${\mathcal N}=1$ vector fields and the gamma functions in the numerator to a collection of eight chiral fields in fundamental representation of the gauged symmetry. This collection of chiral fields couples to certain chiral operators of the two glued copies which generalize the moment map operators of the class~${\mathcal S}$ case.
We will use the shorthand notation $\times_u$ to indicate the gluing. Here $T_{\mathfrak J}(u)$ is an index of a theory corresponding to some Riemann surface with puncture of color ${\mathfrak J}$ with associated symmetry ${\rm SU}(2)_u$. The parameters $t^{\mathfrak J}$ and $a^{\mathfrak J}$ label the ${\rm U}(1)\times {\rm SU}(8)$ symmetry preserved by the puncture.
Let us define the basic building blocks of our construction. We define the tube $T_{{\mathfrak J},\overline{\mathfrak J}}(z,u)$ to be
\begin{gather*}
T_{{\mathfrak J},\overline{\mathfrak J}}(u,z)=\Gamma_e\big(q p t^4\big)\left(\prod_{j=1}^8\Gamma_e\big((q p)^{\frac12}t a_j z^{\pm1}\big)\Gamma_e\big(( q p)^{\frac12} t a_j^{-1} u^{\pm1}\big)\right)\Gamma_e\left(\frac1{t^2}u^{\pm1}z^{\pm1}\right) .
\end{gather*}
This tube is the model obtained as compactification on sphere with two punctures and flux $-1/2$ for ${\rm U}(1)_t$ and zero flux for other symmetries. The model is an IR free Wess--Zumino theory. From this we can construct cap theories
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}
\pagestyle{plain}
\usepackage{fancybox}
\usepackage{bm}
\begin{document}
\allowdisplaybreaks
$C^{(M,L; i)}_{{\mathfrak J}}(z)$, corresponding to a sphere with single puncture, by computing residues. We define these to be
\begin{gather*}
C^{(M,L;i)}_{{\mathfrak J}}(z)=\frac1{\Big(\prod\limits_{j\neq i}\Gamma_e(a_i/a_j)\Big)\Gamma_e\big( pq t^2\frac1{a_i^2}\big)(q;q)(p;p)}\operatorname{Res}_{u\to \frac1{(q p)^{\frac12} q^M p^L t} a_i} \frac1u T_{{\mathfrak J},\overline{\mathfrak J}}(u,z) .
\end{gather*}
 The cap theory for zero values of $M$ and $L$ is a model corresponding to sphere with one puncture and flux $-\frac34$ for ${\rm U}(1)_t$, $\frac78$ for ${\rm U}(1)_i$, and $-\frac18$ for ${\rm U}(1)_j$. See for details of the derivation of the flux.
The index can be thought as partition function on ${\mathbb S}^1\times {\mathbb S}^3$, and for non vanishing values of~$M$ and~$L$ the theory
also has surface defects wrapping the~${\mathbb S}^1$ and one of the two equators of~${\mathbb S}^3$. Finally we have a three punctured sphere $T_{{\mathfrak J}_B,{\mathfrak J}_C,{\mathfrak J}_D}(w,u,v)$
\begin{gather*}
T_{{\mathfrak J}_B,{\mathfrak J}_C,{\mathfrak J}_D}(w,u,v) = \Gamma_e\big((q p)^{\frac12} t\big(B^{-1}A\big)^{\pm1} w^{\pm1}\big)\Gamma_e\left(\frac{q p}{t^2}\right) (q;q)(p;p)\\
\quad{} \times \oint \frac{{\rm d} h}{4\pi i h} \frac{\Gamma_e\big(\frac{(p q)^{\frac12}}{t^2}\big(A B^{-1}\big)^{\pm1}h^{\pm1}\big)}{\Gamma_e\big(h^{\pm2}\big)}\Gamma_e\big(t h^{\pm1} w^{\pm1}\big) H\big(u,D,v,C,\sqrt{h B},\sqrt{h^{-1}B}; A\big),
\end{gather*} where we have defined
\begin{gather}
H(z_1,z_2,v_1,v_2, a , b; A ) = (q;q)^2(p;p)^2\oint\frac{{\rm d}w_1}{4\pi i w_1}\oint \frac{{\rm d}w_2}{4\pi i w_2} \frac{\Gamma_e\big(\frac{(p q)^{\frac12}}{t^2}w_1^{\pm1}w_2^{\pm1}\big)}{\Gamma_e\big(w_2^{\pm2}\big)\Gamma_e\big(w_1^{\pm2}\big)} \nonumber\\
 \quad{} \times \Gamma_e\big( (q p)^{\frac14}t A^{\frac12}b^{-1} w_1^{\pm1}z_1^{\pm1}\big) \Gamma_e\big((qp)^{\frac14} A^{\frac12} bw_1^{\pm1}z_2^{\pm1}\big)\Gamma_e\big((q p)^{\frac14} t A^{-\frac12} b w_2^{\pm1} z_1^{\pm1}\big)\nonumber\\
\quad{} \times \Gamma_e \big((q p)^{\frac14} A^{-\frac12} b^{-1} z_2^{\pm1}w_2^{\pm1}\big) \Gamma_e\big((q p)^{\frac14} t A^{-\frac12} a w_1^{\pm1} v_1^{\pm1}\big)\Gamma_e\big( ( q p)^{\frac14} A^{-\frac12} a^{-1} v_2^{\pm1} w_1^{\pm1}\big)\nonumber\\
\quad{} \times \Gamma_e\big( ( q p )^{\frac14} t A^{\frac12} a^{-1} w_2^{\pm1} v_1^{\pm1}\big) \Gamma_e\big( ( q p )^{\frac14} A^{\frac12} a w_2^{\pm1} v_2^{\pm1}\big) .
 \end{gather}
The above expressions are non trivial to derive. The theory corresponding to three punctured spheres is constructed by starting from a gauge theory, index of which is roughly speaking $H$, and arguing that at some point on the conformal manifold the ${\rm U}(1)$ symmetry corresponding to fugacity $\sqrt{a/b}$ enhances to ${\rm SU}(2)$. This is a non trivial fact which follows from dualities. This~${\rm SU}(2)$ is then taken to be dynamical with addition of some chiral fields. The resulting index is given above. The statement that this theory corresponds to three punctured sphere is made by performing a variety of physical consistency checks. Note that the construction also gives a theory having only rank five symmetry as opposed to rank eight.
For the three punctured sphere we have flux $3/4$ for ${\rm U}(1)_t$ and vanishing flux for the Cartan generators of ${\rm SU}(8)$. The three punctured sphere depends on four parameters $(A,B,C,D)$ which parametrize ${\rm SO}(8)$ inside ${\rm SU}(8)$. That is,
\begin{gather}
 (a_1,a_2,a_3,a_4) =A^{\pm1} B^{\pm1} ,\qquad (a_5,a_6,a_7,a_8) =C^{\pm1} D^{\pm1} .
\end{gather}
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}
\pagestyle{plain}
\usepackage{fancybox}
\usepackage{bm}
\begin{document}
In principle there should be three punctured spheres depending on all eight parameters but the particular construction of gives us a three punctured sphere only depending on five with the map to eight parameters written above.
The three punctures are of different color
\begin{gather*}
w\colon \ {\mathfrak J}_B=\big(t; A^{\pm1}B^{\pm1},C^{\pm1}D^{\pm1}\big) , \\
u\colon \ {\mathfrak J}_C=\big(t;A^{\pm1}D^{\pm1},B^{\pm1}C^{\pm1}\big) , \\
v\colon \ {\mathfrak J}_D=\big(t; A^{\pm1}C^{\pm1}, B^{\pm1}D^{\pm1}\big) .
\end{gather*}
Without loss of any generality let us assume that we will compute residues with respect to $a_1=A B^{-1}$. Then as we have only a subgroup of ${\rm SU}(8)$ we need to specify the flux for this. We obtain that the flux for the cap is
\begin{gather*} \big({\rm U}(1)_A,{\rm U}(1)_B,{\rm U}(1)_C,{\rm U}(1)_D\big) = \big(\tfrac14,-\tfrac14,0,0\big) .
\end{gather*}
\section{Defect operators}
Using the building blocks of the previous section we can introduce surface defects into the index computation. Given a model of some flux and corresponding to some surface we introduce a~defect operator by gluing to the surface first two three punctured spheres and then closing two of the punctures with caps. In case one closes the two punctures with cap defined by residues $(0,0;i)$ and $(0,0;\overline i)$, where by $\overline i$ we mean $a_j$ such that $a_i=1/a_j$, one adds tube with zero flux, which gives us the original model without defect. We can indeed check, see Appendix, that the index satisfies such property
\begin{gather}
T_{{\mathfrak J}_C}(u)= T_{{\mathfrak J}_C}(z)\times_z \big(\big(T_{{\mathfrak J}_B, {\mathfrak J}_C,{\mathfrak J}_D}(h,z,g)\times_h C^{(0,0;i)}_{{\mathfrak J}_B}(h)\big)\nonumber\\
\hphantom{T_{{\mathfrak J}_C}(u)=}{}
\times_g\big(T_{{\mathfrak J}_B, {\mathfrak J}_C,{\mathfrak J}_D}(v,u,g)\times_v C^{(0,0;\overline i)}_{{\mathfrak J}_B}(v)\big)\big) .
\end{gather}
However, when we close one of the punctures with $(M,L;i)$ and other with $(0,0;\overline i)$ we introduce a surface defect. Performing the computation with $M=1$ and $L=0$, see Appendix, we can see that the index is given by acting on the one with no defect by a~difference operator
\begin{gather*}
{\mathfrak D}_{{\mathfrak J}_D}^{{\mathfrak J}_B,(1,0;i)}T_{{\mathfrak J}_D}(u)=
T_{{\mathfrak J}_D}(g)\times_g \big(\big(T_{{\mathfrak J}_B, {\mathfrak J}_C,{\mathfrak J}_D}(h,z,g)\times_h C^{(0,0;i)}_{{\mathfrak J}_B}(h)\big)\\
\hphantom{{\mathfrak D}_{{\mathfrak J}_D}^{{\mathfrak J}_B,(1,0;i)}T_{{\mathfrak J}_D}(u)=}{}
\times_z\big(T_{{\mathfrak J}_B, {\mathfrak J}_C,{\mathfrak J}_D}(v,z,u)\times_v C^{(1,0;\overline i)}_{{\mathfrak J}_B}(v)\big)\big) .\nonumber
\end{gather*}
The difference operator is given by
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}
\pagestyle{plain}
\usepackage{fancybox}
\usepackage{bm}
\begin{document}
\begin{gather}
{\mathfrak D}_{{\mathfrak J}_D}^{{\mathfrak J}_B,(1,0;AB^{-1})} T_{{\mathfrak J}_D}(z) \sim
\frac{\theta_p\big((pq)^\frac{1}{2}t^{-1}A^{\pm1}C^{\pm1}z\big)\theta_p\big((pq)^\frac{1}{2}t^{-1}B^{\pm1}D^{\pm1}z\big)}{\theta_p\big(q z^2\big)\theta_p\big(z^2\big)} T_{{\mathfrak J}_D}(qz)\nonumber\\
\hphantom{{\mathfrak D}_{{\mathfrak J}_D}^{{\mathfrak J}_B,(1,0;AB^{-1})} T_{{\mathfrak J}_D}(z) \sim}{}
 +\frac{\theta_p\big((pq)^\frac{1}{2}t^{-1}A^{\pm1}C^{\pm1}z^{-1}\big)\theta_p((pq)^\frac{1}{2}t^{-1}B^{\pm1}D^{\pm1}z^{-1})}{\theta_p\big(q z^{-2}\big)\theta_p\big(z^{-2}\big)} T_{{\mathfrak J}_D}\big(qz^{-1}\big)\nonumber\\
\hphantom{{\mathfrak D}_{{\mathfrak J}_D}^{{\mathfrak J}_B,(1,0;AB^{-1})} T_{{\mathfrak J}_D}(z) \sim}{}
+ W^{{\mathfrak J}_B}_{{\mathfrak J}_D,\big(1,0;AB^{-1}\big)}(z) T_{{\mathfrak J}_D}(z) ,
\end{gather}
where $\sim$ means equal up to an overall factor which is independent of~$z$. We have denoted
\begin{gather*}
W^{{\mathfrak J}_B}_{{\mathfrak J}_D, (1,0; AB^{-1})}(z)
\\=\frac{\theta_p\big(q^{-1}t^{-4}\big)\theta_p\big(q^{-1}t^{-4}A^2B^{-2}z^2\big)\theta_p\big((pq)^\frac{1}{2}t^{\pm1}A C^{\pm1}(qz)^{-1}\big)\theta_p\big((pq)^\frac{1}{2}t^{\pm1}B^{-1}D^{\pm1}(qz)^{-1}\big)}
{\theta_p\big(q^{-2}t^{-4}A^2B^{-2}\big)\theta_p\big(z^2\big)\theta_p\big(q^{-1}z^{-2}\big)\theta_p\big(t^{-4}z^2\big)}\\
\quad{} +\frac{\theta_p\big(q^{-1}t^{-4}\big)\theta_p\big(q^{-1}t^{-4}A^2B^{-2}z^{-2}\big)\theta_p\big((pq)^\frac{1}{2}t^{\pm1}A^{-1} C^{\pm1}z^{-1}\big)\theta_p\big((pq)^\frac{1}{2}t^{\pm1}BD^{\pm1}z^{-1}\big)}
{\theta_p\big(q^{-2}t^{-4}A^2B^{-2}\big)\theta_p\big(z^{-2}\big)\theta_p\big(q^{-1}z^{2}\big)\theta_p\big(t^{-4}z^{-2}\big)}\\
\quad{} +\frac{\theta_p\big(q^{-1}A^2B^{-2}\big)\theta_p\big((pq)^\frac{1}{2}t^{2}B D^{\pm1}\big(t^{-1}z\big)^{\pm1}\big)
\theta_p\big((pq)^\frac{1}{2}t^{2}A^{-1} C^{\pm1} \big(t^{-1} z\big)^{\pm1}\big)}
{\theta_p\big(q^{-2}t^{-4}A^2B^{-2}\big)\theta_p\big(z^2\big)\theta_p\big(t^4z^{-2}\big)} \\
\quad{}+\frac{\theta_p\big(q^{-1}A^2B^{-2}\big)\theta_p\big((pq)^\frac{1}{2}t^{2}B D^{\pm1}\big(t^{-1}z^{-1}\big)^{\pm1}\big)
\theta_p\big((pq)^\frac{1}{2}t^{2}A^{-1} C^{\pm1} \big(t^{-1} z^{-1}\big)^{\pm1}\big)}
{\theta_p\big(q^{-2}t^{-4}A^2B^{-2}\big)\theta_p\big(z^{-2}\big)\theta_p\big(t^4z^2\big)}\\
\quad{} +\frac{\theta_p\big(t^{-2}\big)\theta_p\big(q^{-1}t^{-2}A^2\big)\theta_p\big(q^{-1}A^2B^{-2}\big)\theta_p\big(q^{-1}t^{-2}B^{-2}\big) \theta_p\big(q^{-1}t^{-2}A B^{-1} C^{\pm1} D^{\pm1}\big)}{\theta_p\big(p^{-1}q^{-2}t^{-4}A^2 B^{-2}\big)\theta_p\big(q^{-2}t^{-2}A^2B^{-2}\big)}.
\end{gather*}
In Appendix we give details of the computation leading to this operator. One could consider more general residues by gluing the cap $C^{(L,M;\overline i)}_{{\mathfrak J}}(v)$ and general~$L$ and~$M$. We leave this as an exercise to the interested reader.
\section{Relation to van Diejen model}
The difference operator of the previous section is the van Diejen difference operator. Using the notations of  and the definitions of Appendix the van Diejen operator is given as
\begin{gather*}
A_D(h;z)T(z)\equiv V(h;z)T(qz)+V\big(h;z^{-1}\big)T\big(q^{-1}z\big)+V_b(h;z) ,
\end{gather*}
where
\begin{gather*}
 V(h;z) \equiv \frac{\prod\limits_{n=1}^8\theta\big((pq)^{\frac12}h_n z\big)}{\theta(z^2)\theta\big(qz^2\big)},\qquad
 V_b(h;z) \equiv \frac{\sum\limits_{k=0}^3p_k(h)[\mathcal{E}_k(\xi;z)-\mathcal{E}_k(\xi;\omega_k)]}{2\theta(\xi)\theta\big(q^{-1}\xi\big)} ,
\end{gather*}
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}
\pagestyle{plain}
\usepackage{fancybox}
\usepackage{bm}
\begin{document}
where $\omega_k$ are
\begin{gather*}
 \omega_0=1 , \qquad \omega_1=-1 , \qquad \omega_2=p^\frac12 ,\qquad \omega_3=-p^{-\frac12} .
\end{gather*}
The functions $p_k(h)$ are
\begin{alignat*}{3}
  p_0(h)\equiv \prod_n \theta(p^\frac12 h_n) , \qquad  p_1(h)\equiv \prod_n \theta\big({-}p^\frac12 h_n\big) , \\
  p_2(h)\equiv p\prod_n h_n^{-\frac12}\theta(h_n) ,\qquad  p_3(h)\equiv p\prod_n h_n^{\frac12}\theta\big({-}h_n^{-1}\big) ,
\end{alignat*}
and $\mathcal{E}_k$ is
\begin{gather*}
 \mathcal{E}_k(\xi;z)\equiv\frac{\theta\big(q^{-\frac12} \xi \omega_k^{-1} z\big)\theta\big(q^{-\frac12} \xi \omega_k z^{-1}\big)}{\theta\big(q^{-\frac12}\omega_k^{-1} z\big)\theta\big(q^{-\frac12} \omega_k z^{-1}\big)} .
\end{gather*}
The van Diejen operator and the operator () are the same up to a constant function (independent of~$z$). It's clear that $V(h;z)$ coincides with the corresponding term in \eqref{diuer} if we make the identifications
\begin{gather*}
 h_{1,2,3,4}=t^{-1}A^{\pm1}C^{\pm1} , \qquad h_{5,6,7,8}=t^{-1}B^{\pm1}D^{\pm1} .
\end{gather*}
Since $V_b(h;z)$ is elliptic in $z$ with periods~$1$ and $p$ and it is easy to check that $W^{{\mathfrak J}_B}_{{\mathfrak J}_D, (1,0; AB^{-1})}(z)$ is also elliptic with the same period, it is enough to show that the two functions have the same poles and residues to prove that they can differ only by a function independent of~$z$. In the fundamental parallelogram $V_b$ has poles at (we assume with no loss of generality that $|p|<|q|\ll |t|<1$ and the rest of the variables are on unit circle)
\begin{gather*}
 z=\pm q^{-\frac12}p , \qquad z= \pm q^{\frac12}, \qquad z=\pm p^\frac12 q^{\pm\frac12}.
\end{gather*}
In addition to such poles the operator \eqref{diuer} seems to have poles at $z=\pm t^{-2}p , \pm t^2 , 	\pm p^\frac12 t^{\pm2}$ and $z=\pm1,\pm p^\frac12$, but computation of the residue at these poles yields zero. The computation of the residue at the poles is straightforward, the result is ($h$ is either $1$ or $-1$)
\begin{gather*}
\operatorname{Res}_{z\to h q^\frac12} W^{{\mathfrak J}_B}_{{\mathfrak J}_D, (1,0; AB^{-1})}(z)=
-h(p;p)^{-2}\frac{\theta_p\big(h p^\frac{1}{2}t^{\pm1}A C^{\pm1}\big)\theta_p\big(h p^\frac{1}{2}t^{\pm1}B^{-1}D^{\pm1}\big)}
{2q^{-\frac12}\theta_p\big(q^{-1}\big)},\\
\operatorname{Res}_{z\to h q^{-\frac12}} W^{{\mathfrak J}_B}_{{\mathfrak J}_D, (1,0; AB^{-1})}(z)=
h(p;p)^{-2}\frac{\theta_p\big(hp^\frac{1}{2}t^{\pm1}A C^{\pm1}\big)\theta_p\big(h p^\frac{1}{2}t^{\pm1}B^{-1}D^{\pm1}\big)}
{2q^{\frac12}\theta_p\big(q^{-1}\big)},\\
\operatorname{Res}_{z\to h p^\frac12 q^{\frac12}} W^{{\mathfrak J}_B}_{{\mathfrak J}_D, (1,0; AB^{-1})}(z)=
-h (p;p)^{-2}\frac{A^{-2}B^{2}\theta_p\big(h t^{\pm1}A C^{\pm1}\big)\theta_p\big(h t^{\pm1}B^{-1}D^{\pm1}\big)}
{2p^{-\frac32}q^{-\frac12}\theta_p\big(q^{-1}\big)},\\
\operatorname{Res}_{z\to h p^\frac12 q^{-\frac12}} W^{{\mathfrak J}_B}_{{\mathfrak J}_D, (1,0; AB^{-1})}(z)=
h (p;p)^{-2}\frac{A^{-2}B^{2}\theta_p\big(h t^{\pm1}A C^{\pm1}\big)\theta_p\big(h t^{\pm1}B^{-1}D^{\pm1}\big)}
{2p^{-\frac32}q^{\frac12}\theta_p\big(q^{-1}\big)}.
\end{gather*}
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}
\pagestyle{plain}
\usepackage{fancybox}
\usepackage{bm}
\begin{document}
Using the ellipticity of $V_b$ and some basic properties of the theta function this is exactly what we get from computing the residues of $V_b$. Thus, we can conclude that the operators are the same up to a constant function. The van Diejen operator does not depend on the type of residue we took, that is what type of defect was introduced, but only on the color of puncture through the choice of the eight parameters. The choice of the defect enters through the additive constant by which the operator derived from the index differs from the van Diejen operator. In particular, operators introducing different defects commute with each other as they differ by a constant. We can compute operators which correspond to residues with $q$ exchanged by $p$, these will correspond to defects wrapping the other equator of ${\mathbb S}^3$. All the operators should commute and indeed they do as this is true for the van Diejen operators. Our derivation of the operator had only five parameters but the relation discussed here suggests generalization to eight parameters, again up to the additive constant function.
\section{Koornwinder limit}
We consider the following limit of the parameters. Define
\begin{gather}
p^{\frac12} \widetilde A =A C , \qquad p^{\frac12} \widetilde C= B D \qquad \widetilde B=A/C ,\qquad \widetilde D=B/D .
\end{gather}
We take $p$ to zero keeping the new variables fixed. In the limit the difference operator is
\begin{gather*}
{\mathfrak D}_{{\mathfrak J}_D}^{{\mathfrak J}_B,\big(1,0;(\widetilde A \widetilde B/ \widetilde C \widetilde D)^{\frac12}\big)} T_{{\mathfrak J}_D}(u)\\
{} \sim \frac{\big(1-q^{-\frac12}t \widetilde A^{-1}u^{-1}\big)\big(1-q^{-\frac12}t \widetilde C^{-1}u^{-1}\big)\big(1-q^{\frac12} t^{-1} \widetilde A^{-1} u\big)\big(1-q^{\frac12} t^{-1} \widetilde C^{-1} u\big)}{\big(1-u^2\big)\big(1-q u^2\big)} T_{{\mathfrak J}_D}(q u) \\
 \quad{}+\frac{\big(1-q^{-\frac12}t \widetilde A^{-1}u\big)\big(1-q^{-\frac12}t \widetilde C^{-1}u\big)\big(1-q^{\frac12} t^{-1} \widetilde A^{-1} u^{-1}\big)\big(1-q^{\frac12} t^{-1} \widetilde C^{-1} u^{-1}\big)}{\big(1-u^{-2}\big)\big(1-q u^{-2}\big)} T_{{\mathfrak J}_D}(q u^{-1}) \\
\quad{} +W^{{\mathfrak J}_B}_{{\mathfrak J}_D,\big(1,0;(\widetilde A \widetilde B/\widetilde C\widetilde D )^{\frac12}\big)} T_{{\mathfrak J}_D}(u).\end{gather*}
 We note that conjugating the operator to be
\begin{gather*}
{\mathfrak O}_{{\mathfrak J}_D}^{{\mathfrak J}_B,\big(1,0;(\widetilde A \widetilde B / \widetilde C \widetilde D)^{\frac12}\big)}=
\Gamma_e\big(q^{\frac12}t {\widetilde A}^{-1}u^{\pm1}\big)^{-1} \Gamma_e\big(q^{\frac12}t {\widetilde C}^{-1}u^{\pm1}\big)^{-1}\\
 \hphantom{{\mathfrak O}_{{\mathfrak J}_D}^{{\mathfrak J}_B,\big(1,0;(\widetilde A \widetilde B / \widetilde C \widetilde D)^{\frac12}\big)}= }{}
\times {\mathfrak D}_{{\mathfrak J}_D}^{{\mathfrak J}_B,\big(1,0;(\widetilde A \widetilde B / \widetilde D
\widetilde C)^{\frac12}\big)} \Gamma_e\big(q^{\frac12}t {\widetilde A}^{-1}u^{\pm1}\big) \Gamma_e\big(q^{\frac12}t {\widetilde C}^{-1}u^{\pm1}\big) . \end{gather*}
We can write
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}
\pagestyle{plain}
\usepackage{fancybox}
\usepackage{bm}
\begin{document}
We can write
\begin{gather*}
{\mathfrak O}_{{\mathfrak J}_D}^{{\mathfrak J}_B,\big(1,0;(\widetilde A \widetilde B/ \widetilde D \widetilde C)^{\frac12}\big)} {\mathfrak F}(u)=
\frac{\prod\limits_{l=1}^4(1- a_l u)}{\big(1-u^2\big)\big(1-q u^2\big)}({\mathfrak F}(q u)-{\mathfrak F}(u))\\
\qquad{}
+\frac{\prod\limits_{j=1}^4\big(1- a_j u^{-1}\big)}{\big(1-u^{-2}\big)\big(1-q u^{-2}\big)}\big({\mathfrak F}\big(q u^{-1}\big)-{\mathfrak F}(u)\big)
 +E_{{\mathfrak J}_D}^{{\mathfrak J}_B,\big(1,0;(\widetilde A \widetilde B / \widetilde D \widetilde C)^{\frac12}\big)} {\mathfrak F}(u) ,\\
a_1=q^{\frac12}t \widetilde A^{-1} ,\qquad
a_2=q^{\frac12}t \widetilde C^{-1} ,\qquad
a_3=q^{\frac12}t^{-1} \widetilde A^{-1} ,\qquad
a_4=q^{\frac12}t^{-1} \widetilde C^{-1}.
\end{gather*} The first two terms define the rank one Koornwinder operator  and we have an additional constant term. The eigenfunctions are the Askey--Wilson polynomials. In general these polynomials have four independent parameters $a_l$ but in our case they are restricted to $a_1 a_4 =a_2 a_3$. The constant term is
\begin{gather*}
E_{{\mathfrak J}_D}^{{\mathfrak J}_B,(1,0;\big(\widetilde A \widetilde B / \widetilde D
\widetilde C)^{\frac12}\big)}=\left[-\frac{q^3t^2}{ (\widetilde A \widetilde C)^2}-q^2t^2\left(1-\frac{\widetilde B}{\widetilde C\widetilde D\widetilde A}-\frac1{\widetilde C^2}-\frac{1+t^{-2}}{\widetilde A\widetilde C}\right)\right. \\
\left.\hphantom{E_{{\mathfrak J}_D}^{{\mathfrak J}_B,(1,0;\big(\widetilde A \widetilde B / \widetilde D \widetilde C)^{\frac12}\big)}=}{}
 - q\left(-\frac{\widetilde B}{\widetilde C^3\widetilde A\widetilde D}+\frac{\widetilde B}{\widetilde C^2\widetilde D}+\frac{\widetilde B}{\widetilde A\widetilde D\widetilde C}+\frac1{\widetilde C^2}+\frac{\widetilde B t^2}{\widetilde C^2 \widetilde D}\right)+\frac{\widetilde B\widetilde A}{\widetilde D \widetilde C}\right].
\end{gather*}
Let us take the limit of the three punctured sphere. We give details of the computation in Appendix with the final result given here (taking $\lim\limits_{p\to 0}$ of the right-hand side as in~\eqref{limpfuj})
\begin{gather}
 T_{{\mathfrak J}_B,{\mathfrak J}_C,{\mathfrak J}_D}(w,u,v)= \frac1{\big(q p\frac1{ABC D}t^{-2};q\big)} \left(q p t^2 \frac1{A BC D};q\right)^2\left(q p \frac1{B A C D};q\right) \\
{} \times \frac1{\big(\sqrt{ q p} \frac{t}{AC} v^{\pm1},\sqrt{q p}\frac{t}{D B}v^{\pm1};q\big)}
\frac1{\big(\sqrt{q p} \frac{t}{AB}w^{\pm1},\sqrt{ q p} \frac{t}{D C} w^{\pm1};q\big)}\frac1{
\big(\sqrt{q p } \frac{t}{B C} u^{\pm1},\sqrt {q p } \frac{ t}{ A D } u^{\pm1};q\big)} . \nonumber
\end{gather} The index factorizes. In particular on general grounds  we expect the index of the three punctured sphere to be
\begin{gather*}
\frac1{\big(\sqrt{ q p} \frac{t}{AC} v^{\pm1},\sqrt{q p}\frac{t}{D B}v^{\pm1};q\big)}
\frac1{\big(\sqrt{q p} \frac{t}{AB}w^{\pm1},\sqrt{ q p} \frac{t}{D C} w^{\pm1};q\big)}\\
\qquad{}\times \frac1{\big(\sqrt{q p } \frac{t}{B C} u^{\pm1},\sqrt {q p }\frac{ t}{ A D } u^{\pm1};q\big)}
 \sum_{\lambda} C_\lambda \psi_\lambda(u)\psi_\lambda(w)\psi_\lambda(v) ,
\end{gather*} where the sum is over all the eigenvalues of the Koornwinder operator and $\psi_\lambda(z)$ are Askey--Wilson polynomials. What we have shown above is that
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}
\pagestyle{plain}
\usepackage{fancybox}
\usepackage{bm}
\begin{document}
in the limit the three punctured sphere we have defined has all~$C_\lambda$ vanishing but the one corresponding to the constant polynomial. The Koornwinder polynomials have higher rank generalizations which should be relevant for higher rank E string theories. In those cases we do not know the three punctured spheres and the relation to Koornwinder polynomials can provide a useful tool to study the indices of these models. The limit we considered does not have a special physical meaning a priori, however the fact that the expressions become simple and the fact that one might generalize the discussion to the higher rank case, make the limit of potential interest.
\appendix
\section{Index definitions}
We compute the supersymmetric index  using the standard definitions of . The index of chiral field charged under flavor ${\rm U}(1)$ symmetry with charge $S$ and having R-charge ${\mathfrak R}$ is
\begin{gather*}
 \Gamma_e\big((q p)^{\frac{ \mathfrak R}2} u^S\big) .
\end{gather*}
The parameter $u$ is fugacity for the flavor symmetry. We define here
\begin{gather*} \Gamma_e(u) = \prod_{i,j=0}^\infty \frac{1-\frac1u q^{i+1}p^{j+1}}{1- u p^i q^j} .
\end{gather*} We will use the following definitions
\begin{gather*}
 (s;q)= \prod_{i=1}^\infty \big(1-s q^{i-1}\big) ,\qquad \theta_r(u)=\prod_{j=1}^\infty \big(1- u r^{j-1}\big)\big(1-r^j/u\big) .
\end{gather*} Finally we use the condensed conventions
\begin{gather*}
f\big(y^{\pm1}\big) =f(1/y) f(y) ,	\qquad (s_1,\dots,s_k;q) =(s_1;q)\cdots(s_k;q) .
\end{gather*}
Contour integrals in the paper are around the unit circle unless we state otherwise.
\section{Computation of the sphere with two punctures}
We give here the derivation of equation. The computation involves calculating several contour integrals over products of elliptic gamma functions
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}
\pagestyle{plain}
\usepackage{fancybox}
\usepackage{bm}
\begin{document}
 and taking
\begin{gather*}
C^{(0,0;AB^{-1})}_{{\mathfrak J}_B}(w)\times_w T_{{\mathfrak J}_B,{\mathfrak J}_C,{\mathfrak J}_D}(w,u,v)
\\
=(q;q)(p;p)\oint\frac{{\rm d}w}{4\pi i w} \frac{\prod\limits_{j=1}^8\Gamma_e\big((q p)^{\frac12 }\frac1t a_j^{-1} w^{\pm1}\big)}{\Gamma\big(w^{\pm2}\big)} C^{(0,0;AB^{-1})}_{{\mathfrak J}_B}(w)T_{{\mathfrak J}_B,{\mathfrak J}_C,{\mathfrak J}_D}(w,u,v)
\\
=(q;q)^4(p;p)^4\!\oint\!\frac{{\rm d}w}{4\pi i w} \frac{\prod\limits_{j=1}^8\Gamma_e\big((q p)^{\frac12 }\frac1t a_j^{-1} w^{\pm1}\big)}{\Gamma\big(w^{\pm2}\big)}
\Gamma_e\big(pqt^4\big)\prod_{j\neq i}\Gamma_e\left(\frac{pqt^2}{a_ia_j}\right)0
\prod_{j=1}^8\Gamma_e\big((pq)^{\frac{1}{2}}ta_jw^{\pm1}\big)\\
\quad{}\times\Gamma_e\left(\frac{(pq)^{\frac{1}{2}}w^{\pm1}}{ta_i}\right)\Gamma_e\left(\frac{a_iw^{\pm1}}{(pq)^{\frac{1}{2}}t^3}\right)
 \Gamma_e\big((q p)^{\frac12} t\big(B^{-1}A\big)^{\pm1} w^{\pm1}\big)\Gamma_e\left(\frac{q p}{t^2}\right) \\
\quad{}\times\oint \frac{{\rm d}y}{4\pi i y} \frac{\Gamma_e\big(\frac{(p q)^{\frac12}}{t^2}\big(A B^{-1}\big)^{\pm1}y^{\pm1}\big)}{\Gamma_e(y^{\pm2})}
\Gamma_e\big(t y^{\pm1} w^{\pm1}\big)\oint\frac{{\rm d}w_1}{4\pi i w_1}\oint \frac{{\rm d}w_2}{4\pi i w_2} \frac{\Gamma_e\big(\frac{(p q)^{\frac12}}{t^2}w_1^{\pm1}w_2^{\pm1}\big)}{\Gamma_e\big(w_2^{\pm2}\big)\Gamma_e\big(w_1^{\pm2}\big)} \\
\quad{}\times\Gamma_e\big( (q p)^{\frac14}t A^{\frac12}B^{-\frac12} y^{\frac12} w_1^{\pm1}u^{\pm1}\big)
\Gamma_e\big((qp)^{\frac14} A^{\frac12} B^{\frac12} y^{-\frac12} w_1^{\pm1}D^{\pm1}\big)\\
\quad{}\times \Gamma_e\big((q p)^{\frac14} t A^{-\frac12} B^{\frac12} y^{-\frac12} w_2^{\pm1} u^{\pm1}\big)
\Gamma_e \big((q p)^{\frac14} A^{-\frac12} B^{-\frac12} y^{\frac12} D^{\pm1}w_2^{\pm1}\big)\\
\quad{}\times
\Gamma_e\big((q p)^{\frac14} t A^{-\frac12} B^\frac12 y^\frac12 w_1^{\pm1} v^{\pm1}\big)\Gamma_e\big( ( q p)^{\frac14} A^{-\frac12} B^{-\frac12} y^{-\frac12} C^{\pm1} w_1^{\pm1}\big) \\
\quad{} \times\Gamma_e\big( ( q p )^{\frac14} t A^{\frac12} B^{-\frac12} y^{-\frac12} w_2^{\pm1} v^{\pm1}\big)\Gamma_e\big( ( q p )^{\frac14} A^{\frac12} B^\frac12 y^\frac12 w_2^{\pm1} C^{\pm1}\big) .
\end{gather*}
Plugging in the values of $a_j$ from where $a_i=AB^{-1}$ and using the identity $\Gamma_e\big(\frac{pq}{z}\big)\Gamma_e(z)=1$ we get
\begin{gather*}
(q;q)^4(p;p)^4\oint\frac{{\rm d}w}{4\pi i w} \frac{1}{\Gamma\big(w^{\pm2}\big)}
\Gamma_e\big(pqt^4\big)\Gamma_e\big(pqt^2\big)\Gamma_e\big(pqt^2B^2\big)\Gamma_e\big(pqt^2A^{-2}\big)\\
\quad{} \times\Gamma_e\big(pqt^2A^{-1}BC^{\pm1}D^{\pm1}\big) \Gamma_e\left(\frac{AB^{-1}w^{\pm1}}{(pq)^{\frac{1}{2}}t^3}\right)
 \Gamma_e\big((q p)^{\frac12} tA^{-1}B w^{\pm1}\big)\Gamma_e\left(\frac{q p}{t^2}\right)\\
 \quad{}\times \oint \frac{{\rm d}y}{4\pi i y} \frac{\Gamma_e\big(\frac{(p q)^{\frac12}}{t^2}\big(A B^{-1}\big)^{\pm1}y^{\pm1}\big)}{\Gamma_e\big(y^{\pm2}\big)}\Gamma_e\big(t y^{\pm1} w^{\pm1}\big)\\
\quad{} \times\oint\frac{{\rm d}w_1}{4\pi i w_1}\oint \frac{{\rm d}w_2}{4\pi i w_2} \frac{\Gamma_e\big(\frac{(p q)^{\frac12}}{t^2}w_1^{\pm1}w_2^{\pm1}\big)}{\Gamma_e\big(w_2^{\pm2}\big)\Gamma_e\big(w_1^{\pm2}\big)} \Gamma_e\big( (q p)^{\frac14}t A^{\frac12}B^{-\frac12} y^{\frac12} w_1^{\pm1}u^{\pm1}\big)\\
\quad{} \times \Gamma_e\big((qp)^{\frac14} A^{\frac12} B^{\frac12} y^{-\frac12} w_1^{\pm1}D^{\pm1}\big)\Gamma_e\big((q p)^{\frac14} t A^{-\frac12} B^{\frac12} y^{-\frac12} w_2^{\pm1} u^{\pm1}\big) \\
\quad{} \times \Gamma_e \big((q p)^{\frac14} A^{-\frac12} B^{-\frac12} y^{\frac12} D^{\pm1}w_2^{\pm1}\big)
 \Gamma_e\big((q p)^{\frac14} t A^{-\frac12} B^\frac12 y^\frac12 w_1^{\pm1} v^{\pm1}\big)\\
\quad{} \times \Gamma_e\big( ( q p)^{\frac14} A^{-\frac12} B^{-\frac12} y^{-\frac12} C^{\pm1} w_1^{\pm1}\big) \Gamma_e\big( ( q p )^{\frac14} t A^{\frac12} B^{-\frac12} y^{-\frac12} w_2^{\pm1} v^{\pm1}\big) \\
\quad{} \times \Gamma_e\big( ( q p )^{\frac14} A^{\frac12} B^\frac12 y^\frac12 w_2^{\pm1} C^{\pm1}\big) .
\end{gather*}
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}
\pagestyle{plain}
\usepackage{fancybox}
\usepackage{bm}
\begin{document}
We can perform the integral over $w$ using the inversion formula which sets $y=\frac{AB^{-1}}{(pq)^\frac12t^2}$, and we get
\begin{gather*}
(q;q)^2(p;p)^2\Gamma_e\big(pqt^2B^2\big)\Gamma_e\big(pqt^2A^{-2}\big)\Gamma_e\big(pqt^2A^{-1}BC^{\pm1}D^{\pm1}\big)
\Gamma_e(pq)\Gamma_e\big(t^{-4}A^2B^{-2}\big)\\
\quad{}\times \Gamma_e\big(pqA^{-2}B^2\big)
\oint\frac{{\rm d}w_1}{4\pi i w_1}\oint \frac{{\rm d}w_2}{4\pi i w_2} \frac{\Gamma_e\big(\frac{(p q)^{\frac12}}{t^2}w_1^{\pm1}w_2^{\pm1}\big)}{\Gamma_e\big(w_2^{\pm2}\big)\Gamma_e\big(w_1^{\pm2}\big)} \Gamma_e\big( AB^{-1} u^{\pm1} w_1^{\pm1}\big)\\
\quad {} \times \Gamma_e\big((qp)^{\frac12}t BD^{\pm1} w_1^{\pm1}\big)\Gamma_e\big((q p)^{\frac12} t^2 A^{-1} B u^{\pm1} w_2^{\pm1}\big) \Gamma_e \big(t^{-1} B^{-1} D^{\pm1}w_2^{\pm1}\big) \Gamma_e\big( v^{\pm1} w_1^{\pm1}\big)\\
\quad{} \times\Gamma_e\big((q p)^{\frac12}t A^{-1} C^{\pm1} w_1^{\pm1}\big) \Gamma_e\big( (q p)^{\frac12} t^2 v^{\pm1} w_2^{\pm1}\big) \Gamma_e\big( t^{-1} A C^{\pm1} w_2^{\pm1}\big) .
\end{gather*}
$\Gamma_e(pq)$ is zero but the integral over $w_1$ is pinched at $w_1=v^{\pm1}$ due to the term $\Gamma_e(v^{\pm1}w_1^{\pm1})$ such that the multiplication is finite and we get
\begin{gather*}
(q;q)(p;p) \Gamma_e\big(pqt^2B^2\big)\Gamma_e\big(pqt^2A^{-2}\big)\Gamma_e\big(pqt^2A^{-1}BC^{\pm1}D^{\pm1}\big)
\Gamma_e\big(t^{-4}A^2B^{-2}\big)\Gamma_e\big(pqA^{-2}B^2\big)\\
\quad{} \times\Gamma_e\big( AB^{-1} u^{\pm1} v^{\pm1}\big)\Gamma_e\big((qp)^{\frac12}t BD^{\pm1} v^{\pm1}\big)
\Gamma_e\big((q p)^{\frac12}t A^{-1} C^{\pm1} v^{\pm1}\big)\\
\quad{} \times\oint \frac{{\rm d}w_2}{4\pi i w_2} \frac{1}{\Gamma_e\big(w_2^{\pm2}\big)}
\Gamma_e\big((q p)^{\frac12} t^2 A^{-1} B u^{\pm1} w_2^{\pm1}\big) \Gamma_e \big(t^{-1} B^{-1} D^{\pm1}w_2^{\pm1}\big)
\Gamma_e\big( t^{-1} A C^{\pm1} w_2^{\pm1}\big) .
\end{gather*}
Integral over $w_2$ can be evaluated using the elliptic beta integral formula, and the final result is
\begin{gather*}
\Gamma_e\big(pqA^{-2}B^2\big) \Gamma_e\big( AB^{-1} u^{\pm1} v^{\pm1}\big)\Gamma_e\big((qp)^{\frac12}t BD^{\pm1} v^{\pm1}\big)
\Gamma_e\big((q p)^{\frac12}t A^{-1} C^{\pm1} v^{\pm1}\big)\\
\quad{}\times \Gamma_e\big((pq)^\frac12 t B C^{\pm1}u^{\pm1}\big) \Gamma_e\big((pq)^\frac12 t A^{-1}D^{\pm1}u^{\pm1}\big) .
\end{gather*}
We glue this to another three punctured sphere closed with $a_i=A^{-1}B$ and the claim is that gluing this to a given model we get the same model. Indeed we have
\begin{gather*}
 T_{{\mathfrak J}_C}(u)\times_u \big(\big(T_{{\mathfrak J}_B, {\mathfrak J}_C,{\mathfrak J}_D}(w,u,v)\times_w C^{(0,0;AB^{-1})}_{{\mathfrak J}_B}(w)\big)\\
 \quad{} \times_v\big(T_{{\mathfrak J}_B, {\mathfrak J}_C,{\mathfrak J}_D}(h,z,v)\times_h C^{(0,0;A^{-1}B)}_{{\mathfrak J}_B}(h)\big)\big)\\
=(q;q)^2(p;p)^2\Gamma_e\big(pq\big(A^{-2}B^2\big)^{\pm1}\big)\Gamma_e\big((pq)^\frac12 t B^{-1} C^{\pm1}z^{\pm1}\big)
\Gamma_e\big((pq)^\frac12 t AD^{\pm1}z^{\pm1}\big)\\
\quad{} \times\oint\frac{{\rm d}u}{4\pi i u} \frac{\Gamma_e\big((q p)^{\frac12 }t^{-1} A^{\pm1} D^{\pm1}u^{\pm1}\big)
\Gamma_e\big((q p)^{\frac12 }t^{-1} B^{\pm1} C^{\pm1}u^{\pm1}\big)}{\Gamma\big(u^{\pm2}\big)}\\
\quad{} \times\Gamma_e\big((pq)^\frac12 t B C^{\pm1}u^{\pm1}\big)
\Gamma_e\big((pq)^\frac12 t A^{-1}D^{\pm1}u^{\pm1}\big)T_{{\mathfrak J}_C}(u)\\
\quad{} \times\oint\frac{{\rm d}v}{4\pi i v} \frac{\Gamma_e\big((q p)^{\frac12 }t^{-1} A^{\pm1} C^{\pm1}v^{\pm1}\big)
\Gamma_e\big((q p)^{\frac12 }t^{-1} B^{\pm1} D^{\pm1}v^{\pm1}\big)}{\Gamma\big(v^{\pm2}\big)}\\
\quad{} \times\Gamma_e\big( AB^{-1} u^{\pm1} v^{\pm1}\big)\Gamma_e\big((qp)^{\frac12}t BD^{\pm1} v^{\pm1}\big)
\Gamma_e\big((q p)^{\frac12}t A^{-1} C^{\pm1} v^{\pm1}\big)\\
\quad{} \times\Gamma_e\big( A^{-1}B z^{\pm1} v^{\pm1}\big)\Gamma_e\big((qp)^{\frac12}t B^{-1}D^{\pm1} v^{\pm1}\big)\Gamma_e\big((q p)^{\frac12}t A C^{\pm1} v^{\pm1}\big) .
\end{gather*}
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}
\pagestyle{plain}
\usepackage{fancybox}
\usepackage{bm}
\begin{document}
Terms cancel in the second integral and we get
\begin{gather*}
=(q;q)^2(p;p)^2\Gamma_e\big(pq\big(A^{-2}B^2\big)^{\pm1}\big)\Gamma_e\big((pq)^\frac12 t B^{-1} C^{\pm1}z^{\pm1}\big)
\Gamma_e\big((pq)^\frac12 t AD^{\pm1}z^{\pm1}\big)\\
\quad{}\times\oint\frac{{\rm d}u}{4\pi i u} \frac{\Gamma_e\big((q p)^{\frac12 }t^{-1} A^{\pm1} D^{\pm1}u^{\pm1}\big)
\Gamma_e\big((q p)^{\frac12 }t^{-1} B^{\pm1} C^{\pm1}u^{\pm1}\big)}{\Gamma\big(u^{\pm2}\big)}\\
\quad{}\times\Gamma_e\big((pq)^\frac12 t B C^{\pm1}u^{\pm1}\big)\Gamma_e\big((pq)^\frac12 t A^{-1}D^{\pm1}u^{\pm1}\big)T_{{\mathfrak J}_C}(u)\\
\quad{}\times\oint\frac{{\rm d}v}{4\pi i v} \frac{1}{\Gamma\big(v^{\pm2}\big)}
\Gamma_e\big( AB^{-1} u^{\pm1} v^{\pm1}\big) \Gamma_e\big( A^{-1}B z^{\pm1} v^{\pm1}\big) .
\end{gather*}
The integrals can be evaluated using the inversion formula which sets $u=z$:
\begin{gather*}
=\Gamma_e\big((pq)^\frac12 t B^{-1} C^{\pm1}z^{\pm1}\big)
\Gamma_e\big((pq)^\frac12 t AD^{\pm1}z^{\pm1}\big)\Gamma_e\big((q p)^{\frac12 }t^{-1} A^{\pm1} D^{\pm1}z^{\pm1}\big)\\
\quad{} \times\Gamma_e\big((q p)^{\frac12 }t^{-1} B^{\pm1} C^{\pm1}z^{\pm1}\big)\Gamma_e\big((pq)^\frac12 t B C^{\pm1}z^{\pm1}\big)
\Gamma_e\big((pq)^\frac12 t A^{-1}D^{\pm1}z^{\pm1}\big)T_{{\mathfrak J}_C}(z) .
\end{gather*}
We see that all terms cancel so we get
\begin{gather*}
 T_{{\mathfrak J}_C}(u)\times_u \big(\big(T_{{\mathfrak J}_B, {\mathfrak J}_C,{\mathfrak J}_D}(w,u,v)\times_w C^{(0,0;AB^{-1})}_{{\mathfrak J}_B}(w)\big)\\
\qquad{} \times_v\big(T_{{\mathfrak J}_B, {\mathfrak J}_C,{\mathfrak J}_D}(h,z,v)\times_h C^{(0,0;A^{-1}B)}_{{\mathfrak J}_B}(h)\big)\big)= T_{{\mathfrak J}_C}(z).
\end{gather*}
\section{Computation of the sphere with two punctures and a defect}
Here we compute the difference operator. The computation is a small twist on the one of the previous section, however it is less straightforward and thus  for which we perform another duality operation. After the duality the $p$ vanishing limit is well defined for all fields. Let us write the fields surviving after scaling
\begin{gather*}
(p q)^{\frac16}A^{\frac13}b^{-\frac23} t^{\frac13}a^{-\frac23} z_2^{-\frac13} z_1^{\pm1}w_2^j , \ (p q)^{\frac16}A^{-\frac23}b^{\frac13} t^{\frac13}a^{\frac13} z_2^{-\frac13} v_1^{\pm1} w_2^j , \\
(q p)t^{-2} , \ (q p)^{\frac13} A^{-\frac13} t^{-\frac43} b ^{-\frac13} a^{-\frac13} z_2^{\frac13} v_2^{-1} \big(w^j_2\big)^{-1} , \
 (q p)^{\frac13} A^{-\frac13} t^{\frac23} b ^{-\frac13} a^{-\frac13} z_2^{\frac13} v_2^{-1} \big(w^j_2\big)^{-1} , \
a b^{-1} t w_1^{\pm1} ,\\
( q p)^{ \frac1 2 }a b^{-1} v_2^ {-1} z_2^{-1} , \ ( q p)^{\frac12} b^{-1} t^{-1} A^{-1} w_1^{\pm1} a^{-1} ,\\
(q p)^{\frac12} a^{-1} b z_2 v_2 , \ (q p)^{\frac12} z_2^{-1} t^{-1} w_1^{\pm1} v_2^{-1} , \
b t a^{-1} w_1^{\pm1} , \ (q p)^{\frac12} t v_2 A v_1^{\pm1} , \ (q p)^{\frac12} a b t v_2 z_1^{\pm1} ,
\end{gather*}
We would like to thank Hee-Cheol Kim, S.~Ruijsenaars, Cumrun Vafa, and Gabi Zafrir for relevant discussions. The research was supported by Israel Science Foundation under grant no. 1696/15 and by I-CORE Program of the Planning and Budgeting Committee.
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}
\pagestyle{plain}
\usepackage{fancybox}
\usepackage{bm}
\begin{document}
we discuss it in detail. We compute
\begin{gather*}
T_{{\mathfrak J}_B, {\mathfrak J}_C,{\mathfrak J}_D}(w,u,v)\times_w C^{(1,0;AB^{-1})}_{{\mathfrak J}_B}(w)\\
=(q;q)(p;p)\oint\frac{{\rm d}w}{4\pi i w} \frac{\prod\limits_{j=1}^8\Gamma_e\big((q p)^{\frac12 }\frac1t a_j^{-1} w^{\pm1}\big)}{\Gamma\big(w^{\pm2}\big)} C^{(1,0;AB^{-1})}_{{\mathfrak J}_B}(w)T_{{\mathfrak J}_B,{\mathfrak J}_C,{\mathfrak J}_D}(w,u,v) \\
\sim\oint\frac{{\rm d}w}{4\pi i w} \frac{\prod\limits_{j=1}^8\Gamma_e\big((q p)^{\frac12 }\frac1t a_j^{-1} w^{\pm1}\big)}{\Gamma\big(w^{\pm2}\big)}
\prod_{j=1}^8\Gamma_e\big((pq)^{\frac{1}{2}}ta_jw^{\pm1}\big)
\Gamma_e\left(\frac{(pq)^\frac12 q w^{\pm1}}{tAB^{-1}}\right)\\
\quad{} \times\Gamma_e\left(\frac{AB^{-1}w^{\pm1}}{(pq)^{\frac{1}{2}} q t^3}\right)
 \Gamma_e\big((q p)^{\frac12} t\big(B^{-1}A\big)^{\pm1} w^{\pm1}\big)\Gamma_e\left(\frac{q p}{t^2}\right)
\oint \frac{{\rm d}y}{4\pi i y} \frac{\Gamma_e\big(\frac{(p q)^{\frac12}}{t^2}\big(A B^{-1}\big)^{\pm1}y^{\pm1}\big)}{\Gamma_e\big(y^{\pm2}\big)}\\
\quad{}\times\Gamma_e\big(t y^{\pm1} w^{\pm1}\big)\oint\frac{{\rm d}w_1}{4\pi i w_1}\oint \frac{{\rm d}w_2}{4\pi i w_2} \frac{\Gamma_e\big(\frac{(p q)^{\frac12}}{t^2}w_1^{\pm1}w_2^{\pm1}\big)}{\Gamma_e\big(w_2^{\pm2}\big)\Gamma_e\big(w_1^{\pm2}\big)} \Gamma_e\big( (q p)^{\frac14}t A^{\frac12}B^{-\frac12}y^{\frac12} w_1^{\pm1}u^{\pm1}\big)\\
\quad{}\times\Gamma_e\big((qp)^{\frac14} A^{\frac12} B^{\frac12}y^{-\frac12} w_1^{\pm1}D^{\pm1}\big)\Gamma_e\big((q p)^{\frac14} t A^{-\frac12} B^{\frac12} y^{-\frac12} w_2^{\pm1} u^{\pm1}\big)\\
\quad{} \times \Gamma_e \big((q p)^{\frac14} A^{-\frac12} B^{-\frac12} y^{\frac12} D^{\pm1}w_2^{\pm1}\big)\Gamma_e\big((q p)^{\frac14} t A^{-\frac12} B^\frac12 y^\frac12 w_1^{\pm1} v^{\pm1}\big)\\
\quad{} \times \Gamma_e\big( ( q p)^{\frac14} A^{-\frac12} B^{-\frac12} y^{-\frac12} C^{\pm1} w_1^{\pm1}\big) \Gamma_e\big( ( q p )^{\frac14} t A^{\frac12} B^{-\frac12} y^{-\frac12} w_2^{\pm1} v^{\pm1}\big)\\
\quad{}\times\Gamma_e\big( ( q p )^{\frac14} A^{\frac12} B^\frac12 y^\frac12 w_2^{\pm1} C^{\pm1}\big),
\end{gather*}
where $\sim$ means equality up to overall factors independent of $w$, $u$, $v$. Using the identity $\Gamma_e\big(\frac{pq}{z}\big)\Gamma_e(z)=1$ and the elliptic beta integral formula we evaluate the integral over~$w$ and up to overall factors we get
\begin{gather}
\Gamma_e\big(pq^2\big)\oint \frac{{\rm d}y}{4\pi i y} \frac{\Gamma_e\big((pq)^\frac12 q A^{-1} B y^{\pm1}\big)\Gamma_e\big((pq)^{-\frac12}q^{-1}t^{-2}AB^{-1}y^{\pm1}\big)}{\Gamma_e\big(y^{\pm2}\big)}\oint\frac{{\rm d}w_1}{4\pi i w_1}\oint \frac{{\rm d}w_2}{4\pi i w_2}\nonumber\\
\quad{} \times \frac{\Gamma_e\big(\frac{(p q)^{\frac12}}{t^2}w_1^{\pm1}w_2^{\pm1}\big)}{\Gamma_e\big(w_2^{\pm2}\big)\Gamma_e\big(w_1^{\pm2}\big)}\Gamma_e\big( (q p)^{\frac14}t A^{\frac12}B^{-\frac12} y^{\frac12} w_1^{\pm1}u^{\pm1}\big)\Gamma_e\big((qp)^{\frac14} A^{\frac12} B^{\frac12} y^{-\frac12} w_1^{\pm1}D^{\pm1}\big)
\nonumber\\
 \quad{} \times \Gamma_e\big((q p)^{\frac14} t A^{-\frac12} B^{\frac12} y^{-\frac12} w_2^{\pm1} u^{\pm1}\big) \Gamma_e \big((q p)^{\frac14} A^{-\frac12} B^{-\frac12} y^{\frac12} D^{\pm1}w_2^{\pm1}\big)\nonumber\\
 \quad{}\times \Gamma_e\big((q p)^{\frac14} t A^{-\frac12} B^\frac12 y^\frac12 w_1^{\pm1} v^{\pm1}\big)
 \Gamma_e\big( ( q p)^{\frac14} A^{-\frac12} B^{-\frac12} y^{-\frac12} C^{\pm1} w_1^{\pm1}\big)\nonumber\\
\quad{}\times \Gamma_e\big( ( q p )^{\frac14} t A^{\frac12} B^{-\frac12} y^{-\frac12} w_2^{\pm1} v^{\pm1}\big) \Gamma_e\big( ( q p )^{\frac14} A^{\frac12} B^\frac12 y^\frac12 w_2^{\pm1} C^{\pm1}\big) .
\end{gather}
We got a zero multiplying the integral, but we will see next that some of the integrals are pinched giving finite result. We start by evaluating the integral over $y$ using the residue theorem and we get that the integral over $w_1$ is pinched due to $\Gamma_e\big((q p)^{\frac14} t A^{-\frac12} B^\frac12 y^\frac12 w_1^{\pm1} v^{\pm1}\big)$ term for the poles
\end{document}


\documentclass[a4paper,12pt]{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{wrapfig}
\pagestyle{plain}
\usepackage{fancybox}
\usepackage{bm}
\begin{document}
 $y_1=(pq)^{-\frac12}t^{-2}AB^{-1}$ and $y_2=(pq)^{-\frac12}q^{-1}t^{-2}AB^{-1}$. For $y_1$ the integral over $w_1$ is pinched at $w_1=v^{\pm1}$ and we proceed exactly as in appendix B to get the same result up to some overall factors
\begin{gather}
\frac12 \frac{\Gamma_e\big(qt^{-2}\big)\Gamma_e\big(pq^2t^2A^{-2}B^2\big)\Gamma_e\big(t^{-2}B^{-2}\big)\Gamma_e\big(t^{-2}A^2\big) \Gamma_e\big((pq)^{-1}q^{-1}t^{-4}A^2 B^{-2}\big)} {\Gamma_e\big((pq)^{-1}t^{-4}A^2 B^{-2}\big)}\nonumber\\
\quad{}\times\Gamma_e\big(t^{-2}AB^{-1}C^{\pm1}D^{\pm1}\big)
\Gamma_e\big( AB^{-1} u^{\pm1} v^{\pm1}\big)\Gamma_e\big((qp)^{\frac12}t BD^{\pm1} v^{\pm1}\big)
\Gamma_e\big((q p)^{\frac12}t A^{-1} C^{\pm1} v^{\pm1}\big)\nonumber\\
\quad{}\times\Gamma_e\big((pq)^\frac12 t B C^{\pm1}u^{\pm1}\big)\Gamma_e\big((pq)^\frac12 t A^{-1}D^{\pm1}u^{\pm1}\big).
\end{gather}
Now we look at the pole $y_2$. the integral over $w_1$ is pinched at $w_1=q^{\pm\frac12}v^{\pm1}$. Substituting these values \eqref{c2} now becomes
\begin{gather*}
\frac12\frac{\Gamma_e\big(t^{-2}\big)\Gamma_e\big(pq^3t^2A^{-2}B^2\big)}
{\Gamma_e\big(pq^3 t^4 A^{-2}B^2\big)}\frac{\Gamma_e\big(v^2\big)}{\Gamma_e\big(qv^2\big)}
\Gamma_e\big( q^{-\frac12}AB^{-1}u^{\pm1}\big(q^\frac12 v\big)^{\pm1}\big)\Gamma_e\big((qp)^{\frac12}q^\frac12 t B D^{\pm1}\big(q^\frac12 v\big)^{\pm1}\big)\\
\quad{} \times\Gamma_e\big( ( q p)^{\frac12} q^\frac12 t A^{-1} C^{\pm1} \big(q^\frac12 v\big)^{\pm1}\big)
\oint \frac{{\rm d}w_2}{4\pi i w_2} \frac{1}{\Gamma_e\big(w_2^{\pm2}\big)} \Gamma_e\left(\frac{(p q)^{\frac12}}{t^2}q^\frac12 v w_2^{\pm1}\right)\\
\quad{}\times \Gamma_e\big((q p)^{\frac12}q^\frac12 t^2 A^{-1} B w_2^{\pm1} u^{\pm1}\big) \Gamma_e \big(q^{-\frac12} t^{-1} B^{-1} D^{\pm1}w_2^{\pm1}\big)\\
\quad{}\times \Gamma_e\big( ( q p )^{\frac12}q^\frac12 t^2 w_2^{\pm1} v^{-1}\big) \Gamma_e\big( q^{-\frac12}t^{-1} A w_2^{\pm1} C^{\pm1}\big)
+\big\{v \leftrightarrow v^{-1} \big\} .
\end{gather*}
The integral here can be interpreted as index of the ${\rm SU}(2)$ gauge theory with four flavors. Using the Intriligator--Pouliot duality transformation (that is $V(\underline{s})={\prod\limits_{1\leq j < k\leq 8} \Gamma_e(s_j s_k)V(\sqrt{pq}/\underline{s})}$ in the notations of) the expression becomes
\begin{gather*}
\frac12\frac{\Gamma_e\big(t^{-2}\big)\Gamma_e\big(pq^3t^2A^{-2}B^2\big)}
{\Gamma_e\big(pq^3 t^4 A^{-2}B^2\big)}\frac{\Gamma_e\big(v^2\big)}{\Gamma_e\big(qv^2\big)}
\Gamma_e\big( q^{-\frac12}AB^{-1}u^{\pm1}\big(q^\frac12 v\big)^{\pm1}\big)\Gamma_e\big((qp)^{\frac12}q^\frac12 t B D^{\pm1}\big(q^\frac12 v\big)^{\pm1}\big)\\
\quad{} \times\Gamma_e\big( ( q p)^{\frac12} q^\frac12 t A^{-1} C^{\pm1} \big(q^\frac12 v\big)^{\pm1}\big) \Gamma_e\big(pq^2A^{-1}Bvu^{\pm1}\big)\Gamma_e\big((pq)^\frac12 t^{-3}B^{-1}vD^{\pm1}\big)\\
\quad{} \times\Gamma_e\big((pq)^\frac12 t^{-3}AvC^{\pm1}\big)\Gamma_e\big(pq^2t^4A^{-2}B^2\big)\Gamma_e\big((pq)^\frac12 t A^{-1}u^{\pm1}D^{\pm1}\big)\Gamma_e\big((pq)^\frac12 tBu^{\pm1}C^{\pm1}\big)\\
\quad{} \times\Gamma_e\big(pq^2t^4A^{-1}B v^{-1}u^{\pm1}\big)\Gamma_e\big(q^{-1}t^{-2}B^{-2}\big)\Gamma_e\big(q^{-1}t^{-2}AB^{-1}C^{\pm1}D^{\pm1}\big)\\
\quad{}\times\Gamma_e\big((pq)^\frac12 t B^{-1}v^{-1}D^{\pm1}\big) \Gamma_e\big(q^{-1}t^{-2}A^2\big)\Gamma_e\big((pq)^\frac12 t Av^{-1}C^{\pm1}\big)\Gamma_e\big(pq^2\big)\\
\quad{}\times \oint \frac{{\rm d}w_2}{4\pi i w_2} \frac{1}{\Gamma_e\big(w_2^{\pm2}\big)} \Gamma_e\big(q^{-\frac12}t^2 v^{-1} w_2^{\pm1}\big) \Gamma_e\big(q^{-\frac12} t^{-2} A B^{-1} w_2^{\pm1} u^{\pm1}\big)\\
\quad{} \times\Gamma_e \big((pq)^{\frac12}q^\frac12 t B D^{\pm1}w_2^{\pm1}\big)
\Gamma_e\big( ( q p )^{\frac12}q^\frac12 t A^{-1} w_2^{\pm1} C^{-1}\big) \Gamma_e\big( q^{-\frac12}t^{-2} v w_2^{\pm1} \big)
+\big\{v \leftrightarrow v^{-1} \big\} .
\end{gather*}
We have zero multiplying the integral but the integral is pinched at $w_2=\big(q^{\pm\frac12}t^{-2}v\big)^{\pm1}$ due to the colliding of poles of the first and last elliptic gamma functions in the last integral. We get different contribution for each choice
\end{document}