Proof of Riemann's Second Bilinear Relation Let $\eta$ be a meromorphic differential and let $\omega$ be a differential with no residue on a Riemann surface $\Sigma$. Let $\mathcal{L}$ be the simply connected domain obtained by cutting $\Sigma$ along a canonical basis $\{a_i, b_i \}$ for its homology and consider the map $\mathfrak{u} : \mathcal{L} \to \mathbb{C}$ given by $\mathfrak{u}(P) = \int_{P_0}^P \omega$. Here, $P_0 \in \mathcal{L}$ is fixed. In "Riemann Surfaces and Theta Functions" (page 33), Bertola gives the second Riemann bilinear relation as
$$\sum_{Q = \text{pole of } \eta, \omega} \underset{Q}{Res}\ \mathfrak{u} \eta = \frac{1}{2\pi i}\sum_{i=1}^g \oint_{b_i} \omega \oint_{a_i} \eta - \oint_{b_i} \eta \oint_{a_i} \omega$$
Bertola then claims that this can be proven using the residue theorem. However, I don't see how the residue theorem can be applied and I'm not sure how to approach this proof. Does anyone have any suggestions for how to approach this proof? 
 A: The boundary of the polygon is segments like $a_ib_ia_i^{-1}b_i^{-1}$
Let $z$ and $z^{\prime}$ be two corresponding points on $a_i$ and $a_i^{-1}$
Let $f=\int \omega$ (its easier to type). 
Now 
$$f(z^{\prime})-f(z)=\int_{z}^{z^{\prime}} \omega=\int_{b_i} \omega$$
where the second equality holds since $b_i$ is between $a_i$ and $a_i^{-1}$, and the portions of $a_i$ and $a_i^{-1}$ integrated over cancel each other out.
Similarly if $z$ and $z^{\prime}$ are two corresponding points on $b_i$ and $b_i^{-1}$
Then 
$$f(z^{\prime})-f(z)=\int_{z}^{z^{\prime}} \omega=\int_{a_i^{-1}} \omega=-\int_{a_i} \omega$$
Now $$\int_{a_i} f\eta +\int_{a_i^{-1}} f\eta=\int_{a_i} (f(z)- f(z^{\prime}))\eta =-\int_{b_i}\omega\int_{a_i}\eta$$
$$\int_{b_i} f\eta +\int_{b_i^{-1}} f\eta=\int_{a_i} (f(z)- f(z^{\prime}))\eta =\int_{a_i}\omega\int_{b_i}\eta$$
The result is
$$\int_C f\omega=\sum\limits_{i=1}^g\int_{a_i}\omega\int_{b_i}\eta-\int_{b_i}\omega\int_{a_i}\eta$$
Where $C$ is the entire boundary.
Now apply the residue theorem to the left hand side.
(there may be some sign difference in my answer and the question, its a question of orientations, conventions, and the highly likely case that I made some sign error.) 
