Definite integral of rational expression involving quadratics I was given the following exercise on my Calculus class:
$$
\int_2^4 \frac{x^2+4x+24}{x^2-4x+8}dx
$$
I studied from a book (author, Stewart) various methods to solve integrals of the form $\int \frac{P(x)}{Q(x)}dx$; a basic idea common to all of this methods is that $P(x)$ should have a smaller degree than $Q(x)$, in order for us to make a useful factorization. Since this is not the case on the integral I was given, I first computed the division of $P(x)=x^2+4x+24$ over $Q(x)=x^2-4x+8$, which took me to the fact that
$P(x)= Q(x) + (8x+32)$. So the integral can be rewritten in the following manner:
$$
\int_2^4 \frac{(x^2-4x+8)+(8x+32)}{x^2-4x+8}dx=\int_2^4 dx+\int_2^4 \frac{8x+32}{x^2-4x+8}dx
$$
Putting aside the first term of the resulting expression, which is a very simple integral, it all comes down to solving the second term. Gladly I have managed to translate the first integral into a new one in which the numerator is of smaller degree than the denominator. But how do I go about solving $\int_2^4 \frac{8x+32}{x^2-4x+8}dx$.
Well, according to Stewart, once we have managed to solve our little degree problem, we have to factorize the denominator, and from there rewrite the whole expression. But the quadratic on the denominator does not seem to have a complete factorization, and so I am clueless on what to do. This is the only method I was taught to solve this kind of integrals. Am I making a mistake somewhere, or how would you go about solving this problem? Thanks in advance.
 A: HINT
You may start by noticing that
\begin{align*}
\frac{8x+32}{x^{2}-4x+8} & = 4\times\frac{2x + 8}{x^{2}-4x+8} = 4\times\frac{2x - 4 + 4 + 8}{x^{2}-4x+8}\\\\
& = 4\times\frac{2x - 4}{x^{2}-4x+8} + 4\times\frac{12}{x^{2}-4x+8}
\end{align*}
In order to integrate the first expression, observe that $(x^{2}-4x+8)^{\prime} = 2x-4$. So it remains to solve the integral of the second expression. For this purpose, we can rearrange the denominator as $(x-2)^{2} + 4$. Then you apply the substitution (or any other trigonometric substitution you prefer)
\begin{align*}
\cosh(u) = \frac{x-2}{2}
\end{align*}
Can you take it from here?
A: It appears you have written your integral in the wrong manner, as $8+32\neq 24$.
\begin{align}
\int_2^4 \frac{x^2+4x+24}{x^2-4x+8}\ dx&=\int_2^4 \frac{(x^2-4x+8)+(8x+16)}{x^2-4x+8}\ dx\\
&=\int_2^4 dx + 8\int_2^4\frac{x+2}{x^2-4x+8}\ dx\\
&=x\big]_2^4+8\int_2^4 \frac{x+2}{(x-2)^2+4}\ dx\\
&=2+8\int_0^2 \frac{u+4}{u^2+4}\ du&\textrm{(let } u=x-2)\\
&=2+8\int_0^2\frac{u}{u^2+4}\ du+32\int_0^2  \frac{1}{u^2+4}\ du\\
&=2+4\int_4^8\frac1{v}\ dv+16\arctan(\frac{u}2)\big]_0^2&\textrm{(let } v=u^2+4)\\
&=2+4\ln v\big]_4^8+16\arctan(\frac{u}2)\big]_0^2\\
&=2+4\ln2+16(\frac{\pi}4)\\
&=2+4\ln2+4\pi
\end{align}
A few steps may have been unnecessary, but my thought process uses really simple substitutions which may fall in line with the thinking of certain students.
A: You're almost there. Write the second integrand as $$\frac{8x+32}{x^2-4x+8}=\frac{8x-16+16+32}{x^2-4x+8}=\frac{4(2x-4)+48}{x^2-4x+8}=4\frac{2x-4}{x^2-4x+8}+\frac{48}{x^2-4x+8}.$$
Again the first summand is easy (can you see why?), so focus on the last, which we may write as $$48\frac{1}{x^2-4x+4+4}=48\frac{1}{(x-2)^2+4}.$$ Can you now proceed?
