TITLE: Definite Integral of an Infinite Sum
QUESTION [6 upvotes]: It is given that $$ f(x) = \sum_{n=1}^\infty \frac{\sin(nx)}{4^n} $$
How would one go about calculating $$ \int_0^\pi f(x)\ dx $$ 
EDIT:
I was able to calculate the integral of the $ \sin(nx) $ part using $u$ substitution. However, I lack the required knowledge to combine an integral and an infinite sum as this is the first time  I am doing this kind of a question.
I am currently studying in 11th in India under the CBSE curriculum. This question appeared in one of my internal tests and I am trying to get an explanation for it. 
I'd like to mention that I only posess basic knowledge of integration and differentiation as taught in my coaching center and knowledge of 11th grade NCERT math.

REPLY [10 votes]: An alternative approach:
$$ f(x)=\text{Im}\sum_{n\geq 1}\frac{e^{inx}}{4^n} = \text{Im}\left(\frac{e^{ix}}{4-e^{ix}}\right) = \text{Im}\left(\frac{e^{ix}(4-e^{-ix})}{17-8\cos x}\right)=\frac{4\sin x}{17-8\cos x}$$
implies:
$$ \int_{0}^{\pi}f(x)\,dx=\left[\tfrac{1}{2}\,\log(17-8\cos x)\right]_{0}^{\pi}=\log\sqrt{\frac{17+8}{17-8}}=\color{red}{\log\tfrac{5}{3}}. $$