<s>[INST] compute the following integral $\int^{a}_{-a} \sqrt{a^2-x^2}dx$ I have to compute the following integral:
$\int^{a}_{-a} \sqrt{a^2-x^2}dx$
I did the substitution: $x=a\sin\theta$ so $dx=a\cos\theta d\theta$. The boundaries becomes $\pi/2+2k\pi$ and $-\pi/2-2k\pi$. So:
$\int^{\pi/2+2k\pi}_{-\pi/2-2k\pi} a^2\cos^2\theta d\theta$ becomes the integral.
My question is whether I am doing it correct. Thanks.
 [/INST] Let $I=\int\sqrt{a^2-x^2}dx=\sqrt{a^2-x^2}\int dx-\int\left(\frac{\sqrt{a^2-x^2}}{dx}\int dx\right)dx$
$=x\sqrt{a^2-x^2}-\int\left(\frac{(-2x)x}{2\sqrt{a^2-x^2}}\right)dx$
$=x\sqrt{a^2-x^2}-\int\left(\frac{(a^2-x^2-a^2)}{\sqrt{a^2-x^2}}\right)dx$
$=x\sqrt{a^2-x^2}-\int \sqrt{a^2-x^2}dx +a^2\int\frac{dx}{\sqrt{a^2-x^2}}$
$=x\sqrt{a^2-x^2}-I +a|a|\arcsin\frac xa+C$ where $C$ is the indefinite constant for indefinite integration.
Or, $I=\frac{x\sqrt{a^2-x^2}}2+\frac{a|a|}2\arcsin\frac xa+\frac C2$
So, $$\int^{a}_{-a} \sqrt{a^2-x^2}dx=(\frac{x\sqrt{a^2-x^2}}2+\frac{a|a|}2\arcsin\frac xa+C)\mid_{-a}^a=\frac{a|a|}2\{ \arcsin1-\arcsin(-1)\}$$
$$=\frac{a|a|}2\{\frac\pi2-(-\frac\pi2)\}=\frac{\pi a|a|}2$$

Alternatively,
taking $a>0,x=a\sin \theta,dx=a\cos \theta d\theta$
and $\sqrt{a^2-x^2}=|a|\cos \theta=a\cos \theta$ as $a>0$
$$\int^{a}_{-a} \sqrt{a^2-x^2}dx=\int^{\pi/2+2k\pi}_{-\pi/2+2k\pi} (a\cos\theta)^2 d\theta=\frac{a^2}2\int^{\pi/2+2k\pi}_{-\pi/2+2k\pi}(1+\cos2\theta)d\theta$$
$$=\frac{a^2}2(\theta+\frac{\sin2\theta}2)\mid_{-\pi/2+2k\pi}^{\pi/2+2k\pi}$$
$$=\frac{a^2}2\{\frac \pi 2+2k\pi-(-\frac \pi2+2k\pi)\}+\frac{a^2}4(\sin(4k+1)\pi-\sin(4k-1)\pi)=\frac{\pi a^2}2$$
</s>