Evaluate the following integral:
$\int \frac{\left(x^{2}+1\right)\left(x^{2}+2\right)}{\left(x^{2}+3\right)\left(x^{2}+4\right)} d x$
$\frac{\left(x^{2}+1\right)\left(x^{2}+2\right)}{\left(x^{2}+3\right)\left(x^{2}+4\right)}=\frac{x^{4}+3 x^{2}+2}{x^{4}+7 x^{2}+12}$
$=\frac{\left(x^{4}+7 x^{2}+12\right)-4 x^{2}-10}{x^{4}+7 x^{2}+12}$
$=1-\frac{4 x^{2}+10}{x^{4}+7 x^{2}+12}$
Now, $\frac{4 x^{2}+10}{x^{4}+7 x^{2}+12}=\frac{4 x^{2}+10}{\left(x^{2}+3\right)\left(x^{2}+4\right)}$
Let, $\frac{4 x^{2}+10}{\left(x^{2}+3\right)\left(x^{2}+4\right)}=\frac{A x+B}{x^{2}+3}+\frac{C X+D}{x^{2}+4}$
$\Rightarrow 4 x^{2}+10=(A x+B)\left(x^{2}+4\right)+(C x+D)\left(x^{2}+3\right)$
For, $x=0,10=4 B+3 D \ldots$ (i)
For, $x=1,14=5 A+5 B+4 C+4 D \ldots$ (ii)
For, $x=-1,14=-5 A+5 B-4 C+4 D \ldots$ (iii)
Also, by comparing coefficient of $x^{3}$ we get, $0=A+C$ (iv)
On solving, (i), (ii), (iii), (iv) we get,
$A=0, B=-2, C=0, D=6$
So, $\frac{\left(x^{2}+1\right)\left(x^{2}+2\right)}{\left(x^{2}+3\right)\left(x^{2}+4\right)}=1+\frac{2}{x^{2}+3}-\frac{6}{x^{2}+4}$
$\therefore \int \frac{\left(x^{2}+1\right)\left(x^{2}+2\right)}{\left(x^{2}+3\right)\left(x^{2}+4\right)} d x=\int\left(1+\frac{2}{x^{2}+3}-\frac{6}{x^{2}+4}\right) d x$
$=\mathrm{x}+\frac{2}{\sqrt{3}} \tan ^{-1} \mathrm{x}-3 \tan ^{-1} \frac{\mathrm{x}}{2}+\mathrm{c}$
Therefore, $\int \frac{\left(x^{2}+1\right)\left(x^{2}+2\right)}{\left(x^{2}+3\right)\left(x^{2}+4\right)} d x=x+\frac{2}{\sqrt{3}} \tan ^{-1} x-3 \tan ^{-1} \frac{x}{2}+c$