I have a problem with maximizing the fraction of the square of the sum of some sine and cosine functions. Denote $\mathbf{x} \triangleq {(x_i)}_{i \in \{1,2,...,N\}}$. The problem is shown below. $$\max_{\mathbf{x}} \frac{A({(\sum_{i = 1}^N \cos(x_i - a_i))}^2+{(\sum_{i = 1}^N \sin(x_i - a_i))}^2)}{B({(\sum_{i = 1}^N \cos(x_i - b_i))}^2+ {(\sum_{i = 1}^N \sin(x_i - b_i))}^2)+1}$$ where $A$ and $B$ are constant, and $\mathbf{a} \triangleq {(a_i)}_{i \in \{1,2,...,N\}}$ and $ \mathbf{b} \triangleq {(b_i)}_{i \in \{1,2,...,N\}}$ are known.
I tried some variable substitution and found it hard to handle sine and cosine functions decently.
Could anyone give me some hints to handle optimization problem with sine and cosine functions? Thanks!