I want to calculate integrals with $\sin(x)$ and $\cos(x)$ by real and imaginary part of $e^{ix}$.
Assume $e^{ix}=\cos(x)+i\sin(x)$
For example $$ \begin{align*} \int \sin(x)dx &= \int Im(e^{ix})dx = Im\left(\int e^{ix}dx\right)= Im\left(\frac{1}{i}e^{ix}+c\right) = Im\left(-ie^{ix}+c\right) \\ &= Im(-i[\cos(x)+i\sin(x)]+c) = Im(-i[\cos(x)+i\sin(x)]+c) \\ &= Im(-i\cos(x)+\sin(x)+c) = -\cos(x) + c \end{align*} $$
How to use this method (if it is possible) to calculate $\int \sin^{2}(x) dx$ and $\int x^{2}\sin^{2}(x) dx$ ?
How to handle higher exponent of $\sin(x)$ and $\cos(x)$ in integrals like $\int \sin^{n}(x) dx$, $\int \sin^{n}(x) \cos^{m}(x) dx$ where $n,m\geq 2$ ?