I have this line integral $$\oint_{\partial D}(f\nabla f)\cdot\hat{n}\,ds$$ which I would like to "change variables" so that the final result is in terms of a line integral of $g$ on $[0,2\pi]$ where $g(\theta)=f(e^{i\theta})$.
Background info: $D=\{(x,y)\in\mathbb{R}^2: x^2+y^2<1\}$, so $\partial D$ is a unit circle.
My working (which is definitely wrong, but I am not sure where it goes wrong.): Parametrize the circle $\partial D$ by $x=\cos\theta$, $y=\sin\theta$. We may take $\hat n\,ds=(dy,-dx)$.
$\begin{align*} &\oint_{\partial D}(f\nabla f)\cdot(dy,-dx)\\ &=\oint_{\partial D}(ff_x,ff_y)\cdot(dy,-dx)\\ &=\oint_{\partial D} (ff_x\,dy-ff_y\,dx) \end{align*}$
Making the change of variable $g(\theta)=f(e^{i\theta})$, then $f_x=\frac{dg}{d\theta}\frac{d\theta}{dx}=g'\cdot\frac{1}{-\sin\theta}$, $f_y=\frac{dg}{d\theta}\frac{d\theta}{dy}=g'\frac{1}{\cos\theta}$, $dx=-\sin\theta\, d\theta$, $dy=\cos\theta\,d\theta$.
Substituting all of these in, the eventual integral becomes $$\int_0^{2\pi} gg'(\tan\theta-\cot\theta)\,d\theta.$$
I am certain this is wrong since $\tan\theta=\infty$ at $\theta=\pi/2$. Which part of my working is wrong?
Thanks for any help. Very curious to know the error.