let the centroid be the point $(x_c,y_c)$
where $$x_c = \frac{\int x ds}{\int ds}$$ $$y_c = \frac{\int y ds}{\int ds}$$
Find the centroid of the semicircle $x^2 + y^2 = a^2$, where $y >= 0 $ I was trying: $$ y = \sqrt{a^2-x^2}$$ $$y' = \frac{-x}{\sqrt{a^2-x^2}}$$ $$ds = \sqrt{1 + (\frac{-x}{\sqrt{a^2-x^2}})^2}dx$$ $$y_c = \frac{\int_{-a}^a adx}{\int_{-a}^a \frac{a}{\sqrt{a^2-x^2}}dx} = 1$$
which is wrong What did I get wrong?
Since $ds=\frac{a}{\sqrt{a^2-x^2}}\,dx$, your last line should be $$y_c = \frac{\int_{-a}^a \color{blue}{a}\,dx}{\int_{-a}^a \frac{a}{\sqrt{a^2-x^2}}\,dx} =\frac{2a^2}{a[\arcsin(x/a)]_{-a}^a}=\frac{2a^2}{\pi a}=\frac{2a}{\pi}.$$ As regards the $x$- coordinate, we have that $$x_c = \frac{\int_{-a}^a \frac{ax}{\sqrt{a^2-x^2}}\,dx}{\int_{-a}^a \frac{a}{\sqrt{a^2-x^2}}\,dx}=0$$ because the integrand at the numerator is odd and the interval is symmetric with respect to $0$.
P.S. In polar coordinates the computation is easier: $$y_c = \frac{\int_{-\pi/2}^{\pi/2} a\sin(\theta)\,a d\theta}{\int_{-\pi/2}^{\pi/2} ad\theta} =\frac{2a^2}{a\pi}=\frac{2a}{\pi}.$$
P.P.S. Letting $x=a\sin(\theta)$ then $dx=a\cos(\theta)\,d\theta$ and $$\int_{-a}^a \frac{a}{\sqrt{a^2-x^2}}\,dx =\int_{-\pi/2}^{\pi/2} \frac{a}{a\cos(\theta)}\,a\cos(\theta)\,d\theta=a\int_{-\pi/2}^{\pi/2}d\theta=\pi a.$$