# Math Help - A strange integral

1. ## A strange integral

Hello, everyone!

Try this integral: . $\int \frac{dx}{1 + e^x}$

I posted this problem at SOSMath three years ago.

I said (quite smugly as you will see):
. . . . ."So far, I've found four ways to integrate it.
. . . . . And the four answers all look different.
. . . . . Give it a try. .I dare you to come up with a fifth method."

Within three hours, radagast found a stunning fifth method.
And a day or so later, skeeter provided a surprising sixth method.

So I offer the challenge again (less arrogantly this time):
. . Is there a seventh method?

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Method #1: "Long Division"

We have: . $I \:= \:\int\frac{dx}{1 + e^x}$

. . $\frac{1}{1 + e^x}\;=\;\frac{1 + e^x - e^x}{1 + e^x} \;= \;\frac{1 + e^x}{1 + e^x} - \frac{1}{1 + e^x}\;=\;1 - \frac{e^x}{1 + e^x}$

Therefore: . $I \;= \;\int\left(1 - \frac{e^x}{1 + e^x}\right)\,dx\;=\;\boxed{x - \ln(1 + e^x) + C}$

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Method #2: $\frac{du}{u}$

Multiply top and bottom by $e^{-x}:$

. . $\frac{e^{-x}}{e^{-x}}\cdot\frac{1}{1 + e^x} \;= \;\frac{e^{-x}}{e^{-x} + 1} \;= \;-\frac{-e^{-x}}{e^{-x} + 1}
$

Therefore: . $I \;= \;-\int\frac{-e^{-x}}{e^{-x} + 1}\,dx \;= \;\boxed{ -\ln(e^{-x} + 1) + C}$

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Method #3: Substitution

Let $U = 1 + e^x\quad\Rightarrow\quad e^x = U-1\quad\Rightarrow\quad x =$ $\ln(U - 1)\quad\Rightarrow\quad dx = \frac{dU}{U - 1}$

Substitute: . $I \;= \;\int \frac{dU}{U(U - 1)}$

Now there are two ways to proceed . . .

. . (A) Partial Fractions

. . $\int\frac{du}{U(U - 1)}\;=\;\int\left(\frac{1}{U - 1} - \frac{1}{U}\right)\,dU$ $= \;\ln|U - 1| - \ln|U| + C$

. . . . $= \;\ln\left|\frac{U - 1}{U}\right| + C \;= \;\ln\left(\frac{e^x}{1 + e^x}\right) + C$

. . (B) Complete the square

. . $\int\frac{dU}{U^2 - U} \;= \;\int\frac{dU}{(U - \frac{1}{2})^2 - (\frac{1}{2})^2} \;=\;\ln\left|\frac{(U - \frac{1}{2}) - \frac{1}{2}}{(U - \frac{1}{2}) + \frac{1}{2}}\right| + C$

. . . . $= \;\ln\lleft|\frac{U - 1}{u}\right| + C \;= \;\boxed{\ln\left(\frac{e^x}{1 + e^x}\right) + C}$

Note: the substitution $u = e^x$ leads to the same integral.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Method #4: Trig Substitution . . . my personal favorite.

Let $e^x = \tan^2\theta\quad\Rightarrow\quad e^{\frac{x}{2}} = \tan\theta\quad \Rightarrow\quad \frac{x}{2} =$ $\ln(\tan\theta)\quad\Rightarrow\quad dx = 2\cdot\frac{sec^2\theta}{\tan\theta}\,d\theta$
The denominator is: . $1 + e^x \;= \;1 + \tan^2\theta \;= \;\sec^2\theta$

Substitute: . $I\;=\;\int\frac{1}{\sec^2\theta}\cdot2\cdot\frac{\ sec^2\theta}{\tan\theta}\,d\theta\;=$ $2\int\cot\theta\,d\theta \;= \;2\cdot\ln|\sin\theta| + C$

Since $\tan\theta = e^{\frac{x}{2}}$. then angle $\theta$ is in a right triangle with $opp = e^{\frac{x}{2}}$ and $adj = 1$.
. . Hence: . $hyp = \sqrt{1 + e^x}$ .and . $\sin\theta = \frac{e^{\frac{x}{2}}}{\sqrt{1 + e^x}}$

Therefore: . $I \;= \;\boxed{2\cdot\ln\left(\frac{e^{\frac{x}{2}}}{ \sqrt{1 + e^x}}\right) + C}$

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

I have "boxed" the four different-looking solutions.

(should you decide to accept it) is to prove them equivalent.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

We note that: . $\frac{d}{dx}\left[\ln(1 + e^x)\right] \:=\:\frac{e^x}{1 + e^x}$

Then: . $\int d\left[\ln(1 + e^x)\right]\,dx\;=\;\int\frac{e^x}{1 + e^x}\,dx$

. . and we have: . $\ln(1 + e^x) \;= \;\int\left(1 - \frac{1}{1 + e^x}\right)\,dx\;=$ $\int dx\: - \underbrace{\int\frac{dx}{1 + e^x}}$
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . This is $I$

We have the equation: . $\ln(1 + e^x)\:=\:x - I + C$

Therefore: . $I\;=\;x - \ln(1 + e^x) + C$ . (Solution #1)

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Method #6: skeeter's method

Let $u^2 = e^x\quad\Rightarrow\quad 2u\,du = e^x\,dx\quad\Rightarrow\qiad 2u\,du =$ $u^2dx\quad\Rightarrow\quad dx = \frac{2\,du}{u}$

Substitute: . $\int\frac{1}{1 + u^2}\left(\frac{2\,du}{u}\right)\;=\;\int\frac{2\, du}{u(1 + u^2)}\;=$ $\int\left(\frac{2}{u} - \frac{2u}{1 + u^2}\right)\,du$

. . $= \;2\ln u - \ln(1 + u^2) + C \;= \;\ln u^2 - \ln(1 + u^2) + C\;=$ $\ln\left(\frac{u^2}{1 + u^2}\right) + C
$

Therefore: . $I \;= \;\ln\left(\frac{e^x}{1 + e^x}\right) + C$ . (Solution #3)

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Now you are fully prepared to impress/amaze/terrify your teacher.

2. Hello, Soroban,

$x-\ln(1+e^x)=\ln(e^x)-\ln(1+e^x)=\ln\left(\frac{e^x}{1+e^x}\right)$. Answer # 3

$-\ln(e^{-x}+1)=\ln\left(\frac{1}{\frac{1}{e^x}+1}\right) =\ln\left(\frac{e^x}{1+e^x}\right)$. Answer # 3

$2 \cdot \ln \left(\frac{e^{\frac{x}{2}}}{\sqrt{1+e^x}} \right) =$ $\ln\left(\left(\frac{e^{\frac{x}{2}}}{\sqrt{1+e^x} }\right)^2\right)$ $=\ln\left(\frac{e^x}{1+e^x}\right)$. Answer # 3

Greetings

EB

3. Well done, Earboth!

My first experience with these multiple-answer integrals was: $\int\sin x\cos x\,dx$
. . which my professor said could be integrated in two ways.

(1) Let $u = \sin x\quda\Rightarrow\quad du = \cos x\,dx$
. . .Substitute: . $\int u\,du \;= \;\frac{1}{2}u^2 + C\;= \;\frac{1}{2}\sin^2x + C$

(2) Let $u = \cos x\quad\Rightarrow\quad du = -\cos x\,dx$
. . . Substitute: . $-\int u\,du \;=\;-\frac{1}{2}u^2 + C\;= \;-\frac{1}{2}\cos^2x + C$

Then he proceeded to show us a third method:

(3) $\int\sin x\cos x\,dx \;= \;\frac{1}{2}\int(2\sin x\cos x)\,dx \;=$ $\;\frac{1}{2}\int\sin(2x)\,dx \;= \;-\frac{1}{4}\cos(2x) + C$

. . (I later found a fourth method.)

Later he gave us: . $\int\sec^2x\tan x\,dx$

And asked us to find at least three ways to integrate it . . .

4. Originally Posted by Soroban
Well done, Earboth![size=3]

My first experience with these multiple-answer integrals was: $\int\sin x\cos x\,dx$
. . which my professor said could be integrated in two ways....
Hello, Soroban,

$\int u\cdot v'dx= u\cdot v-\int v\cdot u'dx$

Let v(x)=sin(x) ==> v'(x) = cos(x) and
u'(x) = cos(x) ==> u(x) = sin(x)

$\int\sin x\cos x\,dx=\sin(x) \cdot \sin(x)-\int\sin x\cos x\,dx + C$

Thus

$2\cdot \int\sin x\cos x\,dx= \left(\sin(x)\right)^2+C_1$. Therefore

$\int\sin x\cos x\,dx=\frac{1}{2}\cdot \left(\sin(x)\right)^2+C_2$

Greetings

EB

5. Nice work, Earboth!
. . That was the fourth method I had found