4

According to WolframAlpha, $$\int \frac1{\cosh x} dx=2\arctan(\tanh(\tfrac x2))+C$$ On the other hand, easily, $$\int \frac1{\cosh x} dx=2\int\frac{e^x}{(e^x)^2+1}dx=2\arctan(e^x)+C $$ I believe that my solution is correct. Does anybody see how WolframAlpha processed and found its solution?

Thanks.

Sebastiano
  • 7,649
Bob Dobbs
  • 10,988

4 Answers4

2

sometimes we get two results to the same problem (specially in integrals) mean this two results (or more) are related (or have common characteristics) and in integrals if you get the same results this mean that you have $$ f_1(x)+c_1=f_2(x)+c_2$$ for example lets show how to get the wolframs result we have $$ \cosh^2x+\sinh^2x=\cosh(2x)$$ So $$ \int \frac{1}{\cosh x}dx=\int \frac{1}{\cosh^2\left(\frac{x}{2}\right)+\sinh^2\left(\frac{x}{2}\right)}dx=\int \frac{1}{\cosh^2\left(\frac{x}{2}\right)+\sinh^2\left(\frac{x}{2}\right)}\frac{\text{sech}^2\left(\frac{x}{2}\right)}{\text{sech}^2\left(\frac{x}{2}\right)}dx$$ then $$ \int \frac{1}{\cosh x}dx=2\int \frac{\frac{1}{2}\text{sech}^2\left(\frac{x}{2}\right)}{1+\tanh^2\left(\frac{x}{2}\right)}dx=2\tan^{-1}\left(\tanh\left(\frac{x}{2}\right)\right)+c$$ and we can see that $$ 2\tan^{-1}\left(\tanh\left(\frac{x}{2}\right)\right)=2\tan^{-1}\left(\frac{e^x-1}{e^x+1}\right) $$ but here we have $$ \tan^{-1}\left(\frac{x+y}{1-xy}\right)=\tan^{-1}\left(x\right)+\tan^{-1}\left(y\right)+a$$ for $a\in \mathbb{R}$ where its value depends on values of $x$ and $y$ , now by putting $x\to e^x$ , $y\to-1$ we get $$2\tan^{-1}\left(\frac{e^x-1}{e^x+1}\right)=2\tan^{-1}\left(e^x\right)+2\tan^{-1}\left(-1\right)+2a=2\tan^{-1}\left(e^x\right)-\frac{\pi}{2}+2a$$ therefore $$ 2\tan^{-1}\left(\tanh\left(\frac{x}{2}\right)\right)=2\tan^{-1}\left(e^x\right)-\frac{\pi}{2}+2a $$ which mean its same result So, we can say

$$ \int \frac{1}{\cosh x}dx=2\tan^{-1}\left(\tanh\left(\frac{x}{2}\right)\right)+c=2\tan^{-1}\left(e^x\right)+c $$

Faoler
  • 1,267
2

For any $\;x\in\Bbb R\;$ it results that

$\begin{align}\arctan\left[\tanh\left(\dfrac x2\right)\right]&=\arctan\left(\dfrac{e^{\frac x2}-e^{-\frac x2}}{e^{\frac x2}+e^{-\frac x2}}\right)=\\[3pt]&\!\!\!\!\!\!\!\!\!\!\!\!\!\!=\arctan\left(\dfrac{e^x-1}{e^x+1}\right)=\\[3pt]&\!\!\!\!\!\!\!\!\!\!\!\!\!\!=\arctan\left[\dfrac{\tan(\arctan e^x)-\tan\left(\frac\pi4\right)}{1+\tan(\arctan e^x)\!\cdot\!\tan\left(\frac\pi4\right)}\right]=\\[3pt]&\!\!\!\!\!\!\!\!\!\!\!\!\!\!=\arctan\left[\tan\left(\arctan\left(e^x\right)-\dfrac\pi4\right)\right]=\\[3pt]&\!\!\!\!\!\!\!\!\!\!\!\!\!\!\overset{\color{blue}{(*)}}{=}\arctan\left(e^x\right)-\dfrac\pi4\;.\end{align}$

The last equality $\,(*)\,$ is a conseguence of the fact that

$\arctan\left(e^x\right)\!-\!\dfrac\pi4\in\left(-\dfrac\pi4,\dfrac\pi4\right)\subseteq\left(-\dfrac\pi2,\dfrac\pi2\right)\quad\forall\,x\in\Bbb R$

and the function tangent is invertible on $\left(-\dfrac\pi2,\dfrac\pi2\right).$

Since $\;\arctan\left[\tanh\left(\dfrac x2\right)\right]\!=\!\arctan\left(e^x\right)\!-\!\dfrac\pi4\;$ for any $\,x\in\Bbb R$

it follows that OP’s solution is equal to WolframAlpha’s one.

Angelo
  • 12,328
1

We need to find a function $f=f(x)$ such that $$\arctan e^x-\arctan f=\text{constant}.$$ Taking tangent of both sides, we have $$\frac{e^x-f}{1+e^xf}=\text{constant}.$$ Setting constant to $1$ we find $$f=\frac{e^x-1}{e^x+1}=\tanh(\tfrac x2).$$

Bob Dobbs
  • 10,988
0

$$\int \frac{1}{\cosh x} \, dx$$

Being $\cosh x = \frac{e^x + e^{-x}}{2}$ rewrite the previous integral:

$$\int \frac{1}{\frac{e^x + e^{-x}}{2}} \, dx$$

Multiply the numerator and denominator by $2$:

$$\int \frac{2}{e^x + e^{-x}} \, dx $$

$$\int \frac{2e^x}{e^{2x} + 1} \, dx \tag 1$$

Let $u = e^x$, then $du = e^x \, dx$. Thus from the $(1)$

$$ 2\int \frac{1}{u^2 + 1} \, du= 2\arctan(u) + C=2\arctan(e^x)+C$$

Sebastiano
  • 7,649