Computing self-intersections with complex analysis It is possible to find the winding number of a path $C \subset \mathbb{C}$ using complex analysis:
$$n = \oint_C\frac{dz}{z}.$$
You can also count the number of roots of $f(z) = 0$ inside a close curved $C$: 
$$n = \oint_C dz\,\frac{f'(z)}{f(z)}.$$
How do we count the number of self-intersections or self-tangencies of $C$ with itself?
$$\#[C \cap C] = \oint \frac{dz}{z}\frac{dw}{w} f(z,w)?$$
Self-intersection is a global event depending on two points - probably it is some kind of double-integral.


 A: The winding number $w(z)=\frac{1}{2\pi i}\int_C\frac{d\zeta}{z-z(\zeta)}$ helps little for counting the multiple points of a curve $C=\{z(\zeta), \zeta\in S^1\}$. Indeed $w$ is an integer-valued function which is constant on the components of $\Bbb C\backslash C$. One of those components is unbounded. The other ones are called holes of $C$ and their number is indicated by $h=h(C)$. So, for using $w$ you need to know $h$. But $h$ itself already suffices to count double points. Indeed if $C$ has $h$ holes and is generic i.e. $C$ has no other multiple points than a finite number $d$ of double points,  we have 
$$d=h-1.$$
This depends on a general property of connected graphs as I am going to explain.
More in general, if $C$ is a connected graph (maybe not a curve) with $h$ holes, $n_2$ double points, $n_3$ triple points and so on, we have 
$$\sum_2(1-j)n_j=h-1.$$
Proof.     Call singularity index of a vertex $v$ the number $s(v)$ of edges which have $v$ as vertex, reduced of $2$. For example if $v$ is smoothable we have $s(v)=0$, if it is a double point $s(v)=2$... Define the singularity index  of the whole graph as the sum $s(C)$ of the indices of its vertices. For example if $C$ consists in a single vertex or has the form of a comb we have $s(C)=-2$, if it is (homeomorphic to)  $S^1$ then  $s(C)=0$. If $C$ is (homeomorphic to) a smooth curve with $d$ double points then $s(C)=d$. In general, if $C$ has $n_2$ double points, $n_3$ triple points ... , then 
$$s(C)=2\sum_2 (j-1)n_j.$$
 So $s(C)$ is anyway an even number.
Now, in order to compute the Euler characteristic $\chi (C)$ ($=\sharp$ of vertices - $\sharp$ of edges) of $C$ 
 observe that each $v$ contributes with $s(v)+2$ to the sum "$2$($\sharp$ of edges)", thus 
$2$($\sharp$ of edges)=$s(C)+2$($\sharp$ of vertices). This gives 
$\chi (C)=- s(C)/2$. 
Assume now $C$ to be connected and take the $\varepsilon$-neighborhood $A$ of $C$. $A$ is an open, connected set in the plane and for $\varepsilon\ll 1$ has $h$ holes like $C$. The homology group $H_0(A)$ (any coefficients) has rank $1$ because of connectedness, $H_1(A)$ is generated by the holes and $H_2(A)=0$ because $A$ is on the plane. Hence the characteristic is $\chi (A)=1-h+0=1-h$. 
But $A$ is by construction a strong deformation retract of $C$ (see wiki: "retraction"). This means that there exist a retraction $A\to C$ which is homotopic to the identity of $A$ and the points of $C$ stay fixed during the homotopy. In other words there exists $F:A\times [0,1]\to A$ continuous, with the properties $F(a,0)=a$, $F(a,1)\in C$, $\forall a\in A$ and $F(x,t)=x, \forall (x,t)\in C\times [0,1]$. Now, a strong deformation retract of a complex has the same characteristic as the complex itself  (see again wiki: "retractions"), hence we have $\chi (C)=\chi (A)$. Substituting we obtain the desired formula.  
A: The intersection number of two closed curves in $\mathbb{C}$ can be calculated by 
means of an integral (http://en.m.wikipedia.org/wiki/Intersection_number#Definition_for_Riemann_surfaces). I would assume this could be applied to calculating the number of selfintersection (e.g. if need be by appropriate subdividing the curve), but I have not checked the details.
