How do I calculate the electric field due to a uniformly charged semicircle? I want to find the y-component of the electric at a point $b$ on the x-axis due to a charged semicircle centred around the origin. 

I found $dq$ using
$$\frac{dq}{Q} = \frac{dθ}{π}$$
$$dq = \frac{Q}{π}dθ$$
And the distance $r$ from $dq$ to $b$ using cosine law
$$r^2 = a^2 + b^2 - 2abcosθ$$
Subbing this into $dE = \frac{kdq}{r^2}$ gives
$$dE = \frac{k\frac{Q}{π}}{a^2 + b^2 - 2abcosθ}dθ$$
Since I only want the y-component of the electric field, I multiplied the whole thing by sinθ and integrated to get
$$E_y = \int\frac{k\frac{Q}{π}sinθ}{a^2 + b^2 - 2abcosθ}dθ$$
$$E_y = \frac{kQ}{2πab}ln(\frac{a^2+b^2+2ab}{a^2+b^2-2ab})$$
The answer that I should be getting is 
$$E_y = \frac{2kQ}{\pi}\frac{1}{b^2-a^2}$$
 A: So you have the source point $[a\cos\theta,~a\sin\theta]$ and the field point $[b,~0]$ and therefore the vector connecting the two is $\vec r = [b-a\cos\theta,~a\sin\theta].$
You are correct to calculate $\|\vec r\| = \sqrt{a^2 + b^2 -2ab\cos\theta}$ but notice that when we want to calculate the $y$-component we need to form $\hat y\cdot \hat r/\|\vec r\|^2$ with $\hat y,\hat r$ being unit vectors. You seem to have assumed that $\hat y\cdot\hat r=\sin\theta$ but in fact we can see from the above expressions and the definition that $\hat r = \vec r / \|\vec r\|$ that actually,$$f(\theta) = \hat y\cdot\frac{\hat r}{\|\vec r\|^2} = \hat y\cdot\frac{\vec r}{\|\vec r\|^3} = \frac{a\sin\theta}{(a^2+b^2-2ab\cos\theta)^{3/2}}.$$Thus substituting $u=a^2+b^2-2ab\cos\theta,~du=2ab\sin\theta~d\theta$ in the integral yields,$$\int_{-\pi}^0 d\theta ~f(\theta) = \int_{(a+b)^2}^{(a-b)^2}\frac{du}{2b}~u^{-3/2} =\frac1b~\left(\frac1{a+b} - \frac1{a-b}\right)=\frac1b~\left(\frac{a-b}{a^2-b^2} - \frac{a+b}{a^2-b^2}\right).$$
You did your integral right, but you did not set up the right integral because of the hand-wave about $\sin\theta.$
A: Assume $b>a$, as shown in your diagram.
First, your given answer should be wrong. Because if we let $a\rightarrow 0$ and fix $b$, then the $y$-component should go to zero. But your answer goes to the Coulomb field of a point charge.
The $y$ component is not obtained by simple multiplication by $\sin\theta$.
You have
$$d\vec{E} = \frac{k\frac{Q}{π}}{(a^2 + b^2 - 2ab\cos \theta)^{3/2}}d\theta((b-a\cos\theta) \hat{i}+a\sin\theta \hat{j})$$
So the $y$ component is
$$dE_y = \frac{k\frac{Q}{π}}{(a^2 + b^2 - 2ab\cos\theta)^{3/2}}d\theta a\sin\theta$$
Then
$$E_y= kQ/\pi \int_0^\pi \frac{a\sin\theta d\theta}{(a^2+b^2-2ab\cos\theta)^{3/2}} $$
$$=\frac{kQ}{2\pi b} \int_0^\pi \frac{d(a^2+b^2-2ab\cos\theta)}{(a^2+b^2-2ab\cos\theta)^{3/2}}$$
$$=\frac{kQ}{\pi b}\left[(a^2+b^2-2ab\cos\theta)^{-1/2}\right]_\pi^0$$
$$=\frac{kQ}{\pi b}\left[(a^2+b^2-2ab)^{-1/2}-(a^2+b^2+2ab)^{-1/2}\right]$$
$$=\frac{kQ}{\pi b}\left[\frac{1}{b-a}-\frac{1}{b+a}\right]$$
$$=\frac{2kQ}{\pi}\frac{a}{b}\frac{1}{b^2-a^2}$$
If instead you have $a>b$, then the answer is
$$E_y=\frac{kQ}{\pi b}\left[\frac{1}{a-b}-\frac{1}{a+b}\right]$$
$$=\frac{2kQ}{\pi}\frac{1}{a^2-b^2}$$
