41

My way to solve this integral. I wonder is there another way to solve it as it's very long for me.

$$\int_{0}^{\pi}\frac{1-\sin (x)}{\sin (x)+1}dx$$

Let $$u=\tan (\frac{x}{2})$$ $$du=\frac{1}{2}\sec ^2(\frac{x}{2})dx $$

By Weierstrass Substitution

$$\sin (x)=\frac{2u}{u^2+1}$$

$$\cos (x)=\frac{1-u^2}{u^2+1}$$

$$dx=\frac{2du}{u^2+1}$$

$$=\int_{0}^{\infty }\frac{2(1-\frac{2u}{u^2+1})}{(u^2+1)(\frac{2u}{u^2+1}+1)}du$$

$$=\int_{0}^{\infty }\frac{2(u-1)^2}{u^4+2u^3+2u^2+2u+1}du $$

$$=2\int_{0}^{\infty }\frac{(u-1)^2}{u^4+2u^3+2u^2+2u+1}du $$

$$=2\int_{0}^{\infty }\frac{(u-1)^2}{(u+1)^2(u^2+1)}du $$

$$=2\int_{0}^{\infty }(\frac{2}{(u+1)^2}-\frac{1}{u^2+1})du $$

$$=-2\int_{0}^{\infty }\frac{1}{u^2+1}du+4\int_{0}^{\infty}\frac{1}{(u+1)^2}du $$

$$\lim_{b\rightarrow \infty }\left | (-2\tan^{-1}(u)) \right |_{0}^{b}+4\int_{0}^{\infty}\frac{1}{(u+1)^2}du$$

$$=(\lim_{b\rightarrow \infty}-2\tan^{-1}(b))+4\int_{0}^{\infty}\frac{1}{(u+1)^2}du$$

$$=-\pi+4\int_{0}^{\infty}\frac{1}{(u+1)^2}du$$

Let $$s=u+1$$

$$ds=du$$

$$=-\pi+4\int_{1}^{\infty}\frac{1}{s^2}ds$$

$$=-\pi+\lim_{b\rightarrow \infty}\left | (-\frac{4}{s}) \right |_{1}^{b}$$

$$=-\pi+(\lim_{b\rightarrow \infty} -\frac{4}{b}) +4$$

$$=4-\pi$$

$$\approx 0.85841$$

Quanto
  • 120,125
Mathxx
  • 8,468
  • 2
    I think multiplying top and bottom by bottom's conjugate was another way to proceed to get the integral all pretty like. – randomgirl Mar 17 '15 at 17:17
  • 1
    You might not appreciate this but, now that you did all that work, you can just use the fundamental theorem of calculus to prove the result. – Zach466920 Mar 17 '15 at 17:18
  • @Zach466920, it seems to me that Mathxx is using FTC (among other things, to justify $u$-substitutions and to evaluate the integral of $1/s^2$). What shorter usage of it did you have in mind? – LSpice Mar 17 '15 at 18:14
  • @Jade NB the fundamental theorem states that the derivative is the inverse of integration and vice versa. So in theory if the derivative of a function F(x) equals the integrand. F(x) is the integral, no need for advanced techniques. In other words, it can formalize a guess for an integral. – Zach466920 Mar 17 '15 at 19:19
  • @Zach466920, but, unless you are proposing the answer "$F(\pi) - F(0)$, where $F$ is an anti-derivative of $x \mapsto (1 - \sin(x))/(1 + \sin(x))$" (which seems hardly likely to satisfy, and certainly doesn't make it clear that the numerical value is $4 - \pi$), how does that help? – LSpice Mar 17 '15 at 20:18
  • Op splits the integral into pieces at some point, you'd just apply the fundamental theorem to each piece. You're right, you only prove the anti-derivative, however there are two fundamental theorems, and the second one says that indefinite integration and definite integration are related. Keep in mind that either need the F(x), the anti-derivative, from the start, or you need to be able to guess it. I was only saying that sense Op has a result, Op doesn't need to bother proving the integration in a roundabout way, he can just use the amazing fundamental theorems of calculus. – Zach466920 Mar 17 '15 at 20:29
  • @Zach466920 Can you explain what are you trying to solve by fundamental theorems of calculus ? I don't understand. Thanks in advance. – Mathxx Mar 18 '15 at 00:55
  • 1
    @Zach466920 I think the main thing OP is looking for is a better way to find the anti-derivative than using the Weierstrass Substitution. We all agree that substituting the limits to find the definite integral is easy once you've gotten the anti-derivative. – Teepeemm Mar 18 '15 at 17:43
  • I know that's why I said he might not appreciate it – Zach466920 Mar 18 '15 at 17:51

16 Answers16

68

Substitute $x=\pi/2-2t$ so the integral becomes $$ -2\int_{\pi/4}^{-\pi/4}\frac{1-\cos 2t}{1+\cos 2t}\,dt= 2\int_{-\pi/4}^{\pi/4}\frac{1-\cos^2t}{\cos^2t}\,dt =2\Bigl[\tan t - t\Bigr]_{-\pi/4}^{\pi/4} $$

egreg
  • 244,946
26

First use partial fractions to get rid of the sine in the numerator: $$ \int_0^{\pi} \frac{1-\sin{x}-1+1}{1+\sin{x}} \, dx = \int_0^{\pi} \left( \frac{2}{1+\sin{x}} - 1 \right) \, dx = -\pi + \int_0^{\pi} \frac{2 \, dx}{1+\sin{x}}. $$ We have the identity $$ 1+\sin{x} = 2\sin^2{\left( \frac{x}{2} + \frac{\pi}{4} \right)} $$ (from $\cos{2\theta}=1-2\sin^2{\theta}$ and $\sin{\theta}=-\cos{(\theta+\pi/2)}$), so the remaining integral is $$ \int_0^{\pi} \csc^2{\left( \frac{x}{2} + \frac{\pi}{4} \right)} \, dx = \left[ -2 \cot{\left( \frac{x}{2} + \frac{\pi}{4} \right)} \right]_0^{\pi} = -2(-1-1) = 4 $$

Nicky Hekster
  • 52,147
Chappers
  • 69,099
  • 5
    I wouldn't call that 'partial fractions' (which usually implies a factorisation of the denominator) so much as just 'fraction arithmetic'. – LSpice Mar 17 '15 at 18:13
  • I suppose, although it's listed under the same heading in my brain. Not sure it has a specific name other than something like "turning into a proper fraction". – Chappers Mar 17 '15 at 20:10
  • 1
    I think that 'proper fraction' itself has little meaning outside the setting of numeric fractions (i.e., elements of $\mathbb Q$) or, maybe, fractions with numerator and denominator drawn from a Euclidean domain (like $\mathbb Z$ or a polynomial ring). I would call your second fraction 'proper' in comparison to the first only in the sense that it allows one to compute the integral more easily. (Anyway, despite all the space I've just taken, the computation, which is certainly good, is more important than the specific terms used to describe it!) – LSpice Mar 17 '15 at 20:20
  • 2
    There's a fair amount on the Internet about "proper rational functions", which are elements $f/g$, $f,g \in k[X]$, $g \neq 0$ with $\deg{f}<\deg{g}$. That's probably equivalent to what I was remembering from my school algebra. – Chappers Mar 17 '15 at 21:29
17

Multiply numerator and denominator by $1 - \sin x$. So that $\displaystyle\int_0^\pi \dfrac{1-\sin x}{1+\sin x} \cdot \dfrac{1-\sin x}{1-\sin x}dx $

$$ = \displaystyle\int_0^\pi \dfrac{1-2\sin x+ \sin^2x}{\cos^2x}dx = \int_0^\pi \sec^2x - 2\dfrac{\sin x}{\cos^2x} + \tan^2x dx$$

We know that $\tan^2x + 1 = \sec^2x$. So the integral would look like: $$= \int_0^\pi 2\sec^2x -1 - 2\dfrac{\sin x}{\cos^2x}dx$$

We know the integral of $\sec^2x$ is just $\tan x$, and the last integrand can be solved by letting $u=\cos x$.

cgo
  • 1,970
7

Hint: Note that by symmetry our integral is twice the integral from $0$ to $\pi/2$. Then by symmetry replace $\sin x$ by $\cos x$. Then use the identities $\cos x=2\cos^2 (x/2)-1=1-2\sin^2(x/2)$.

André Nicolas
  • 514,336
5

\begin{align} A &= \int_{0}^{\pi}\left(\:\frac{1\:-\:\sin (x)}{\sin (x)\:+\:1}\:\right)dx \\ F(x) &= \int\left(\:\frac{1\:-\:\sin (x)}{\sin(x)\:+\:1 }\cdot\frac{\sin(x)\:-\:1}{\sin (x)\:-\:1 }\:\right)dx \\ &= \int\left(\:\frac{ -\sin^2(x) + 2\cdot sin(x)-1}{\sin^2(x)\:-\:1 }\:\right)dx \\ &= \int\left(\:\frac{ -(\sin^2(x) - 2\cdot sin(x)+1)}{-(1-\sin^2(x)) }\:\right)dx \\ &= \int\left(\:\frac{ (\sin^2(x) - 2\cdot sin(x)+1)}{(1-\sin^2(x)) }\:\right)dx \\ &= \int\left(\:\frac{\sin^2(x) - 2\cdot sin(x)+1}{\cos^2(x) }\:\right)dx \\ &= \int\left(\:\frac{\sin^2(x)}{\cos^2(x)}-\frac{ 2\cdot sin(x)}{\cos^2(x)}+\frac{1}{\cos^2(x)}\:\right)dx \\ &= \int\left(\:\frac{\sin^2(x)}{\cos^2(x)}\right)dx-\int\left(\frac{2\cdot sin(x)}{\cos^2(x)}\right)dx+\int\left(\frac{1}{\cos^2(x)}\:\right)dx \\ F(x) &= \tan(x) - x - 2\cdot\sec(x) + \tan(x)\\ A &= F(\pi) - F(0)\\ F(\pi) - F(0) &= (\tan(\pi) - \pi - 2\cdot\sec(\pi) + \tan(\pi))-(\tan(0) - 0 - 2\cdot\sec(0) + \tan(0))\\ &= (0 - \pi - 2\cdot-1 + 0)-(0 - 0 - 2\cdot1 + 0)\\ &= (-\pi + 2)-(-2)\\ &= -\pi + 2+2\\ &= 4-\pi\\ \end{align}

redthumb
  • 511
4

The question asked "is there another way", so here's another one. Start by removing the trig from the numerator:

$$ \int_0^{\pi} \frac{1-\sin{x}}{1+\sin{x}} \, \mathrm{d}x = \int_0^{\pi} \frac{2 - (1 +\sin{x})}{1+\sin{x}} \, \mathrm{d}x = \int_0^{\pi} \left( \frac{2}{1+\sin{x}} - 1 \right) \, \mathrm{d}x = -\pi + \int_0^{\pi} \frac{2 \, \mathrm{d}x}{1+\sin{x}} $$

There are many ways to solve this but I would like to demonstrate the substitution $u = 1 + \sin x$. It would be much more convenient if the limits ran from $0$ to $\frac{\pi}{2}$, so that $x = \sin^{-1} (u-1)$ is a continuous, monotonic function from $[1,2]$ to $[0,\frac{\pi}{2}]$, and also because $\cos x$ and $\sin x$ are both positive for $0 \leq x \leq \frac{\pi}{2}$. The latter property is often useful so we can write $\cos x=\sqrt{1-\sin^2 x}$ and $\sin x=\sqrt{1-\cos^2 x}$. Fortunately symmetry considerations allow a change of limits:

$$\int_0^{\pi} \frac{2 \, \mathrm{d}x}{1+\sin{x}} = \int_0^{\pi/2} \frac{4 \, \mathrm{d}x}{1+\sin{x}}$$

We have $\frac{\mathrm{d}u}{\mathrm{d}x} = \cos x = \sqrt{1-\sin^2 x} = \sqrt{1-(u-1)^2} = \sqrt{2u - u^2}$ so the integral becomes:

$$\int_0^{\pi/2} \frac{4 \, \mathrm{d}x}{1+\sin{x}} = \int_1^2 \frac{4 \, \mathrm{d}u}{u \sqrt{2u - u^2}} = \int_1^2 \frac{4 \, \mathrm{d}u}{u \sqrt{-u(u-2)}}$$

This might look fearsome but is actually very amenable to the third Euler substitution, since we have a factorised quadratic expression inside the square root. The computation is very similar to this answer. In general the substitution is $\sqrt{au^2 + bu + c} = \sqrt{a(u-\alpha)(u-\beta)} = (u-\alpha)t$ which gives $u = \frac{a\beta-\alpha t^2}{a-t^2}$; in our case we can take $a=-1$, $b=2$, $c=0$, $\alpha=0$, and $\beta=2$ with $\sqrt{-u(u-2)} = ut$.

Since $u=\frac{(-1)(2)-0t^2}{-1-t^2}=2(t^2+1)^{-1}$ we obtain $\frac{\mathrm{d}u}{\mathrm{d}t} = -4t(t^2+1)^{-2}$ and to change the limits we set $t=\frac{\sqrt{-u(u-2)}}{u} = \sqrt{\frac{2-u}{u}}$. The remaining integral becomes:

$$\int_1^2 \frac{4 \, \mathrm{d}u}{u \sqrt{-u(u-2)}} = \int_1^0 \frac{4 (-4t)(t^2+1)^{-2} \, \mathrm{d}t}{u^2 t} = \int_0^1 \frac{4 (4t)(t^2+1)^{-2} \, \mathrm{d}t}{4(t^2+1)^{-2} t} = \int_0^1 4 \, \mathrm{d}t = 4$$

This was not the most straightforward way to find the result $4 - \pi$, but I just wanted to draw out the similarity between this integral and one the original poster had asked about before (the main differences being the trig in the numerator - which is easily removed - and the limits).

Silverfish
  • 1,871
4

Contour integration is quite a good idea in this case. On the unit circle, we have

$$z=e^{ix}=\cos x + i \sin x$$ and therefore $$\sin x=\frac{z-z^{-1}}{2i}$$ and $$dz=iz\,dx$$ Substitution makes the integral

$$I=\int_C \frac{1}{zi}\frac{-z^2+2iz+1}{z^2+2iz-1}dz=-\int_C\frac{1}{zi}\frac{(z-i)^2}{(z+i)^2}dz=$$ $$=i\int_C\frac{1}{z}\left(\frac{z^2-1-2zi}{z^2+1}\right)^2dz$$ where the integration contour $C$ is the upper half of the unit arc (clockwise). Now you can consider integration around the upper half of the unit disc. The integration splits symbolically as

$$\text{residue}=\int_{-1}^1+\int_C$$ The residue unfortunately lies directly on the integration path, at $z=0$, and is equal to $\operatorname{Res}=i$. As the path is straight at the residue, you can take the Cauchy principal value of the integral and use half the residue:

$$I=\frac12 2\pi i (i)-i\int_{-1}^1 \frac{1}{z}\left(\frac{z^2-1-2zi}{z^2+1}\right)^2dz$$ $$=-\pi-i\int_{-1}^1 \frac{1}{z}\left(\frac{(z^2-1)^2-4z^2-4zi(z^2-1)}{(z^2+1)^2}\right)dz$$ We keep only the even terms under the integral (this is the "Cauchy principal value" step): $$I=-\pi-4\int_{-1}^1 \frac{(z^2-1)}{(z^2+1)^2}dz \quad (*)$$ $$I=-\pi-4\int_{-1}^1 \left(\frac{1}{z^2+1}-\frac{2}{(z^2+1)^2}\right)dz$$ These integrals are elementary (or tabulated in the case of the last term) and lead to the result $$I=-\pi-4(\pi/2-2\cdot 1/2(1+\pi/2)))=4-\pi$$

Essentially, the only integral to compute is the one marked $(*)$, the rest is just simplification of rational functions. The integral seems to be more trivial than it looks (splitting it as I have is apparently not the most optimal solution, as half of it cancels out). If anyone notices a clever trick to get $\int (x^2-1)/(1+x^2)^2dx=-x/(1+x^2)$ (apart from exclaiming "it's obvious now" when you see the result), let me know in the comments.

orion
  • 16,154
  • 1
  • 34
  • 45
  • Probably the simplest way is to split into the fractions $\frac{2x^2}{(1+x^2)^2}-\frac{1}{1+x^2}$, although this isn't very intuitive. As a rule, these rational functions tend not to yield easily: probably the safest way is to split off the $x^2$ term and integrate it by parts, which produces an integral that cancels the other one. – Chappers Mar 18 '15 at 10:36
4

Yet another way. Using $u=\tan(x)$, we get $$ \begin{align} \int\frac{1-\sin(x)}{1+\sin(x)}\,\mathrm{d}x &=\int\lower{2pt}{\frac{1-\frac{u}{\sqrt{1+u^2}}}{1+\frac{u}{\sqrt{1+u^2}}}\frac{\mathrm{d}u}{1+u^2}}\\ &=\int\left(1-\raise{2pt}{\frac{u}{\sqrt{1+u^2}}}\right)^{\!\!2}\,\mathrm{d}u\\ &=\int\left(2-\raise{2pt}{\frac{2u}{\sqrt{1+u^2}}}-\frac1{1+u^2}\right)\,\mathrm{d}u\\[6pt] &=2u-2\sqrt{1+u^2}-\arctan(u)+C\\[14pt] &=2\tan(x)-2\sec(x)-x+C \end{align} $$ Therefore, $$ \begin{align} \int_0^\pi\frac{1-\sin(x)}{1+\sin(x)}\,\mathrm{d}x &=(2-\pi)-(-2)\\[6pt] &=4-\pi \end{align} $$

robjohn
  • 353,833
4

$\big[$Another (standard) method$\big]$

When we have integrals of the form: $\displaystyle \int \frac{dx}{a+b\sin (x) + c\cos (x)} $ we can perform the substitution: $t=\tan (x/2)$. Then, we have: $\displaystyle \sin(x) = \frac{2t}{1+t^2} $ , $\displaystyle \cos (x) = \frac{1-t^2}{1+t^2} $ , $\displaystyle dx= \frac{2dt}{1+t^2}$.

First we must remove the sine term from the numerator.

$\displaystyle \int_0^{\pi} \frac{1-\sin(x) -1 + 1}{\sin(x) + 1} dx = \int_0^{\pi} \frac{2}{\sin(x)+1} -1 dx$

Now we substitute. Also @$x=0 \rightarrow t=0$ and @$x=\pi \rightarrow t=\infty$. Thus:

$\displaystyle \int_0^{\infty} \Bigg( \frac{2}{\frac{2t}{1+t^2} +1} -1 \Bigg) \cdot \frac{2}{1+t^2} dt = \int_0^{\infty} \frac{4}{2t+1+t^2} - \frac{2}{1+t^2} dt = $

$\displaystyle = \int_0^{\infty} \frac{4}{(t+1)^2} dt - 2\tan^{-1}(t)\big|_0^{\infty} = 4 \left[ -\frac{1}{t+1} \right]_0^{\infty} -2\frac{\pi}{2} = -4 \left( \frac{1}{\infty} - \frac{1}{0+1} \right) -\pi = 4-\pi $

KeyC0de
  • 1,282
2

Substitute $t=\sin x:$

$$\begin{align}\int_0^\pi\frac{1-\sin x}{1+\sin x}\mathrm dx&=-\pi+4\int_0^1\frac{\mathrm dt}{(1+t)^\frac32(1-t)^\frac12}\\&\overset{v=\frac{1-t}{1+t}}{=}-\pi+2\int_0^1\frac{\mathrm dv}{\sqrt v}\\&=4-\pi\end{align}$$

Integreek
  • 8,530
1

With a slight modification to the typical tangent half-angle substitution, the partial fraction expansion can be traded for a more immediate one.

$$\begin{align*} & \int_0^\pi \frac{1-\sin x}{1+\sin x} \, dx \\ &= 2 \int_0^\tfrac\pi2 \frac{1-\sin x}{1+\sin x} \, dx & x\to\pi-x\text{ for }x\in\left[\frac\pi2,\pi\right] \\ &= 4 \int_0^1 \frac{y^2}{1+y^2} \, dy & y=\tan\left(\frac\pi4-\frac x2\right) \\ &= 4 \int_0^1 \left(1-\frac1{1+y^2}\right) \, dy \\ &= 4(1-\arctan1)=\boxed{4-\pi} \end{align*}$$

This is also equivalent to enforcing $u=\dfrac{1-y}{1+y}$ in OP's integral.

user170231
  • 25,320
1

$$ \begin{aligned} \int_0^\pi \frac{1-\sin x}{\sin x+1} d x&=2 \int_0^{\frac{\pi}{2}} \frac{1-\sin x}{\sin x+1} d x \\ & =2 \int_0^{\frac{\pi}{2}} \frac{1-\cos x}{\cos x+1} d x \\ & =2 \int_0^{\frac{\pi}{2}} \frac{1-2 \cos x+1-\sin ^2 x}{\sin ^2 x} d x \\ & =2\left(2 \int_0^{\frac{\pi}{2}} \csc ^2 x d x-2 \int_0^{\frac{\pi}{2}} \csc x \cot x d x-\frac{\pi}{2}\right) \\ & =4-\pi \end{aligned}$$

Lai
  • 31,615
1

$$\begin{align}\int_0^\pi\frac{1-\sin x}{1+\sin x}\mathrm dx&\overset{(*)}{=}-\pi+4\int_0^\frac\pi2\frac{\mathrm dx}{1+\sin x}\\&=-\pi+4\int_0^\frac\pi2\frac{1-\sin x}{\cos^2x}\mathrm dx\\&=-\pi+4[\tan x-\sec x]_0^\frac\pi2\\&\overset{v=\tan x}{=}-\pi+4+4\lim_{v\to\infty}\frac1{\sqrt{v^2+1}+v}\\&=4-\pi\end{align}$$

Explanation of $(*)$:

$$\int_0^{2a}f(x)\mathrm dx=\int_0^af(x)+f(2a-x)\mathrm dx$$

Integreek
  • 8,530
0

Substitute $v=\frac1{1+\sin x}$:

$$\begin{align}\int_0^\pi\frac{1-\sin x}{1+\sin x}\mathrm dx&=2 \int_0^\frac\pi2\frac{1-\sin x}{1+\sin x}\mathrm dx\\&=2\int_\frac12^1\frac{\sqrt{2v-1}}v\mathrm dv\\&=4\sqrt{2v-1}-2\sin^{-1}\left(1-\frac1v\right)\Bigg|_\frac12^1\\&=4-\pi\end{align}$$

Integreek
  • 8,530
0

I'll sugest more tricky approach

First of all :

$ 1 \pm \sin x = \overbrace{ \sin ^2 \frac{x}{2} + \cos^2 \frac{x}{2} }^1 \pm 2 \sin \frac{x}{2}\cdot \cos \frac{x}{2} = (\sin \frac{x}{2} \pm \cos \frac{x}{2} )^2$

Second observation

$\sin \frac{x}{2} + \cos \frac{x}{2} = \sqrt{2}\cos ( \frac{x}{2} - \frac{\pi}{4} ) $

$\sin \frac{x}{2} - \cos \frac{x}{2} = \sqrt{2}\sin ( \frac{x}{2} - \frac{\pi}{4} ) $

Thus

$ \displaystyle \int^{\pi}_0\frac{1-\sin (x)}{\sin (x)+1}dx = \int^{\pi}_0 \left ( \frac{\sin \frac{x}{2} - \cos \frac{x}{2} }{\sin \frac{x}{2} + \cos \frac{x}{2} } \right )^2 dx = \int^{\pi}_0 \left ( \frac{\sqrt{2}\sin ( \frac{x}{2} - \frac{\pi}{4}) }{\sqrt{2}\cos ( \frac{x}{2} - \frac{\pi}{4})} \right )^2 dx = $

$ = \displaystyle \int_{0}^{\pi} \tan^2\left(\frac{x}{2} - \frac{\pi}{4}\right) dx = \int_{0}^{\pi} \left[\sec^2\left(\frac{x}{2} - \frac{\pi}{4}\right) - 1\right] dx $

$\displaystyle = \int_{0}^{\pi} \sec^2\left(\frac{x}{2} - \frac{\pi}{4}\right) dx - \int_{0}^{\pi} 1 \, dx$

$\displaystyle = 2 \tan\left(\frac{x}{2} - \frac{\pi}{4}\right) \Big|_{0}^{\pi} - x \Big|_{0}^{\pi} = 2\left[\tan\left(\frac{\pi}{2} - \frac{\pi}{4}\right) - \tan\left(-\frac{\pi}{4}\right)\right] - \pi $

$= \displaystyle 2\left[\tan\left(\frac{\pi}{4}\right) - (-1)\right] - \pi \\ = 2(1 + 1) - \pi \\ = 4 - \pi$

0

Using $\sin x = \frac{e^{ix} - e^{-ix}}{2i}$,

$$I = \int_{0}^{\pi}\frac{2i - e^{ix} + e^{-ix}}{e^{ix} - e^{-ix}+2i} ~dx$$

Let $u = e^{ix} \implies x = -i\log(u) \implies dx = \frac{-i}{u} ~du$.

$$I = \int_{1}^{-1}\frac{2i - u + \frac{1}{u}}{u - \frac{1}{u} + 2i}\frac{-i}{u} ~du$$ $$= -i\int_{-1}^{1}\frac{u^2 - 2iu - 1}{u(u^2 + 2iu - 1)} ~du$$

But the integrand is now discontinuous at $u = 0$, so let's split it up.

$$I = -i\int_{-1}^{0}\frac{u^2 - 2iu - 1}{u(u^2 + 2iu - 1)} ~du -i\int_{0}^{1}\frac{u^2 - 2iu - 1}{u(u^2 + 2iu - 1)} ~du$$

Let $v = -u$ in the first integral, and $v = u$ in the second.

$$I = -i\int_{1}^{0}\frac{(-v)^2 - 2i(-v) - 1}{-v((-v)^2 + 2i(-v) - 1)} (-dv) -i\int_{0}^{1}\frac{v^2 - 2iv - 1}{v(v^2 + 2iv - 1)} ~dv$$ $$= i\int_{0}^{1}\frac{v^2 + 2iv - 1}{v(v^2 - 2iv - 1)} ~dv -i\int_{0}^{1}\frac{v^2 - 2iv - 1}{v(v^2 + 2iv - 1)} ~dv$$ $$= i\int_{0}^{1}\frac{(v^2 + 2iv - 1)^2 - (v^2 - 2iv - 1)^2}{v(v^2 - 2iv - 1)(v^2 + 2iv - 1)} ~dv$$ $$= i\int_{0}^{1}\frac{(v+i)^4 - (v-i)^4}{v(v - i)^2(v + i)^2} ~dv$$ $$= i\int_{0}^{1}\frac{(v^4 + 4iv^3 - 6v^2 - 4iv + 1) - (v^4 - 4iv^3 - 6v^2 + 4iv + 1)}{v(v^2 + 1)^2} ~dv$$ $$= i\int_{0}^{1}\frac{8iv^3 - 8iv}{v(v^2 + 1)^2} ~dv$$ $$= -8\int_{0}^{1}\frac{v^2 - 1}{(v^2 + 1)^2} ~dv$$

This eliminates the $i$'s, but let's bring them back to do partial fraction decomposition.

$$I = -8\int_{0}^{1} \left(\frac{1}{2(v+i)^2} + \frac{1}{2(v-i)^2}\right) ~dv$$ $$= -4\int_{0}^{1} \frac{1}{(v+i)^2} ~dv - 4\int_{0}^{1} \frac{1}{(v-i)^2} ~dv$$

In the first integral, let $w = v + i$. In the second integral, let $w = v - i$.

$$I = -4\int_{i}^{1+i} \frac{1}{w^2} ~dw - 4\int_{-i}^{1-i} \frac{1}{w^2} ~dw$$ $$= -4[-\frac{1}{w}]_{i}^{1+i} - 4[-\frac{1}{w}]_{-i}^{1-i}$$ $$= 4\left(\frac{1}{i+1} - \frac{1}{i}\right) + 4\left(\frac{1}{1-i} - \frac{1}{-i} \right)$$ $$= \frac{4(1-i)}{2} - \frac{4}{i} + \frac{4(1+i)}{2} + \frac{4}{i}$$ $$= 2 - 2i + 2 + 2i$$ $$= \boxed{4}$$

Dan
  • 18,262