If I have a function whose denominator has only complex roots, could I integrate it and perform partial fraction decomposition by separating the factors? For example, am I allowed to evaluate $$\int\frac{1}{(x+i)(x-i)}dx$$Or $$\int\frac{1}{(x+2i)(x-2i)}dx$$By partial fractions (without getting rid of $i$)? I don't think I could continue since we are integrating along the $x$-axis. Edit: I am asking if in general I could integrating with imaginary numbers, not just in this specific example. I was giving a background.

  • 3
    $\begingroup$ I think you can continue doing it, one time I did the same with the integral $\int \frac{dx}{1+x^2}$ $\endgroup$ Feb 9 at 19:04
  • 2
    $\begingroup$ @SineoftheTime Jazak allah. But we are integrating on $\mathbb{R}$ and not $\mathbb{C}$, so shouldn't it be illegal? I think it worked in your case since there is a form of $\arctan x$ in terms of the complex logarithm. $\endgroup$ Feb 9 at 19:07
  • 2
    $\begingroup$ @KamalSaleh Barak Allah fik. Somehow, to return to the $\mathbb{R}$-world, you'd have to use some identities involving complex numbers $\endgroup$ Feb 9 at 19:09
  • 1
    $\begingroup$ What do you mean by "integrating in the $x$-axis"? Do you mean the real axis on the complex plane? $\endgroup$ Feb 9 at 23:10
  • 2
    $\begingroup$ It is definitely allowed. You'll get an antiderivative involving complex logarithms. That's ok if you know what complex logarithms mean. Note that $\int dx/(x-a) = \ln(x-a)$, ((not** $\ln |x-a|$: that only works for real numbers). $\endgroup$ Feb 10 at 0:04

2 Answers 2


Yes, but you need to be a bit careful. Formally you are just embedding the space of integrable functions $\mathbb{R} \to \mathbb{R}$ into the space of integrable functions $\mathbb{R} \to \mathbb{C}$ (which is its complexification), and this embedding is compatible with taking antiderivatives. Even though complex numbers appear in the calculation, because the original function you're integrating is real, the final answer must necessarily be real, so the imaginary parts have to cancel out somehow. Note that it is not necessary to allow $x$ to be complex.

The simplest examples where everything works out quite cleanly involve trigonometric functions. For example you can see this old thread which explains how to compute $\int_0^{2 \pi} \sin^{100} x \, dx$ by writing $\sin x = \frac{e^{ix} - e^{-ix}}{2i}$ and then expanding using the binomial theorem.

The case of rational functions is more complicated because logarithms appear. $\int \frac{1}{x^2 + 1} \, dx$ is a good example so let's work through that in some detail. The partial fraction decomposition is

$$\frac{1}{(x + i)(x - i)} = \frac{1}{2i} \left( \frac{1}{x + i} - \frac{1}{x - i} \right)$$

and integrating formally gives an antiderivative of

$$\int \frac{1}{1 + x^2} \, dx = \frac{1}{2i} \left( \ln (x + i) - \ln (x - i) \right).$$

But is this the right answer? We were expecting $\arctan x$, of course. This answer is actually correct if properly interpreted, but there is a subtlety here. Even if $x$ is real, $x + i$ and $x - i$ are complex, so to make sense of these expressions we have to pick a branch of the complex logarithm, which complicates things; different choices will differ by a constant (which isn't a big deal, that's just how antiderivatives work), but we also have to pick a branch cut, which is a complication you might want to avoid since the final answer shouldn't really depend on this choice.

To make things less confusing I would personally rewrite the partial fraction decomposition slightly, as

$$\frac{1}{(1 + ix)(1 - ix)} = \frac{1}{2} \left( \frac{1}{1 + ix} + \frac{1}{1 - ix} \right)$$

which, again integrating formally, gives an antiderivative of

$$\int \frac{1}{1 + x^2} \, dx = \frac{1}{2} \left( \frac{\log (1 + ix)}{i} - \frac{\log (1 - ix)}{i} \right)$$

where we define

$$\log (1 + z) = \sum_{n \ge 1} (-1)^{n-1} \frac{z^n}{n}$$

even if $z$ is complex (as long as $|z| < 1$). Now there's no issue with branches and branch cuts, or rather, the choice to use the Taylor series around $1$ makes this choice for us. From here we can write

$$\log (1 + ix) - \log (1 - ix) = \log \frac{1 + ix}{1 - ix}$$

(this is no longer entirely obvious with our specific choice of branch of the logarithm and needs to be checked) and now we need to stop and think a bit about what this function is actually doing. If $x$ is real, $1 + ix$ is a complex number which has polar form $re^{i \theta}$ such that $x = \tan \theta$. Then $1 - ix$ is its complex conjugate, which is $re^{-i \theta}$. So their ratio is $e^{2 i \theta}$. This gives, again at least formally,

$$\frac{1}{2i} \left( \log (1 + ix) - \log (1 - ix) \right) = \frac{1}{2i} \log e^{2i \theta} = \theta = \arctan x.$$

But you might rightfully feel a little wary of this argument, since it involves applying logarithm rules to the complex logarithm (again, even if $x$ is real) which generally only hold up to a multiple of $2 \pi i$, due to the whole issue with branches, and we also need to potentially say some things about the domain and range of $\arctan$ and so forth. You can check that everything is fine (computationally the worst that'll happen is that you pick up an additive constant, which is not an issue for antiderivatives) but at this point it is maybe more work than it's worth.

  • 2
    $\begingroup$ Actually maybe I've made things unnecessarily complicated for myself; this argument as written only works for $|x| < 1$ so a priori it doesn't establish what the antiderivative is outside of this interval. You can fix this by mumbling some stuff about the identity principle or doing the more careful work I tried to avoid re: branches and branch cuts, but again, at this point it might be more trouble than it's worth. $\endgroup$ Feb 10 at 0:17

Yes, this is OK.

One caution, however, is that
$$ \int\frac{dx}{x+i} \ne \ln|x+i|+C . $$ Instead, $$ \int\frac{dx}{x+i} = \ln(x+i)+C $$ is correct.

  • $\begingroup$ The caution comes from the fact that the absolute value for complex numbers in general is $|z|=\sqrt{\Re(z)^2+\Im(z)^2}$, right? $\endgroup$ Feb 10 at 1:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .