# Antiderivative of a rational function

Tags:
1. Dec 28, 2016

### Rectifier

I am trying to find primitives to the rational function below but my answer differs from the answer in the book only slightly and now, I am asking for your help to find the error in my solution. This solution is long since I try to include all the steps in the process.

The problem

$$\int \frac{x^2+8x+4}{x^2+4x+8} dx$$

Relevant equations

$$\int \frac{1}{x} dx = \ln |x| + C \\ \int \frac{1}{x^2+1} dx =arctan x + C$$

The attempt at a solution

I am starting with a polynomial division and rewrite the fraction as
$\int \frac{x^2+8x+4}{x^2+4x+8} dx = \int 1 + \frac{4x-4}{x^2+4x+8} dx$

Since divisor is irreducible, I must complete the square and adapt the quotient to use the standard formula for a function that has a primitive which is $arctan x +C$ as follows.

$$\int 1 + \frac{4x-4}{x^2+4x+8} dx = x + \int \frac{4x-4}{(x+2)^2+4} dx \\ x + \int \frac{4(x-1)}{\frac{4}{4}(x+2)^2+4} dx \\ x + \int \frac{4(x-1)}{4 \left( \frac{(x+2)^2}{4}+1 \right)} dx \\ x + \int \frac{4(x-1)}{4 \left( \left( \frac{x+2}{2} \right)^2+1 \right)} dx \\ x + \int \frac{x-1}{ \left( \frac{x+2}{2} \right)^2+1} dx$$

I split the qotent:
$$x + \int \frac{x}{ \left( \frac{x+2}{2} \right)^2+1} dx - \int \frac{1}{ \left(\frac{x+2}{2} \right)^2+1} dx$$

Lets focus on the part that has $x$ as divisor.

$$\int \frac{x}{ \left( \frac{x+2}{2} \right)^2+1} dx$$

I perform a variable substitutution $[t= \frac{x+2}{2} \Leftrightarrow x = 2t-2, \frac{dt}{dx} = \frac{1}{2} \Leftrightarrow 2 dt = dx]$. That results in

$$\int \frac{x}{ \left( \frac{x+2}{2} \right)^2+1} dx = 2 \left( \int \frac{2t-2}{ t^2+1} dt \right) = 2 \int \frac{2t}{ t^2+1} dt - 2 \cdot 2 \int \frac{1}{ t^2+1} dt$$

I split the quotient once more and focus on the part that has $2t$ as divisor where I make one more variable substitution $[g=t^2+1, \frac{dg}{dt}=2t \Leftrightarrow 2t dt = dg]$

$$2 \int \frac{2t}{ t^2+1} dt = 2 \int \frac{1}{g} dg = 2 \ln|g| + C = 2 \ln|t^2+1| + C = \ln| \left(\frac{x+2}{2} \right)^2 + 1|+ C$$
I use back-substitution in the last steps.

Now, lets add the rest of the integrals that we didn't focus on before:

$$x + \int \frac{x}{ \left( \frac{x+2}{2} \right)^2+1} dx - \int \frac{1}{ \left(\frac{x+2}{2} \right)^2+1} dx \\ x + \ \ 2 \int \frac{2t}{ t^2+1} dt - 2 \cdot 2 \int \frac{1}{ t^2+1} dt - \int \frac{1}{ \left(\frac{x+2}{2} \right)^2+1}\\ x + \ \ 2\ln| \left(\frac{x+2}{2} \right)^2 + 1| - 4 \arctan t - 2 \arctan(\left(\frac{x+2}{2} \right)) + C \\ x + \ \ 2\ln| \left(\frac{x+2}{2} \right)^2 + 1| - 6 \arctan(\left(\frac{x+2}{2} \right)) + C$$

I am not interested in alternative ways to solve the problem but to find the error in my calculations.

Please help.

The part that differs from the answer in my book is inside $\ln$ and not by much (see spoiler)
It differs only by a multiple of 4. In my book the contents of ln are: 2 \ln( x^2 + 4x + 8 )
.

2. Dec 28, 2016

### Fightfish

The two answers are equivalent. It is an indefinite integral so any multiplicative factors in the argument of the $\ln$ can simply be absorbed into the undetermined constant i.e. $\ln (4 f(x)) + C = \ln (f(x)) + \ln 4 + C = \ln (f(x)) + C'$.

3. Dec 28, 2016

### Ray Vickson

You have unnecessary absolute-value signs $| \ldots |$, and these get in the way of further simplification. In fact,
$$\int \frac{2t \, dt}{t^2+1} = \ln(t^2+1)$$
with no need for $| \ldots |$ because $t^2+1 \geq 1$ is always positive, and always has a non-negative logarithm.

4. Dec 28, 2016

### Rectifier

Thank you for your help everyone.

@Ray Vickson you wrote something before that that I didn't manage to read on how to solve that more efficiently. What steps are unnecessary here?

5. Dec 28, 2016

### Ray Vickson

I deleted it, because after posting (briefly) I noticed your statement that you were not interested in seeing other ways of doing it---only in finding your mistakes, which turned out to not be mistakes after all. However, what I said was:
$$\frac{4x-4}{(x+2)^2+4} dx = 2 \frac{ (2x+4) -6}{(x+2)^2+4} dx = 2\frac{(2x+4)\, dx}{(x+2)^2+4} - \frac{12\, dx}{(x+2)^2+4} .$$
The first term has the form $2 \, df/f$ while the second one is closely related to $dt/(t^2+1)$.

6. Dec 31, 2016

### Rectifier

Oh, thank you for reposting that! I wrote that last line since I often get alternative ways of solving the problem without them mentioning why my last solution produced a strange/wrong answer so I end up doing the same mistakes over and over again.

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted