Compute $\int \frac{n^x}{n^{2x} + 8n^x + 12} \, dx$, where $n$ is a positive real number.
UPDATED SOLUTION: First, set $n^x = u.$ We have $du = n^x\log(n)\, dx.$ Subbing in $u$ and $\frac{du}{u\log(n)},$ we have $\frac{1}{\log n}\int \frac{1}{u^{2} + 8u + 12} \, du.$ Using partial fractions, we have $\frac1{u^2+8u+12}=\frac1{(u+6)(u+2)}=\frac A{u+6}+\frac B{u+2}.$ Solving for $A$ and $B,$ $Au+Bu=0$ and $2A+6B=1.$ Since $A=-B$ and $B=\frac{1}{4}, A=-\frac{1}{4}.$ Therefore, $\frac{1}{\log n}\int \frac{1}{u^{2} + 8u + 12} \, du =\frac{1}{4\log n}\int \frac{1}{u+2} - \frac {1}{u+6}\, du.$ Taking the integral of each fraction and simplifying, we get $\frac{1}{4\log n}\log\frac{|u+2|}{|u+6|} + C.$ Subbing in $n^x$ for $u,$ we get $\frac{1}{4\log n}\log\frac{|n^x+2|}{|n^x+6|} + C.$ Since $n^x$ is always positive, our answer is $\boxed{\frac{1}{4\log n}\log\frac{n^x + 2}{n^x + 6} + C},$ where $C$ is a constant and $n$ doesn't equal $1.$
OLD SOLUTION: First, set $n^x = u.$ We have $du = n^x\log(n) dx.$ Subbing in $u$ and $\frac{du}{u\log(n)},$ we have $\frac{1}{\log n}\int \frac{1}{u^{2} + 8u + 12} \, du.$ Completing the square, $\frac{1}{\log n}\int \frac{1}{(u+4)^2 - 4} \, du.$ Next, we set $u + 4 = v,$ so $dv = du.$ Subbing in $v$ and $dv,$ we have $\frac{1}{\log n}\int \frac{1}{v^2 - 4} \, dv.$ Factoring out -1/4, we have $-\frac{1}{4\log n}\int \frac{1}{1-\frac{v^2}{4}} \, dv.$ Again, we set $\frac{v}{2} = w,$ so $dw = \frac{dv}{2}.$ Subbing in $w$ and $2dw$, we have $-\frac{1}{2\log n}\int \frac{1}{1-w^2} \, dw.$ Making partial fractions, we get $-\frac{1}{2\log n}\int \frac{1}{1-w^2} \, dw = -\frac{1}{2\log n}\int \frac{1}{(1+w)(1-w)} \, dw = -\frac{1}{4\log n}\int \frac{1}{1+w} + \frac{1}{1-w} \, dw.$ Taking the integral of each fraction and simplyfying, we get $-\frac{1}{4\log n}\log\frac{|1+w|}{|1-w|}.$ Subbing in $ \frac{n^x}{2} + 2$ for $w,$ we get $-\frac{1}{4\log n}\log\frac{|1+ \frac{n^x}{2} + 2|}{|1-(\frac{n^x}{2} + 2)|} = -\frac{1}{4\log n}\log\frac{|n^x + 6|}{|-n^x - 2|}.$ Taking out the negative from $-n^x - 2$ because of the absolute value and taking the reciprocal of the logarithm because of the negative in front of $\frac{1}{4\log n}$, we get $\frac{1}{4\log n}\log\frac{|n^x + 2|}{|n^x + 6|},$ and since $n^x$ is always positive, our answer is $\boxed{\frac{1}{4\log n}\log\frac{n^x + 2}{n^x + 6}}.$
Alternatively, you could have used the roots of the quadratic to write $$\frac1{u^2+8u+12}=\frac1{(u+6)(u+2)}=\frac A{u+6}+\frac B{u+2}$$ You determine $A$ and $B$ using $$(A+B)u=0$$ and $$2A+6B=1$$ So $A=-B$ and $4B=1$. Therefore $$\frac1{u^2+8u+12}=\frac 14\left(\frac 1{u+2}-\frac 1{u+6}\right)$$ You will get the same result, but less chances to make mistakes.