# Why am I getting two different answers when the countour integral is performed in two different ways?

If $$C$$ is the circle $$|z|=2,$$ taken with positive orientation then show that $$\int_C\frac{2z}{2+z^2}dz=4\pi i.$$

I tried solving the problem as follows:

Let $$I=\int\frac{2z}{2+z^2}dz.$$ Then, $$I=\int_C \frac{1}{z-i\sqrt 2}dz+\int_C\frac{1}{z+i\sqrt 2}dz=4\pi i.$$ This is because, for any complex number $$z_0\in\Bbb C,$$ if $$C_1$$ is any simple closed contour with poitive orientation such that $$z_0$$ lies interior to $$C$$ then $$\int_{C_1}\frac{dz}{z-z_0}=2\pi i.$$

However, if we solve it in the following way, we get a different answer:

We note that, $$C:z(t)=2e^{it},t\in [0,2\pi ].$$

Now, $$\int\frac{2z}{2+z^2}dz=\int_0^{2\pi}\frac{2.2.e^{it}}{4e^{2it}+2}z'(t)dt=\int_{0}^{2\pi}\frac{4e^{it}}{4e^{2it}+2}2ie^{it}dt=8i\int_0^{2\pi}\frac{e^{2it}}{4e^{2it}+2}=[\text{Log}(2e^{2ti}+1)]^{2\pi}_0=0.$$

In this case, I actually used the following theorem:

This picture is taken from the book "Complex analysis" by Mathews and Howell.

It seems strange that we get 2 different answers when we use two different methods to solve the question given that, both are valid ways of solving the question.

I rechecked my calculation in the last method above and it seems correct. WolframAlpha agrees with my calculation. Here are two pictures of the same from WolframAlpha,

I don't get where is the mistake occuring. Any explanation regarding this apparent issue will be greatly appreciated.

• The 2nd integral is where the mistake lies; note that $\log(z)$ is multivalued, so you have to be careful about which branch you're on. Commented Sep 4 at 19:06
• @DarkMalthorp In this case, I am taking the principal branch of the Logarithm, as this is the only branch whose derivative is well-known. So, I don't really get where's the mistake. Can you please elaborate a bit? Commented Sep 4 at 19:16
• The principal branch of the logarithm is not even continuous in $\Bbb C \setminus \{ 0 \}$. With your method you would get that $\int_{|z|=1} \frac{dz}{z}$ is zero instead of $2 \pi i$. Commented Sep 4 at 19:28
• your assertion "for any complex number $z_0\in\Bbb C,$ if $C_1$ is any closed contour with poitive orientation such that $z_0$ lies interior to $C$ then $\int_{C_1}\frac{dz}{z-z_0}=2\pi i$" is False. You need to restrict to $C_1$ being simple or change the statement to accommodate winding numbers. Commented Sep 5 at 3:35
• @user8675309 You're correct. I should've mentioned the curve is simple. Nevertheless I've edited it now. But can you please help me with this confusion? Commented Sep 5 at 10:19

$$\newcommand\C{\mathbb{C}}$$ Suppose $$f$$ is an analytic function on an open domain $$D \subset \C$$ and $$C \subset D$$ is a contour. Suppose on $$D$$, $$f$$ has an antiderivative $$F$$, so $$F'(z) = f(z),\ \forall z \in D.$$ Then by definition, if $$z(t)$$, $$a \le t \le b$$, is a parameterization of $$C$$, then, by the chain rule and the fundamental theorem of calculus, \begin{align*} \int_Cf(z)\,dz &= \int_{t=a}^{t=b} f(z(t))z'(t)\,dt \\ &= \int_{t=a}^{t=b} F'(z(t))z'(t)\,dt \\ &= \int_{t=a}^{t=b}\frac{d}{dt}F(z(t))\,dt \\ &= F(z(b)) - F(z(a)). \end{align*} In particular, if $$C$$ is closed, the integral is zero.

In your example, the function $$f(z) = \frac{2z}{2+z^2}$$ has no antiderivative $$F$$ that is analytic on any open set containing $$C$$ as given. There is no function of the form "$$\log(2+z^2)$$" that is analytic on an open set containing $$C$$.

I also do not see how to compute the integral using the $$\operatorname{Log}$$ function.

If you want to use the fundamental thoerem of calculus, you can proceed as follows: First, let $$G(t) = \int_0^t \frac{4ie^{2is}}{2e^{2is}+1}\,ds$$ The formula $$G(t) = \log(2e^{2it}+1) - \log(3),$$ is ill-defined, but one can show that $$e^{G(t)} = \frac{2e^{2it}+1}{3}.$$ On the other hand, using polar coordinates, there exist unique continuous functions $$r(t)$$ and $$\theta(t)$$ such that $$r(0)=1$$, $$\theta(0)=0$$, and $$re^{i\theta} = \frac{2e^{2it}+1}{3}.$$ From this it follows that $$G(t) = \log(r(t)) + i\theta(t).$$ Applying the fundamental theorem of calculus, we get \begin{align*} \int_C \frac{2z}{2+z^2}\,dx &= G(2\pi) - G(0)\\ &= r(2\pi)-r(0) + i(\theta(2\pi)-\theta(0)). \end{align*} Now observe that $$\frac{2e^{2it} + 1}{3}, 0 \le t \le 2\pi$$ goes twice around the circle of radius $$\frac{2}{3}$$ centered at $$\frac{1}{3}$$. It follows that $$r(2\pi) = r(0)$$ and $$\theta(2\pi) - \theta(0) = 4\pi$$. This shows that the integral is equal to $$4\pi i$$.

• But the book "Complex Analysis" by Howell and Mathews says a theorem like FTC is valid. I have attached the picture from the book in the original post (OP). I'll be glad if you consider checking out the OP. Commented Sep 6 at 2:37
• And even if one decides to define $\log(z)$ on $\mathbb C - \{0\}$ by making some fashionable choice of principle value for the argument of $z$ --- say by choosing $(-\pi,\pi]$, or $[-\pi,\pi)$, or $[0,2\pi)$, or $(0,2\pi]$, or, well anything else --- the version of the $\log(z)$ that you get will still fail to be continuous, and therefore will still fail to be analytic, and so the hypothesis of the "FTC" will still fail to be satisfied where you are intending to apply that theorem. And therefore the conclusion of the "FTC" will still be unjustified. Commented Sep 6 at 13:15
• A theorem like the FTC is indeed valid, but it has hypotheses that you cannot sweep under the rug. Commented Sep 6 at 13:17
• That sounds right. Commented Sep 6 at 16:24
• Your computation of $\int_{-\pi}^{\pi}f(z)dz$ via limits is not correct. (1) $\Log(2e^{2it}+1)$ is defined for $t = \pm \pi$. (2) $\Log(2e^{2it}+1)$ is not defined for $t = \pm \pi/2$. Note that $e^{2it}$ winds twice around the origin. Commented Sep 6 at 23:36

You need to think about the analytic continuation of the log function. If you use the primary branch of the log function, it is going to cease to be analytic every time you complete a winding.

One solution is to break the interval being evaluated into sub-intervals. Choose a branch of the log function that is analytic over each sub-interval.

This is probably the right way to do it.

But, being quick about it, every time $$2e^{2\pi i t} + 1$$ completes a winding, our evaluation of $$\log(2e^{2\pi i t} + 1)$$ picks up $$2\pi i$$ for the revolution.

To understand what is going on here let us consider the following simpler integral $$\int_C \frac 1 z dz$$ where $$C$$ is the unit circle taken with positive orientation. It is parameterized by $$z : [0,2\pi] \to \mathbb C, z(t) = e^{it}$$. As we know $$\int_C \frac 1 z dz = \int_0^{2\pi} \frac{1}{z(t)}z'(t) dt = \int_0^{2\pi} i dt = 2\pi i .$$ Concerning the last equation let us observe that the constant function $$c(t) \equiv i$$ has the antiderivative $$\iota(t) = it$$ so that $$\int_0^{2\pi} i dt = \iota(2\pi) - \iota(0) = 2\pi i - 0 = 2\pi i$$ by the FTC.

On the other hand, we can also consider the integral $$\int_0^{2\pi} \frac{z'(t)}{z(t)} dt$$. Without knowing what $$z(t)$$ is, one can argue that $$(\log \circ z)'(t) = \log'(z(t))z'(t) = \frac{z'(t)}{z(t)}$$ (chain rule). Thus $$\log \circ z$$ seems to be an antiderivative of $$\frac{z'}{z}$$ which seems to be imply $$\int_0^{2\pi} \frac{z'(t)}{z(t)} dt = \log(z(2\pi)) - \log(z(0)) = 0$$ because $$z(t)$$ is a closed path. This is what WolframAlpha seems to suggest.

But wait: Where precisely is the function $$\log$$ defined? In order that the FTC applies, the function $$\log \circ z$$ must be defined on $$[0,2\pi]$$, hence $$\log$$ must be defined for all $$w = z(t)$$ with $$t \in [0,2\pi]$$, i.e. for all $$w$$ on the unit circle $$S^1$$. Actually it must be defined on an open neighborhood $$U^1$$ of $$S^1$$ and must be complex differentiable on $$U^1$$.

It is well-known that no such logarithm function exists. We can only say that there are holomorphic logarithm functions on each sliced plane (or more generally, as Paul Frost wrote in his answer, on each simply connected $$U \subset \mathbb C \setminus \{0\})$$. For example we have the principal branch $$\operatorname{Log}$$ which is defined an $$\mathbb C \setminus (-\infty, 0]$$.

Let us assume for a moment that there is a holomorphic logarithm $$\log : U^1 \to \mathbb C$$ as described above. Then both $$\iota$$ and $$\log \circ z$$ are antiderivatives of $$c(t) \equiv i$$. Hence $$\phi = \log \circ z - \iota$$ must be constant on $$[0,2\pi]$$. This implies $$0 = \phi(0) = \phi(2\pi) = -2\pi$$ which is a contradiction. Actually this is a proof of the non-existence of $$\log : U^1 \to \mathbb C$$.

However, working with logarithms on sliced planes is sufficient. Indeed $$\int_0^{2\pi} \frac{z'(t)}{z(t)} dt = \lim_{\epsilon \to 0} \int_0^{2\pi -\epsilon} \frac{z'(t)}{z(t)} dt .$$ Taking a branch cut slightly below the positive $$x$$-axis, we get a branch $$\log$$ of the logarithm which is defined for all $$e^{it}$$ with $$t \in [0,2\pi-\epsilon]$$. Actually we can achieve $$\log (e^{it}) = it$$ for these $$t$$ so that $$\int_0^{2\pi -\epsilon} \frac{z'(t)}{z(t)} dt = \log(e^{i(2\pi -\epsilon)}) - \log(e^{i0}) = (2\pi -\epsilon)i$$ which yields $$\lim_{\epsilon \to 0} \int_0^{2\pi -\epsilon} \frac{z'(t)}{z(t)} dt = 2\pi i.$$

Let us now discuss your integral $$I=\int_C\frac{2z}{2+z^2}dz$$ where $$C$$ is the circle $$|z|=2$$ taken with positive orientation. It is parameterized by $$z : [0,2\pi] \to \mathbb C, z(t) = 2e^{it}$$.

You proved that $$I = 4\pi i$$, but you were confused by the alternative approach based on WolframAlpha which seems to result in $$I = 0$$.

Writing $$f(z) = 2+z^2$$ and $$w(t) = f(z(t)) = 4e^{2it}+2$$ we have $$I = \int_C \frac{f'(z)}{f(z)} dz = \int_0^{2\pi}\frac{f'(z(t))}{f(z)t))}z'(t)dt = \int_0^{2\pi}\frac{w'(t)}{w(t)}dt .$$ Again $$\log \circ w$$ seems to be an antiderivative of $$\frac{w'}{w}$$ and this seems to prove $$I = 0$$ by the FTC.

$$w$$ is a closed curve which traverses the circle $$S$$ with center $$2$$ and radius $$4$$ twice in positive direction. In order that the FTC applies $$\log$$ must be defined on an open neighborhood $$U$$ of $$S$$ and must be complex differentiable on $$U$$. We know that such $$\log$$ does not exist, thus the conclusion $$I = 0$$ is invalid.

Nevertheless we can again compute $$I$$ by using logarithms on sliced planes. Let us first observe that $$\int_0^{2\pi} \frac{w'(t)}{w(t)}dt = \int_0^{\pi} \frac{w'(t)}{w(t)}dt + \int_{\pi}^{2\pi} \frac{w'(t)}{w(t)}dt$$. Since $$w(\pi +t) = w(t)$$, we see that $$\int_0^{\pi} \frac{w'(t)}{w(t)}dt = \int_{\pi}^{2\pi} \frac{w'(t)}{w(t)}dt$$ so that $$I = 2 \int_0^{\pi} \frac{w'(t)}{w(t)}dt$$.

Taking once more a branch cut slightly below the positive $$x$$-axis, we get a branch $$\log$$ of the logarithm which is defined for all $$w(t)$$ with $$t \in [0,\pi-\epsilon]$$ and satisfies $$\log (e^{it}) = it$$ for these $$t$$, we get

$$\int_0^{\pi} \frac{w'(t)}{w(t)}dt = \lim_{\epsilon \to 0} \int_0^{\pi-\epsilon} \frac{w'(t)}{w(t)}dt = \lim_{\epsilon \to 0} (\log(w(\pi-\epsilon)) - \log(w(0))).$$

Unfortunately there is no explicit formula for $$\log(w(t))$$, but we can write $$w(t) = r(t)e^{is(t)}$$ with $$r(t) = \lvert w(t) \rvert$$ and a real-valued increasing $$s(t)$$ such that $$s(0) = 0$$ and $$s(t) \to 2\pi$$ as $$t \to \pi$$. Then

$$\log(w(\pi-\epsilon)) = \log(r(\pi-\epsilon)e^{is(\pi-\epsilon)})= \log r(\pi-\epsilon)) + is(\pi-\epsilon) \to \log 6 + 2\pi i$$ as $$\epsilon\to \pi$$. Since $$\log(w(0)) = \log 6$$, we see that $$\int_0^{\pi} \frac{w'(t)}{w(t)}dt = 2\pi i$$.

As an indefinite integral you have indeed $$\int \frac{4ie^{2it}}{1 + 2e^{2it}}dt = \log(1+2e^{2it}) + c . \tag{1}$$ Here $$\log$$ is a branch of the natural logarithm. There are infinitely many such branches. More precisely, for each simply connected domain $$U \subset \mathbb C \setminus \{0\}$$ there exists a branch $$\log_{U} : U \to \mathbb C$$, and for each $$k \in \mathbb Z$$ we get another branch $$\log_{U,k} = \log_{U} + 2k\pi i$$. These are all branches on $$U$$. Usually one takes sliced planes as domains.

Note that a branch is required to be continuous on its domain. This implies that it is holomorphic, and this is needed for $$(1)$$ to make sense. On $$\mathbb C \setminus \{0\}$$ there does not exist a branch of the natural logarithm.

For any circular curve $$C_{a,b,U}$$ in a simply connected $$U$$, parameterized by $$z : [a,b] \to U, z(t) = 2e^{it}$$, we get $$\int_{C_{a,b,U}} \frac{4ie^{2it}}{1 + 2e^{2it}}dt = \log(1 + 2e^{2ib}) - \log(1 + 2e^{2ia}) . \tag{2}$$

This does not depend on the chosen branch $$\log = \log_{U,k}$$. Note that we need $$b-a < 2 \pi$$ in order to find a simply connected $$U$$ containing $$C_{a,b,U}$$. Actually we can take a sliced plane for $$U$$ when $$b-a <2\pi$$.

The complete circle $$C$$ is no curve with values in a simply connected domain $$U \subset \mathbb C \setminus \{0\}$$, thus $$(2)$$ does not apply here.

Remark.

On each simply connected $$U$$, the function $$\frac{2z}{2+z^2}$$ has $$\log(2+z^2)$$ as an antiderivative, where $$\log$$ is a branch of the logarithm on $$U$$. Hence for any curve $$C$$ in $$U$$, parameterized by $$z : [a,b] \to U$$, we get

$$\int_C \frac{2z}{2+z^2}dz = \log(2+z(b)^2) - \log(2+z(a)^2) . \tag{3}$$

Update.

Let us come back to your integral $$\int_0^{2\pi}\frac{8ie^{2it}}{4e^{2it}+1}dt .$$

You want to calculate it by Mathews and Howell's extension of the fundamental theorem of calculus to complex-valued functions. Here it is:

• If $$F : [a,b] \to \mathbb C$$ is an antiderivative of $$f : [a,b] \to \mathbb C$$, then $$\int_a^b f(t)dt = F(b) - F(a)$$.

Let $$g(t) = 4e^{2it} +1$$. Then $$g'(t) = 8ie^{2it}$$ so that $$\int_0^{2\pi}\frac{8ie^{2it}}{4e^{2it}+1}dt = \int_0^{2\pi}\frac{g'(t)}{g(t)}dt. \tag{4}$$ The idea is to use the complex logarithm $$\log$$ to find an antiderivative of $$\dfrac{g'(t)}{g(t)}$$. In fact, the derivative of the function $$\log \circ g$$ is $$(\log \circ g)'(t) = \frac{g'(t)}{g(t)} . \tag{5}$$ This looks like an application of the ordinary chain rule, but it is a bit more sophisticated. Actually neither the real nor the complex chain rule apply here. We need a "mixed chain rule" (see my answer to How to prove Eulers formula using the definition of derivative?). Anyway, $$(5)$$ is definitely correct.

The problem, however, is that to apply the mixed chain rule we need a holomorphic branch of the logarithm $$\log : U \to \mathbb C$$ living on some domain $$U \subset \mathbb C \setminus \{0\}$$. Then for any interval $$[a,b] \subset [0,2\pi]$$ such that $$g([a,b]) \subset U$$ we can define $$\log \circ g : [a,b] \xrightarrow{g} U \xrightarrow{\log} \mathbb C .$$ This yields $$\int_a^b\frac{8ie^{2it}}{4e^{2it}+1}dt = \log(g(b)) - \log(g(a)) .\tag{6}$$ Thus the crucial question is this:

Is it possible to find a branch of the logarithm living on some $$U$$ such that $$g([0,2\pi])$$ (which is a circle) is contained in $$U$$?

It is well-known that this impossible. Thus $$(6)$$ does not apply for $$a = 0, b = 2\pi$$.

• Thank you so much for your answer. So does this mean, that $(2)$ would have been applicable only if the curve $C$ lied in a simply connected domain? Commented Sep 5 at 18:05
• @ThomasFinley See my update which is a bit more general. $(3)$ is applicable for curves in a simply connected domain. Actually it is applicable for all $U$ on which there exists a (holomorphic) branch of the logarithm. There are more such $U$ than simply connected ones. For example, if $V$ is a sliced plane and $\zeta \in V$, then $U = V\setminus \{\zeta\}$ is not simply connected, but trivially admits a branch of the logarithm (since $V$ does). Commented Sep 5 at 22:27
• @Peter Perhaps you should help the OP by writing a clear answer. Commented Sep 6 at 14:21

Too long for a comment.

Let $$f(t)=\frac{4ie^{2ti}}{2e^{2ti}+1}$$ and $$F(t)=\text{Log}(2e^{2ti}+1)$$ be its anti-derivative obtained by means of the principal branch of the logarithm. $$F(t)$$ is not continuous at $$t=\frac\pi 2$$ and $$t=\frac{3\pi}2$$. So, we can not use the fundamental theorem of calculus directly. But, $$I=\int_0^{2\pi }f(t)dt$$ can be seen as an improper integral although the indegrand is continuous so that we can do the computation without mentioning the other branches of the logarithm. $$I_1=\int_0^{\frac\pi 2}f(t)dt=\lim_{t\to(\frac\pi 2)^-}F(t)-F(0)=\pi i-\ln3$$ $$I_2=\int_{\frac\pi 2}^{\frac{3\pi}2}f(t)dt=\lim_{t\to(\frac{3\pi}2)^-}F(t)-\lim_{t\to(\tfrac{\pi}2)^+}F(t)=\pi i-(-\pi i)=2\pi i$$ Similarly, $$I_3=\ln 3+\pi i.$$ Hence, $$I=I_1+I_2+I_3=4\pi i.$$ Or with the help of WolframAlpha, $$\int_0^{2\pi }\frac{4ie^{2it}}{2e^{2it}+1}dt=\int_0^{2\pi}\frac{-4\sin2t}{4\cos2t+5}dt+i\int_0^{2\pi }\frac{4(\cos2t+2)}{4\cos2t+5}dt=4\pi i.$$ From the graphs of this WA output, we can see that the anti-derivative of $$f(t)$$ is in fact $$G(t)=\begin{cases} F(t)&\text{If 0\leq t\leq\frac{\pi}2}\\ F(t)+2\pi i&\text{If \frac\pi 2\leq t\leq\frac{3\pi}2}\\ F(t)+4\pi i&\text{If \frac{3\pi}2\leq t\leq 2\pi}\\ \end{cases}$$ which is about the brunch-cut issue discussed in the comments.

• It would be really helpful if you consider writing why my 2nd method is not correct. Unfortunately, I still didn't get why is it incorrect :?) Commented Sep 6 at 2:22
• @ThomasFinley $F(t)$ is not defined at $t=\frac\pi 2$ and $t=\frac{3\pi}2$. You are not allowed to use the Fundamental theorem of calculus on the whole interval. Commented Sep 6 at 3:48
• Not defined as a continuous function... Commented Sep 6 at 8:33
• So does this mean that if $f,$ and $F$ are two complex valued functions of a real parameter $t$ and $F'(t)=f(t)$ then, $\int_{a}^bf(t)dt=F(b)-F(a)$ holds iff $F$ is defined everywhere on $[a,b].$ In my case, $F$ wasn't defined everywhere on $[0,2\pi]$ and so my method went incorrect. Did I get you? Commented Sep 6 at 8:55
• I should have said continuous because it is defined actually. $\text{Log}(-1)=\pi i$. My thinking comes from real calculus, improper integrals section. @ThomasFinley Commented Sep 6 at 9:02

Your second method is not correct as the other answers have pointed out. I am not going to go through why, but I will give an analogy, if we want to evaluate the integral: $$I = \int_{-1}^1 x^{-2} dx$$ We know this integral diverges and we are not allowed to say: $$I = (-x^{-1})_{-1}^1 = -1 -1 =-2$$ Even though this is the antiderivative evaluated at the endpoints.

• It would be really helpful if you consider writing why my 2nd method is not correct. I still didn't get why is it incorrect, unfortunately. Commented Sep 6 at 2:21