# When can we apply the method of complexifying the integral.

Recently I was scrolling through YouTube, and saw the method of complexifying the integral https://m.youtube.com/watch?v=CpM1jJ0lob8. I tried some integrals out and it worked just fine.

However, I tried to take it up a notch, and tried finding.

$$\int \frac{e^x}{\mathrm{cos}x} dx$$

Which didn't work out. My guess was that it didn't work out because the function we are integrating is discontinuous at some points. So my question is under what circumstances can we apply the method of complexifying the integral?

My work:

$$=Re{\int \frac{e^x}{e^{ix}} dx}$$ $$=Re{\int e^{(1-i)x} dx}$$ $$=Re{\frac{e^{(1-i)x}}{1-i}}+c$$

With a little more algebra (and verified through wolphy I get):

$$\frac{1}{2}e^x(\mathrm{sin}x+\mathrm{cos}x)+c$$

Which looks incorrect because it is the same as when I evaluated:

$$\int e^x \mathrm{cos}x dx$$

• Can you show us the steps you took?
– kccu
Dec 24, 2015 at 3:12
• The first line is not right. Dec 24, 2015 at 3:33

The problem is in saying that $\frac{e^x}{\cos(x)}$ is the real part of $\frac{e^x}{e^{ix}}$. In general it is not true that $\text{Re}\left(\frac{z_1}{z_2}\right) = \frac{\text{Re}(z_1)}{\text{Re}(z_2)}$ for $z_1,z_2 \in \mathbb{C}$. Let's take a look at $\frac{e^x}{e^{ix}}$: \begin{align*} \frac{e^x}{e^{ix}} &= \frac{e^x}{\cos(x)+i\sin(x)}\\ &= \frac{e^x}{\cos(x)+i\sin(x)} \cdot \frac{\cos(x)-i\sin(x)}{\cos(x)-i\sin(x)}\\ &= \frac{e^x(\cos(x)-i\sin(x))}{\cos^2(x)+\sin^2(x)}\\ &=e^x(\cos(x)-i\sin(x)). \end{align*} So in fact $\text{Re}\left(\frac{e^x}{e^{ix}}\right)=e^x\cos(x)\neq \frac{e^x}{\cos(x)}$. Off the top of my head I can't think of how to recognize $\frac{e^x}{\cos(x)}$ as the real part of a complex function. That's not to say it can't be done, but I'm not sure how.

• Well, $\frac{e^x}{\cos(x)}$ is a complex function having $\frac{e^x}{\cos(x)}$ as a real part. Of course, I suppose the real question is "is it the real part of a complex function that would be easy to integrate" which this is not. Dec 24, 2015 at 4:06
• very nice .......+1 Dec 24, 2015 at 4:17

I've used this technique often, and I came up with it independently. Didn't know they were teaching at at MIT as "complexifying the integral", hehe. :)

The lecturer's method works for integrands of the form $k\cdot z$, where $k$ is a real expression and $z$ is a complex expression. This is because $\text{Re}(kz) = k\text{Re}(z)$, which is easy to show.

However, it doesn't work for expressions of the form $\frac{k}{z}$, since $\text{Re}(\frac kz) \neq \frac {k}{\text{Re}(z)}$, in general. In fact, $\text {Re}(\frac kz) = \frac{k}{|z|}\cdot \text {Re}(z)$.

I would suggest a more general way of "complexifying", by using:

$\cos x = \frac 12(e^{ix} + e^{-ix})$ and $\sin x = \frac {1}{2i}(e^{ix} - e^{-ix})$.

A little more algebra, but they always work out.

• Downvoter, care to explain why? Dec 24, 2015 at 6:15
• I tried to derive the formulas you suggested, I keep getting 1/2i for $sinx$, you sure that's right? Dec 26, 2015 at 1:03
• @AhmedS.Attaalla You're absolutely right. It was an unfortunate typo when I copied-pasted the Tex and forgot to amend it. Thanks for spotting it, and I've edited my answer. Anyway, the reason I mentioned those two transformations is that they will always be accurate, even when you apply this to functions that "mix up" real and imaginary parts like taking reciprocals and raising to powers. So they are more widely applicable than the simpler method shown in the video. Hope this helps. Dec 26, 2015 at 1:29

$e^x/\cos(x)$ does not have an elementary antiderivative. This can be shown using the Risch algorithm.

EDIT: The antiderivative can be expressed in terms of the Lerch Phi function:

$$i{{\rm e}^{ \left( 1-i \right) x}}{\it LerchPhi} \left( -{{\rm e}^{-2 \,ix}},1,1/2+i/2 \right)$$

where $${\it LerchPhi}(z,a,v) = \sum_{n=0}^\infty \dfrac{z^n}{(v+n)^a}$$