<s>[INST] Partial fractions - integration $$\int \frac{4}{(x)(x^2+4)} $$ 
By comparing coefficients, 
$ 4A = 4 $,
$A = 1$ 
$1 + B = 0 $, 
$B= -1 $ 
$xC= 0 $, 
$C= 0 $ 
where $\int \frac{4}{x(x^2+4)}dx =\int \left(\frac{A}{x} + \frac{Bx+C}{x^2 + 4}\right)dx$. 
So we obtain $\int \frac{1}{x} - \frac{x}{x^2+4} dx$. 
And my final answer is 
$\ln|x| - x \ln |x^2 + 4| + C$. 
However my answer is wrong , the answer is - $\ln|x| - \frac{1}{2} \ln |x^2 + 4| + C$. 
Where have I gone wrong?
 [/INST] Your partial fraction expansion was correct.$$\frac 4{x(x^2+4)}=\frac 1x-\frac x{x^2+4}$$However, the error lies in integrating the second term of the right-hand side. To simplify$$\int\frac x{x^2+4}\, dx$$Make a substituting $z=x^2+4$. The derivative is $dz=2x\, dx$ so $x\, dx=dz/2$. Therefore, the integral transforms into$$\begin{align*}\int\frac {x\, dx}{x^2+4} & =\frac 12\int\frac {dz}{z}\\ & =\tfrac 12\log z+C\\ & =\tfrac 12\log(x^2+4)+C\end{align*}$$Hence, we have$$\boxed{\int\frac {4\, dx}{x(x^2+4)}=\log x-\tfrac 12\log(x^2+4)+C}$$
</s>