# Analytical Solution for the Problem of Point Location in Arbitrary Planar Domains
## 4 Calculation of the Contour Integral
### The Complex Logarithm
#### 4.2.2 Simplifying the Calculation of the Contour Integral  
The result expressed by (32) allows to assert the full methodology because it calculates, directly and in a straightforward mode, the circulation of a path made up of linear segments. In the particular case of \(\Gamma\) defined as \(M\) linear segments, and with \(f(z)=\frac{1}{z-a}\), expression (7) with the results of expression (32) yields the following generic result:\[\oint_{\Gamma}f(z)\mathrm{d}z =\ln\frac{z_{2}-a}{z_{1}-a}+\ln\frac{z_{3}-a}{z_{2}-a}+\cdots+\ln \frac{z_{M}-a}{z_{M-1}-a}+\ln\frac{z_{1}-a}{z_{M}-a} \tag{33}\] \[=\sum_{n=1}^{M}\ln\frac{z_{(n\bmod M)+1}-a}{z_{n}-a}.\]  
Furthermore, to simplify the calculation and avoid using at all the complex logarithms, the previous calculations can be even more simplified since the possible variations of the contour calculations only occur in the imaginary part, as it is intuitive from previous statements, and easily demonstrable by expression (34). Indeed, being \(z_{k}=r_{k}\mathrm{e}^{\mathrm{i}\theta_{k}}\) and \(z_{m}=r_{m}\mathrm{e}^{\mathrm{i}\theta_{m}}\) and therefore \(\Re\left\{\ln\frac{z_{k}}{z_{m}}\right\}=\Re\left\{\ln\frac{r_{k}}{r_{m}}+ \mathrm{i}\arg\frac{z_{k}}{z_{m}}\right\}=\ln\frac{r_{k}}{r_{m}}\), the calculation of the real part of (33) for the polygon with \(M\) vertices is always null, as shown next:  
\[\Re\left\{\oint_{\Gamma}f(z)\,\mathrm{d}z\right\} =\Re\left\{\ln\frac{z_{2}}{z_{1}}+\cdots+\ln\frac{z_{M}}{z_{M-1}} +\ln\frac{z_{1}}{z_{M}}\right\} \tag{34}\] \[=\ln\frac{r_{2}}{r_{1}}+\cdots+\ln\frac{r_{M}}{r_{M-1}}+\ln\frac{ r_{1}}{r_{M}}\] \[=\ln\left(\frac{r_{2}}{r_{1}}\frac{r_{3}}{r_{2}}\cdots\frac{r_{M} }{r_{M-1}}\frac{r_{1}}{r_{M}}\right)=\ln(1)=0.\]  
Finally, it may then be stated that the circulation can be obtained by simply calculating \(\arg()\) operations using (35):  
\[\oint_{\Gamma}f(z)\,\mathrm{d}z=\sum_{n=1}^{M}\arg\frac{z(n\bmod M)+1-a}{z_{n }-a}. \tag{35}\]  
Reminding the definition in (14), and being \(z_{1}=r_{1}\mathrm{e}^{\mathrm{i}\theta_{1}}\) and \(z_{2}=r_{2}\mathrm{e}^{\mathrm{i}\theta_{2}}\), the definition of the \(\arg()\) function for a quotient of two complex numbers is, of course, given by (36):  
\[\arg\frac{z_{1}}{z_{2}}= \begin{cases}\theta_{1}-\theta_{2}&\Leftarrow-\pi< \theta_{1}-\theta_{2}\leqslant+\pi\\ \theta_{1}-\theta_{2}-2\pi&\Leftarrow\theta_{1}-\theta_{2}>+\pi.\\ \theta_{1}-\theta_{2}+2\pi&\Leftarrow\theta_{1}-\theta_{2}\leqslant-\pi \end{cases}  \tag{36}\]  
Resorting to the actual geometric problem, and denoting the testing point by \(a=(x_{a},y_{a})\), and a generic point to delimit segments by \(P_{n}=(x_{n},y_{n})\), it is immediate to state that  
\[\theta_{n}=\arg(P_{n}-a)=\mathrm{atan2}(y_{n}-a_{y},x_{n}-a_{x}) \tag{37}\]  
and, hence, Algorithm 1 on the following page can be promptly established. Moreover, since the circulation of \(f(z)\) always has a null real part (34), only the imaginary part is relevant and, therefore, the variant for the calculation given by (35) is preferred (simpler) than the calculation using expression (33). In conclusion, in a closed contour, the neat value of (35) will be null if, along the path, there are no transitions between quadrants \(Q2\) and \(Q3\), but if they occur, additional terms of \(\pm 2\pi\mathrm{i}\) must be added at each time, as expressed by (36). So, the following proposition can be asserted:  
**Theorem 3** (**NRA intersection theorem**). : _In a region enclosing a singularity of a function \(f(z)\), the value of the contour integral (hence, the point inclusion) depends exclusively on the number and sense of path transitions over the negative real axis (NRA)._This section has demonstrated how the contour integral is indeed the translation of the winding number approach introduced earlier as one of the well-known techniques for point location in polygons.