# Why does integral and the imaginary part commute?

I have many a times encountered (and used myself) the following technique:

$$\int \sin x \mathrm{d}x = \int \operatorname{Im}(e^{ix}) \mathrm{d}x = \operatorname{Im} \left( \int e^{ix} \mathrm{d}x \right) = \operatorname{Im}( -ie^{ix}) + C = -\cos x + C$$

Not only in this case, but I've used this kind of transform many a times, instinctively, to solve many of those monster trig integrals (and it works like a miracle) but never justified it.

Why and how is this interchange of integral and imaginary part justified?

At first, I thought it might be always true that we can do such a type of interchange anywhere, so, I tried the following: $\operatorname{Im}(f(z)) = f(\operatorname{Im}(z))$. But this is clearly not true, as the LHS is always real but RHS can be, possibly, complex too.

Second thoughts. I realized that we are dealing with operators here and not functions really. Both integral and imaginary parts are operators. So we have a composition of operators and we are willing to check when do these operators commute? I couldn't really make out any further conclusions from here and am stuck with the following questions:

When and why is the following true: $\int \operatorname{Im}(f(z)) \mathrm{d}z= \operatorname{Im} \left( \int f(z) \mathrm{d}z \right)$? (Provided that $f$ is integrable)

Is it always true? (Because like I've used it so many times and never found any counter example)

Edit : I am unfamiliar with integration of complex-valued functions but what I have in mind is that while doing such a thing, I tend to think of $i$ as just as some constant (Ah! I hope this doesn't sounds like really weird), as I stated in the example in the beginning. To be more precise, I have something of like this in my mind: because a complex-valued function $f(z)$ can be thought of as $f(z) = f(x+iy) = u(x,y) + iv(x,y)$ where $u$ and $v$ are real-valued functions and we can now use our definition for integration of real-valued functions as $$\int f(z) \mathrm{d}z = \int (u(x,y) + iv(x,y)) \mathrm{d}(x+iy) = \left(\int u\mathrm{d}x - \int v\mathrm{d}y\right) +i\left(\int v\mathrm{d}x + \int u\mathrm{d}y\right)$$

• What is your definition of $\int f(x) dx$ for a complex-valued function $f$? – Martin R Feb 11 '17 at 17:14
• I have answered your question as an edit in the original post. – kishlaya Feb 11 '17 at 17:29

You can always write $f = \operatorname{Re}(f)+i\operatorname{Im}(f)$. Then, by linearity $\int f = \int \operatorname{Re}(f)+i\int \operatorname{Im}(f)$. But this is clearly the unique decomposition of $\int f$ in its real and imaginary part since both $\int \operatorname{Re}(f)$ and $\int \operatorname{Im}(f)$ are real numbers, hence we must have $\operatorname{Re}\int f = \int \operatorname{Re}f$ and the same for the imaginary part.
If $E,F$ are complex Banach lattices and $T:E\to F$ is a real operator, i.e. mapping real elements to real elements, then $T\circ \operatorname{Re} = \operatorname{Re}\circ T$. Positive Operators are a special case of real operators and your question is a special case if we set $E = L^1, F=\mathbb C, T=\int$.
• @TimB., the result does not hold if the integral is a contour integral (i.e., with a $dz$ at the end and over a complex curve $\gamma$). This is because $\int_\gamma Re(f) dz$ can still be complex. – SuperM Aug 30 '19 at 17:52