4

I am struggling with the integration of $$ \text{I} = \int_0^{\frac{\pi}{2}} \frac{x}{\cos(x)+\sin(x)} \mathrm dx$$ using complex analysis. I used the substitution $z=e^{ix} \rightarrow \mathrm dx = \frac{1}{iz}\mathrm dz$ and hence $\cos(x)+\sin(x)= ((z+\frac{1}{z})-i (z-\frac{1}{z}))$ because we have $ \cos(x)=\frac{1}{2}(e^{ix}+ e^{-ix})$, and $ \sin(x)=\frac{1}{2i}(e^{ix} -e^{-ix})$, and $x= -i \ln(z)$. However I am not successful to obtain the correct result when using real analysis, which gives $$\text{I}= \displaystyle\int_{0}^{\frac{\pi}{2}}\dfrac{x}{\sin\,x + \cos\,x}\,dx = 0.978959918 $$

Any idea how to calculate this integral using complex analysis and Cauchy integral theorem?

  • 1
    Is that how the result is given in your solution source? If so, that alone is very odd. – The Count Apr 26 '19 at 22:12
  • 1
    You only want to see complex analysis way? Because is quite easy using real analysis. – Zacky Apr 26 '19 at 22:15
  • Yes exactly. I know how to do it using real analysis. – Vito Versace Apr 26 '19 at 22:16
  • 4
    I see, are you allowed atleast to do some work before? For example: Let $\frac{\pi}{2}-x=t$ to get $$I=\int_0^\frac{\pi}{2} \frac{\frac{\pi}{2}-t}{\sin t+\cos t}dt$$ And now adding with the initial integral gives: $$2I=\frac{\pi}{2}\int_0^\frac{\pi}{2}\frac{1}{\sin x+\cos x}dx$$ – Zacky Apr 26 '19 at 22:17
  • 1
    I am allowed to do this. But I would like to see a way in which you don't use this identity and use simply complex analysis. – Vito Versace Apr 26 '19 at 22:20
  • 1
    I think what @Zacky is saying is that you have to deal with the $x$ somehow first since it is the only thing holding you back from just straightforwardly substituing $z=e^{\pi{}ix}$. – Μάρκος Καραμέρης Apr 26 '19 at 22:33
  • Even if we get rid of x, I still have problems with the complex analysis integration of the new function. In any case I would rather prefer to keep x and calculate with Cauchy theorem. – Vito Versace Apr 26 '19 at 23:24

4 Answers4

5

The simplified integral $(*)$ can indeed be evaluated with the residue theorem.

$$\begin{align*} I &= \int_0^\tfrac\pi2 \frac x{\cos x+\sin x} \, dx \\ &\stackrel{(*)}= \frac\pi4 \int_0^\tfrac\pi2 \frac{dx}{\cos x+\sin x} & x\to\frac\pi2-x;\text{ average}\\ &= \frac\pi4 \underbrace{\int_0^\infty \frac{dy}{(1+y)\sqrt{1+y^2}}}_{\mathcal I} & y=\tan x \end{align*}$$

Introduce the complex function

$$f(z) = \frac{\log z}{(1+z)\sqrt{1+z^2}} = \frac{\log\lvert z\rvert+i\arg z}{(1+z)\sqrt{\left\lvert1+z^2\right\rvert}\,\exp\left(\frac i2\left[\arg(z-i)+\arg(z+i)\right]\right)}$$

to be integrated along a positively oriented circular contour $\mathcal C$, deformed to avoid branch cuts taken along the positive real axis, such that $\arg z\in(0,2\pi)$; and along the rays $\pm i[1,\infty)$, such that $\arg(z-i)\in\left(-\dfrac{3\pi}2,\dfrac\pi2\right)$ and $\arg(z+i)\in\left(-\dfrac\pi2,\dfrac{3\pi}2\right)$.

plot of contour

$\mathcal C$ is comprised of small arcs (radius $\varepsilon>0$) encircling the branch points at $z\in\{0,\pm i\}$, chunks of a larger arc (radius $R\gg1$), and the multiple line segments that join them, which I'll denote by $A,B,C$ if following the path is takes us away from the origin, and $A',B',C'$ if they point toward it. The integrals along the arcs vanish in their respective limits $(\varepsilon\to0,R\to\infty)$. The remaining pieces' contributions are summarized and joined below.

$$\begin{align*} \int_A f(z)\,dz &\to \int_0^\infty \frac{\log x}{(1+x)\sqrt{1+x^2}} \, dx & z=x+i\varepsilon \\ \int_{A'} &\to \int_\infty^0 \frac{\log x+i2\pi}{(1+x)\sqrt{1+x^2}} \, dx & z=x-i\varepsilon \\ \int_B &\to \int_1^\infty \frac{\log\lvert ix\rvert+i\frac\pi2}{(1+ix)\sqrt{x^2-1}\exp\left(\frac i2\left[-\frac{3\pi}2+\frac\pi2\right]\right)} \, dx & z=-\varepsilon+ix\\ \int_{B'} &\to \int_\infty^1 \frac{\log\lvert ix\rvert+i\frac\pi2}{(1+ix)\sqrt{x^2-1}\exp\left(\frac i2\left[\frac\pi2+\frac\pi2\right]\right)} \, dx & z=\varepsilon+ix \\ \int_C &\to \int_1^\infty \frac{\log\lvert-ix\rvert+i\frac{3\pi}2}{(1-ix)\sqrt{x^2-1} \exp\left(\frac i2\left[-\frac\pi2-\frac\pi2\right]\right)} \, dx & z=\varepsilon-ix \\ \int_{C'} &\to \int_\infty^1 \frac{\log\lvert-ix\rvert+i\frac{3\pi}2}{(1-ix)\sqrt{x^2-1} \exp\left(\frac i2\left[-\frac\pi2+\frac{3\pi}2\right]\right)} \, dx & z=-\varepsilon-ix \\[2ex] \hline \int_{A\cup A'} &\to -i2\pi \, \mathcal I \\ \int_{B\cup B'} &\to -2 \int_1^\infty \frac{\log x+i\frac\pi2}{(1+ix)\sqrt{x^2-1}} \, dx \\ \int_{C\cup C'} &\to 2 \int_1^\infty \frac{\log x+i\frac{3\pi}2}{(1-ix)\sqrt{x^2-1}} \, dx \end{align*}$$

There's a simple pole at $z=-1$ with residue $\dfrac{i\pi}{\sqrt2}$. By the residue theorem, and further combining the preceding log-integrals, we have

$$\oint_{\mathcal C} f(z) \, dz = -i2\pi\,\mathcal I + 4i\,J_1+i2\pi\,J_2-4\pi\,J_3 \stackrel{(\star)}= -\sqrt2\,\pi^2$$

where each of

$$\begin{align*} J_1 &= \int_1^\infty \frac{x\log x}{\left(1+x^2\right)\sqrt{x^2-1}} \, dx \\ J_2 &= \int_1^\infty \frac{dx}{\left(1+x^2\right)\sqrt{x^2-1}} \\ J_3 &= \int_1^\infty \frac x{\left(1+x^2\right)\sqrt{x^2-1}} \, dx \end{align*}$$

are convergent and real-valued. We can ignore $J_3$ upon taking imaginary parts of both sides of $(\star)$:

$$\mathcal I = \frac2\pi J_1 + J_2 \implies I = \frac12 J_1 + \frac\pi4 J_2$$

$J_1$ can be computed as follows. (On the other hand, perhaps there's some shortcut to establishing $I=J_1$; if there is, I don't see it yet. Follow-up question)

$$\begin{align*} J_1 &= \int_0^\tfrac\pi2 \frac{\log(\csc y)}{1+\sin^2y}\,dy & x=\csc y \\ &= \int_0^\tfrac\pi2 \frac{\arctan\left(\sqrt2\,\tan y\right)}{\sqrt2\,\tan y} \, dy & \text{by parts} \\ &= \frac1{\sqrt2}K\left(\sqrt2\right) = \frac\pi{2\sqrt2}\log\left(1+\sqrt2\right) \end{align*}$$

where $K(a) := \displaystyle \int_0^\tfrac\pi2 \frac{\arctan(a\tan y)}{\tan y}\,dy \implies K'(a) = \int_0^\tfrac\pi2 \frac{dy}{1+a^2\tan^2y} = \frac\pi{2(1+a)}$.

$J_2$ is elementary,

$$J_2 \stackrel{x=\csc y}= \int_0^\tfrac\pi2 \frac{\sin y}{2-\cos^2y} \, dy = \frac1{\sqrt2} \log\left(1+\sqrt2\right)$$

so we can finally conclude that $I=\boxed{\dfrac\pi{2\sqrt2}\log\left(1+\sqrt2\right)}$.

user170231
  • 27,172
  • 2
    Nice approach (+1). Complex integration is really powerful tool! – Svyatoslav Jun 04 '25 at 03:51
  • 1
    Thanks @Svyatoslav, and again for teaching me how to use it! It's been one of my favorite things to apply, even if it doesn't always make for less work :) – user170231 Jun 04 '25 at 13:44
2

Here is a proof using complex analysis (CA), or sincerely said, complex numbers, to some force extend, it is all i could do in the direction of a solution using analytic functions and properties of them. There may be some reasons to try to solve this problem using CA, but this is (at least didactically) not a good example to involve it. Reasons:

  • Any proof in real analysis (RA) is one in complex analysis. In CA we also build primitives, and try to evaluate.
  • A proof in CA would be "veritable" only if we essentially use some main results from this field, for instance the residue theorem. But in this given case, it is hard to isolate some closed contour to integrate on it some function related to our integral. (The given integral, or the simpler one of constant$/(\cos t+\sin t)$ cannot be easily written as an integral over a closed contour.)
  • When the algorithmic, straightforward proof in RA is so simple, why do we complicate things to give a CA-solution with a different personality?!

Computations follow.


The given integral is $\newcommand{\arctan}{\operatorname{arctan}}$ $$ \begin{aligned} I &= \int_0^{\pi/2} \frac t{\cos t+\sin t}\; dt = \int_0^{\pi/2} \frac t{\sqrt 2(\cos (t-\pi/4)}\; dt \\ &\qquad\qquad\text{Substitution: }u=t-\pi/4\ , \\ &= \frac 1{\sqrt 2} \int_{-\pi/4}^{\pi/4} \frac {u+\pi/4}{\cos u}\; du \\ &= \frac 1{\sqrt 2} \int_{-\pi/4}^{\pi/4} \frac {\pi/4}{\cos u}\; du + \underbrace{ \frac 1{\sqrt 2} \int_{-\pi/4}^{\pi/4} \frac {u}{\cos u}\; du }_{=0\text{ odd function}} \\ &\qquad\text{(CA argument: integral on contur $-\pi/4\to\pi/4\to-\pi/4$)} \\ &= \frac 1{\sqrt 2}\cdot \frac\pi 4 \underbrace{ \int_{-\pi/4}^{\pi/4} \frac 1{\cos u}\; du}_{=:J\text{ (notation)}}\ , \end{aligned} $$ so it is enough to understand the integral $$ \begin{aligned} J&:= \int_{-\pi/4}^{\pi/4} \frac 1{\cos u}\; du = \int_{-\pi/4}^{\pi/4} \frac 1{\frac 12(e^{iu}+e^{-iu})}\; du \\ &\qquad\qquad\text{Substitution: }z=e^{iu}\ ,\ dz=ie^{iu}\; du=iz\; du \\ &= \int_{\exp-i\pi/4}^{\exp+i\pi/4} \frac 1{\frac 12\left(z+\frac 1z\right)}\; \frac 1{iz}\; dz \\ &= \frac 2i \int_{\exp-i\pi/4}^{\exp+i\pi/4} \frac 1{z^2+1}\; dz \\ &= \frac 2i \Big(\arctan e^{i\pi/4}-\arctan e^{-i\pi/4} \Big) \\ &= \frac 2i \arctan \frac {e^{i\pi/4}-e^{-i\pi/4}} {1+e^{i\pi/4}\cdot e^{-i\pi/4}} = \frac 2i \arctan \frac{\frac 1{\sqrt 2}(1+i)-\frac 1{\sqrt 2}(1-i)}{1+1} = \frac 2i \arctan \frac i{\sqrt 2} \\ &= \frac 2i \cdot i\log(1+\sqrt 2) =2\log(1+\sqrt2)\ . \end{aligned} $$ (The computation of the $\arctan$ of $i/\sqrt 2$ is possibly harder as solving the integral in RA... But our problem is the quick computation of an integral, so we substitute inside CA, write the primitive, compute the values of the primitive at the ends of the contour.)

Here we check the $\arctan$ value, write $a$ for $i\log(1+\sqrt 2)$ for short, then: $$ \tan a =\frac{\sin a}{\cos a} =\frac 1i\cdot \frac{e^{ia}-e^{-ia}}{e^{ia}+e^{-ia}} =\frac 1i\cdot \frac{1-e^{-2ia}}{1+e^{-2ia}} =\frac 1i\cdot \frac{1-(1+\sqrt2)^2}{1+(1+\sqrt2)^2} =\frac 1i\cdot \frac {-1}{\sqrt 2}=\frac i{\sqrt 2}\ . $$


An other way to proceed above is to write $$ \frac 1{z^2+1} =\frac 1{2i}\left(\frac 1{z-i}+\frac 1{z+i}\right)$$ and to use the $\log$-primitives (instead of the $\arctan$ primitive above). (This explains in part the value of the $\arctan$-computation.)


Alternatively, we could integrate $1/(z^2+1)$ on the closed contour $\gamma$ from $0$ radially to $\exp-i\pi/4$, then on the unit circle in trigonometric sense to $\exp-i\pi/4$, then radially to the starting point $0$. Now we are in real analysis, and compute primitives, take them in the end points, well, these are more or less the $\arctan$ values above, with the double insertion of the point $0$, these contribution cancel each other, so we come back to the argument above.


The above idea is sometimes good, when the two radial integrals can combine in a good manner. (E.g. when we integrate a sum of fractions $f\pm \bar f$, and when the obtained fraction, after building the product of the denominators, a real polynomial, and of the corresponding numerator, also real, ... so when this expression is very easy to be integrated. Too much to compute in this case.)


There is a related idea to use $w=z^{1/4}$ and rephrase the "sector contour" $\gamma$ above into a contour $0$ to $-1$ radially, then on the full unit circle to $-1$, then to $0$ back again. (Also, around $0$ draw a full small circle of radius $\epsilon$ when there is a pole in there.) This idea can be used when the function to be integrated has a pole in $0$ and the two radial integrals cancel each other. This is not the case in our case. No pole in zero after substituion, which may survive after passing to the limit $\epsilon\to 0$, no poles in the unit circle (or equivalently in the starting sector delimited by $\gamma$.


Just as a comparison, the proof in RA (so in particular, also in CA) $$ \int_{-\pi/4}^{+\pi/4}\frac 1{\cos u}\; du = \int_{-\pi/4}^{+\pi/4}\frac {\cos u}{\cos^2 u}\; du = \int_{-\pi/4}^{+\pi/4}\frac {\cos u}{1-\sin^2 u}\; du = \int_{-1/\sqrt 2}^{+1/\sqrt 2}\frac {1}{1-s^2}\; du = \log\frac{1+1/\sqrt 2}{1-1/\sqrt 2} = \log\frac{\sqrt 2+1}{\sqrt 2-1} = \log(\sqrt 2+1)^2 = 2\log(\sqrt 2+1)\ , $$ and no intermediary step was omitted.

dan_fulea
  • 38,874
  • Thanks a lot for your nice answer and effort. So it is basically not possible to find a closed contour on which one could integrate. This was actually what I wanted to know. Nevertheless it is still a nice solution. THANK YOU! – Vito Versace May 01 '19 at 04:02
1

By $z=e^{ix}$, $$I=\frac\pi4\int_0^{\frac\pi2}\frac{dx}{\cos x+\sin x}=\frac\pi{2(1+i)}\int_1^i\frac{dz}{z^2+i}.$$ Let $w=\exp(\frac{3\pi i}4)=\tfrac{i-1}{\sqrt2}$. $$I=\frac\pi{4(1+i)w}\int_1^i\left(\frac1{z-w}-\frac1{z+w}\right)=-\frac\pi{4\sqrt2}(\ln(i-w)-\ln(i+w)-\ln(1-w)+\ln(1+w))\\=-\frac\pi{4\sqrt2}\left(\ln(2-\sqrt2)-\ln(2+\sqrt2)\right)=\frac\pi{2\sqrt2}\ln(1+\sqrt2).$$

Bob Dobbs
  • 16,473
0

HINT

If we make the change of variable $y = \pi/2 - x$, one arrives at the integral: \begin{align*} I = \int_{0}^{\pi/2}\frac{x}{\cos(x) + \sin(x)}\mathrm{d}x = \frac{\pi}{2}\int_{0}^{\pi/2}\frac{\mathrm{d}y}{\cos(y) + \sin(y)} - I \end{align*} from whence we conclude that \begin{align*} I = \frac{\pi}{4}\int_{0}^{\pi/2}\frac{\mathrm{d}y}{\cos(y) + \sin(y)} = \frac{\pi}{4\sqrt{2}}\int_{0}^{\pi/2}\frac{\mathrm{d}y}{\sin(y + \pi/4)} \end{align*}

Can you take it from here?