In fact, I have the following function:
$$w:[0,2\pi)\to\mathbb{C}, \quad w(\theta)=i(x\cos(\theta)+y\sin(\theta))\quad(1)$$
whit $x,y\in\mathbb{R}$.
In order to find the extremum, I equal the first derivative to zero: $$y\cos(\theta)-x\sin(\theta)=0\quad(2)$$ So, isolating $\theta$, I find that the extremum $\theta^*$ satisfies: $$ \theta^*=\arctan(y/x)\quad(3)$$ However, this isn't correct because the extremum $\theta^*$ lies in the domain of $w$, $[0,2\pi)$, and the range of $\arctan(x/y)$ is $(-\pi/2,\pi/2)$. I mean, if $\theta^*=\arctan(y/x)<0$ for some $x$ and $y$, this violates the fact that $\theta^*\in[0,2\pi)$.
Could you help me figuring out another solution of (2) with the assumptions that $\theta\in[0,2\pi)$ and $x,y\in\mathbb{R}$ ?
Honestly, it's ambiguous to consider the extremum of complex-valued function. So I assume that you are seeking the extremum of $x\cos(\theta)+y\sin(\theta)$.
Then,
$$ x\cos(\theta)+y\sin(\theta) = D cos(\theta - \alpha) $$ where $D = \sqrt{x^2 + y^2}$, $\alpha \in [0, 2\pi)$ such that $\cos(\alpha) = x/D$, $\sin(\alpha) = y/D$.
The extremum is $D$ and it is attainted as $\theta = \alpha$.