Complex Numbers II: A Guide to Contour Integration (Part 1 of 3)
by greenturtle3141, May 19, 2023, 4:58 AM
Reading Difficulty: 3.5/5
Prerequisites:
- Know what complex numbers are and how to do arithmetic with them.
- Know what an integral is and how to compute some basic integrals.
- It would be good to take a glance at my previous post on complex numbers.
- Sufficient spare time to read this gargantuan post.
This post ended up being so much longer than I anticipated. It is written with the intent of lowering the barrier to entry for learning this methodology. I hope this is helpful, and if nothing else, you can enjoy timing how long it takes you to scroll to the bottom of this post. Enjoy!
When I was young, I was really fascinated by the idea of using complex numbers to evaluate integrals such as
. Unfortunately, I could not learn it. Any videos on YouTube showcasing the idea never really quite explained how it works or what to do. Any articles I found on the internet were simply way too advanced. This post here is meant to bridge the gap, assuming only a general knowledge of integration.
I cover things like holomorphic functions because without this background, it's once again quite easy to fall into weird pitfalls and paradoxes. I won't go too much into depth into the details because that should be deferred for an actual college course.
This post will be divided into several "lessons", each serving a different purpose.
Lesson 0: Complex Number Arithmetic and Review
My first post on complex numbers established some "hidden facts" about complex numbers, and how to avoid common but tricky pitfalls with complex number arithmetic. Let's review some of the key facts.
Complex Addition, Subtraction, Multiplication, Division
If you don't know how to do these, then you are not ready to read this post.
Magnitude (
) and Conjugation (
)
If you don't know what these are and/or how to compute these quantities, then you are not ready to read this post.
Complex Exponents
Summary of Background:
Computing complex exponents:
We will not worry about computing complex exponents with bases other than
.
Exercises
Polar Form
You should be familiar with this, but I will review what this is just in case.
We know that
is the point on the complex unit circle at angle
. By scaling the unit circle, it follows that any nonzero complex number
can be represented in the form
, where
is the magnitude
and
is the angle of
.
Summary of Facts:
Examples:
Exercises
Roots of Unity
This is another thing you should know by now before reading this.
Uh, basically the roots of the polynomial
are
.
Exercises
Square Root of Complex Numbers
Summary of Facts:
Exercises
Complex Log
Summary of Facts:
Exercises
Complex Trig
Basically you throw out all geometric intuition for sine and cosine. Instead we have very brute-force definitions:

When
is a real number
, then the formula
holds, in which case these equations are obviously true. So, these formulas are the "most natural" way to extend the domains of sine and cosine to take in values other than real numbers.
(It is true that
as a consequence of this definition, but this doesn't really help you evaluate what
is for complex
. The point is that we know how to exponentiate complex numbers, so we use that to figure out the cosine and sine.)
Exercises
Lesson 1: Differentiating Complex Expressions
The rules are all the same as for differentiating real expressions. The definition is the same (
). The
doesn't really interfere with anything - just treat it as a constant.
I'll let you dive right into the exercises. This will show you that the answers you expect are basically just completely correct.
Exercises
Lesson 2: Integrating Complex Expressions
This is really easy. If you're trying to integrate something like
(where
are real functions), then this is literally just
.
Alternatively, suppose that
is a complex-valued function, and you knew that
for some
. Then you can apply the fundamental theorem of calculus (FTC)
which still works for complex numbers.
Example
How can we compute
? Well, we know that an antiderivative for
is
. So by the FTC we compute

But let's say you're not feeling confident about this computation. We could also have split the integrand into the real part and the imaginary part to get

In general, all "nice properties" you are familiar with for integrating real expressions will naturally carry over to integrating complex expressions. For example we still have linearity such as
.
Note that the variable we integrate with respect to MUST be a real number, ranging over an interval! Integrals such as "
" or "
" do not make sense, for example. (Well, actually the second integral is kinda ok for weird reasons, but please avoid it for now lol.)
Exercises
ANNOYING WARNING: What is
? You might be tempted to say that
is an antiderivative and then plug in the limits. This is WRONG! The reason is because the
won't be defined at
. This isn't just a cheap reason to say not do this: The integrand jumps quite a bit at
, which breaks the FTC for a subtle reason. (Now you see why I exclude negative reals! As long as you stay where functions are defined, bad things don't happen.)
More generally, if you get a weird result or paradox in your computations, and they involve a square root or log, there is a good chance that these sublties are tripping you up. It's ok if you don't understand what's going wrong.
Lesson 3: Contour Integrals
An integral that looks like
is called a contour integral. One major difference from before is that it's a
, meaning that the "variable" ranges over complex numbers!
Let's talk about what this means.
Curves/paths need an orientation too: You either go one way or the other. Here are some examples of paths.
How do you integrate over a path? Here are the steps.
It's important that you know how to do this, so let's do three examples.
Example 1
Let's compute the contour integral
, where
is the unit circle oriented counter-clockwise.
A parametrization for
is the function
as
ranges from
to
. Thus the integral is just

Example 2
Let's try a more annoying example. Compute the contour integral
, where
is the square with vertices
, oriented counter-clockwise.
Man, it's annoying to make a single function that traces out the entire square! Fortunately, because of properties of contour integrals, we're allowed to split this path up into four nicer paths, which are each easier to parametrize. Here, I want to split this up into the four segments that make up the square.
I'm allowed to split up the contour integral into the sum of four smaller contour integrals over these smaller paths:
So we just need to compute these four integrals. (Yeah yeah yeah it's still annoying, but what can you do...)
Thus
. Wait, isn't that the same answer as the previous example? Strange.
Example 3, Kinda
Let's compute the contour integral
, where
is the following pacman shape of radius
:
We need to split this into three different parts.
The first part,
, is parametrized by
for
. So the integral over
is

This might look complicated, but the integrand is basically just of the form
where
is a constant. So its antiderivative is
, meaning that this integral evaluates to

The third part,
, is handled similarly.

Now we tackle the second part,
. This is parametrized by
for
. So
This integral sucks to evaluate, so I'm not going to do it. (note that making the "substitution"
doesn't actually help you because it just goes backwards a step.)
Darn, if only there was some really cool theorem that could help solve this problem. What a shame.
Summary of Contour Integral Properties
(Stupid warning: If you're intentionally trying to break math, it's possible to take contour integrals over really strange paths that completely destroy this post. It's basically impossible for you to do that though unless you try though, because those paths that might do that are REALLY nasty and hard to come up with, so don't worry.)
Exercises
Lesson 4: Holomorphic Functions
In the complex world, "holomorphic" is just a fancy word for "differentiable". All of the functions we've mentioned so far are holomorphic:
If you want more fancy words: A function that is holomorphic on the whole complex plane is called entire.
Some functions are a bit more subtle.
Not everything is holomorphic.
(Holomorphic functions satisfy some really insanely cool properties. They're honestly miracles. We won't really talk about these miracles, though, since that would mak this post longer than it needs to be.)
Here is the motto I want you to take away from this lesson: Holomorphic functions are really nice, and you should not try and apply any of the theorems we talk about to functions that are not holomorphic. I can't guarantee that the numbers will work out if you do that. Fortunately, basically all sane things that you would consider integrating are holomorphic!
(Next part)
Prerequisites:
- Know what complex numbers are and how to do arithmetic with them.
- Know what an integral is and how to compute some basic integrals.
- It would be good to take a glance at my previous post on complex numbers.
- Sufficient spare time to read this gargantuan post.
This post ended up being so much longer than I anticipated. It is written with the intent of lowering the barrier to entry for learning this methodology. I hope this is helpful, and if nothing else, you can enjoy timing how long it takes you to scroll to the bottom of this post. Enjoy!
When I was young, I was really fascinated by the idea of using complex numbers to evaluate integrals such as

I cover things like holomorphic functions because without this background, it's once again quite easy to fall into weird pitfalls and paradoxes. I won't go too much into depth into the details because that should be deferred for an actual college course.
This post will be divided into several "lessons", each serving a different purpose.
Lesson 0: Complex Number Arithmetic and Review
My first post on complex numbers established some "hidden facts" about complex numbers, and how to avoid common but tricky pitfalls with complex number arithmetic. Let's review some of the key facts.
Complex Addition, Subtraction, Multiplication, Division
If you don't know how to do these, then you are not ready to read this post.
Magnitude (


If you don't know what these are and/or how to compute these quantities, then you are not ready to read this post.
Complex Exponents
Summary of Background:
- Complex exponentiation doesn't really have an intitive interpretation, unless you'd like to enlighten me.
- When
is a complex number,
is also a complex numberm and it is formally defined as a power series (which is a technicality that we won't need).
satisfies basic algebraic properties for real exponents, that you would expect. For example,
.
Computing complex exponents:
, when
is real, is... just that.
, when
is real, is the complex number
. (ALL ANGLES ARE INTERPRETED AS RADIANS. NO DEGREES ALLOWED! THEY BREAK EVERYTHING.)
- In general, to compute
, you just combine the above two. You rewrite as
, then simplify this to
.
- Intuitively, for
, the magnitude of
is controlled by
, whereas the angle of
is controlled by
.
- Indeed,
parametrizes the unit circle as
ranges through
, with
being the complex number on the unit circle at angle
.
We will not worry about computing complex exponents with bases other than

Exercises
- Let
be a fixed real number. As parameter
ranges through all real numbers, what path does the complex number
trace? Answer
A circle centered atwith radius
.
- Compute
. Solution
Polar Form
You should be familiar with this, but I will review what this is just in case.
We know that








Summary of Facts:
- Actually, the angle is not unique. For example,
. So, it is only unique up to differences of multiples of
.
- We could make the angle unique by restricting it to an interval such as
or
.
- Writing in polar form can be incredibly useful. For example, it allows one to compute quantities such as
fairly quickly.
Examples:
has magnitude
and is at an angle of
. So we can write it in polar form as
.
- What is
? This can be evaluated purely using the rules we established for complex exponentiation, but the perspective of polar form is also useful. Here, we seek the complex number with magnitude
and angle
. The complex number on the unit circle at the desired angle is
. Scaling this by
, we get
.
Exercises
- Write
in polar form. Answer
Roots of Unity
This is another thing you should know by now before reading this.
Uh, basically the roots of the polynomial


Exercises
- Why?
- How about
? Hint
Make a substitution to reduce it to solving for some variablein
.
Square Root of Complex Numbers
Summary of Facts:
- Every non-zero complex number has two square roots. So,
is hard to define as a nice well-defined function, because functions can't output two different results.
- If you had to make
a function, you would use the principal square root.
- This is computed by writing
in polar form
, where
, and then taking
.
- (Disallowing
is disputable. I exclude it for "safety" as you shall see soon.)
- (There are "other square roots" that you can "choose".)
Exercises
- Compute
, where
is the principal square root. Answer
- Show that
. (Technically the RHS is undefined under my definition, but if you want you can pretend that it is
.)
Complex Log
Summary of Facts:
- This is a mess.
- There are infinitely many logs, and none of them are perfect.
- The "best" log is the principal log.
- It is calculated as follows: If we write
, where
, then
.
- Intuitively this makes a lot of sense: We use the "rule"
to write
- In general, however, it is NOT true that
holds. It only works in specific cases like the above equality.
- (I have excluded
for safety, once again.)
Exercises
- Compute
, where
is the principal log. Answer
Complex Trig
Basically you throw out all geometric intuition for sine and cosine. Instead we have very brute-force definitions:





(It is true that



Exercises
- Compute
. Answer
- Compute
. Solution
- We say that the real function
is a bounded function because
for all
. Can the same be said for
(i.e. the complex cosine)? Answer
No.is huge. This suggests that
and
don't fluctuate too much when changing the real part of
, but they explode when the imaginary part of
goes up.
Lesson 1: Differentiating Complex Expressions
The rules are all the same as for differentiating real expressions. The definition is the same (


I'll let you dive right into the exercises. This will show you that the answers you expect are basically just completely correct.
Exercises
Answer
Answer
Answer
Answer
Answer
Lesson 2: Integrating Complex Expressions
This is really easy. If you're trying to integrate something like



Alternatively, suppose that




Example
How can we compute




But let's say you're not feeling confident about this computation. We could also have split the integrand into the real part and the imaginary part to get

In general, all "nice properties" you are familiar with for integrating real expressions will naturally carry over to integrating complex expressions. For example we still have linearity such as

Note that the variable we integrate with respect to MUST be a real number, ranging over an interval! Integrals such as "


Exercises
Answer
(note that you can just move the
out)
Answer
ANNOYING WARNING: What is





More generally, if you get a weird result or paradox in your computations, and they involve a square root or log, there is a good chance that these sublties are tripping you up. It's ok if you don't understand what's going wrong.
Lesson 3: Contour Integrals
An integral that looks like


Let's talk about what this means.
is a complex-valued function over complex numbers. That means that it can take in complex numbers and output complex numbers. It can be like,
or
or
or
or... basically anything in terms of a complex variable
.
is a curve in the complex plane. It's basically a path you can draw from a point
to a point
.
Curves/paths need an orientation too: You either go one way or the other. Here are some examples of paths.
- This thingy is a path! Let's call it
.
- This thingy is a different path because it's going the other way, so we call it
.
- This is a totally different path, so we're giving it a different letter.
- The unit circle is an important example of a path that loops.
. Whenever we talk about the unit circle as a path, you should assume that we're going counter-clockwise. (The starting point doesn't really matter.)
- It's ok for paths to have sharp corners. This sector boundary is a perfectly good path! (It also loops)
How do you integrate over a path? Here are the steps.
- Let's say the path is called
. First, find a parametrization for
. A parametrization is a function
that traces out the
path. For example, if
is the unit circle, a parametrization is given by
as
ranges from
to
.
- Once you have a parametrization
for
, the contour integral is given by
It's important that you know how to do this, so let's do three examples.
Example 1
Let's compute the contour integral


A parametrization for






Example 2
Let's try a more annoying example. Compute the contour integral



![[asy]
size(7cm);
draw((-2,0)--(2,0),p=linewidth(1.5),arrow=Arrows(5));
draw((0,-2)--(0,2),p=linewidth(1.5),arrow=Arrows(5));
draw((0,-1)--(1,-1)--(1,1)--(-1,1)--(-1,-1)--(0,-1),p=red,arrow=MidArrow);
label("$\Gamma$",(-1,1.5),p=red);
[/asy]](http://latex.artofproblemsolving.com/9/0/0/900a5d00edd422c4f67a74af25e86b82d766b56b.png)
Man, it's annoying to make a single function that traces out the entire square! Fortunately, because of properties of contour integrals, we're allowed to split this path up into four nicer paths, which are each easier to parametrize. Here, I want to split this up into the four segments that make up the square.
![[asy]
size(7cm);
draw((-2,0)--(2,0),p=linewidth(1.5),arrow=Arrows(5));
draw((0,-2)--(0,2),p=linewidth(1.5),arrow=Arrows(5));
draw((-1,-1)--(1,-1),p=red,arrow=MidArrow);
draw((1,-1)--(1,1),p=purple,arrow=MidArrow);
draw((1,1)--(-1,1),p=orange,arrow=MidArrow);
draw((-1,1)--(-1,-1),p=red+purple,arrow=MidArrow);
label("$\Gamma_1$",(0,-1.5),p=red);
label("$\Gamma_2$",(1.5,0),p=purple);
label("$\Gamma_3$",(0,1.5),p=orange);
label("$\Gamma_4$",(-1.5,0),p=red+purple);
[/asy]](http://latex.artofproblemsolving.com/a/4/0/a40fce8ba54417a4db972a7b83b2be909c4c7750.png)
I'm allowed to split up the contour integral into the sum of four smaller contour integrals over these smaller paths:

- The lower side
can be parametrized by the function
as
ranges from
to
. So
Being wary of tbe warning at the end of Lesson 2, we will NOT be using the complex (principal) log to quickly evaluate this. (Here it should work fine, but I want to be veerrryyyy careful, and so should you!) Let's find a different way to evaluate this.
Remember: If you are ever nervous about what things you're allowed to do with complex integrals, you can always sidestep the issue by splitting the integral into the real part and the imaginary part. This is ALWAYS ok. Here, we can do this by multiplying by the conjugate:
The first integral evaluates to 0 by symmetry (the integrand is odd), and the second integral is
. Thus
.
- The right side
can be parametrized by the function
as
ranges from
to
. So
If you do the same trick as we did for
, you get that
. Again.
is paramterized by
,
and we get
by the same process.
by the same process.
Thus

Example 3, Kinda
Let's compute the contour integral



![[asy]
size(7cm);
draw((-2,0)--(2,0),p=linewidth(1.5),arrow=Arrows(5));
draw((0,-2)--(0,2),p=linewidth(1.5),arrow=Arrows(5));
draw((0,0)--dir(45)--arc((0,0),1,45,360-45,CCW)--(0,0),p=red,arrow=MidArrow);
label("$\gamma$",(-1,1.5),p=red);
[/asy]](http://latex.artofproblemsolving.com/5/2/a/52aa6b4e4dd6c26e745ec50b33b7afb9ead2c545.png)
We need to split this into three different parts.
![[asy]
size(7cm);
draw((-2,0)--(2,0),p=linewidth(1.5),arrow=Arrows(5));
draw((0,-2)--(0,2),p=linewidth(1.5),arrow=Arrows(5));
draw((0,0)--dir(45),p=red,arrow=MidArrow);
draw(arc((0,0),1,45,360-45,CCW)--(0,0),p=purple,arrow=MidArrow);
draw(dir(-45)--(0,0),p=orange,arrow=MidArrow);
label("$\gamma_1$",(0.7,0.3),p=red);
label("$\gamma_3$",(0.7,-0.3),p=orange);
label("$\gamma_2$",(-0.8,1),p=purple);
[/asy]](http://latex.artofproblemsolving.com/texer/v/vejqbgui.png)
The first part,


![$t \in [0,1]$](http://latex.artofproblemsolving.com/6/7/3/6735b925696750e153b8d293780a7b620449b778.png)







The third part,


Now we tackle the second part,


![$t \in [\pi/4,7\pi/4]$](http://latex.artofproblemsolving.com/f/8/6/f86ce343f210fdd49f9da48dc74fbe7f2bd2c5ae.png)


Darn, if only there was some really cool theorem that could help solve this problem. What a shame.
Summary of Contour Integral Properties
- It's linear, so
, and also
.
- It's "additive on paths". So if you split a path
into two paths
and
, then
. We used this property to do Example 2.
- Reversing the direction of the path will negate the integral. That is, if
is a path and
is that same path but going the opposite way, then
.
(Stupid warning: If you're intentionally trying to break math, it's possible to take contour integrals over really strange paths that completely destroy this post. It's basically impossible for you to do that though unless you try though, because those paths that might do that are REALLY nasty and hard to come up with, so don't worry.)
Exercises
- Let
denote the principle logarithm, so that
whenever
and
. Demonstrate the identity
where
is the path that starts at
, moves left/right to the real number
, then moves along a
-radian arc centered at
with radius
in order to reach the complex number
.
(If you want, you may assume thatand
so you don't have to consider multiple cases.)
SolutionNaturally, we split this path into the two obvious parts., is paramterized by
for
, so we have that
The second part,
, is paarmetrized by
for
, so we have that
In sum,
Lesson 4: Holomorphic Functions
In the complex world, "holomorphic" is just a fancy word for "differentiable". All of the functions we've mentioned so far are holomorphic:
- Polynomials like
are holomorphic, over all
.
is holomorphic, over all
.
is holomorphic, over all
.
- Rational functions such as
or
are holomorphic, wherever they are defined.
- Combining things from above (using addition, multiplication, composition, etc.) will still make a holomorphic function. For example,
is holomorphic, wherever it is defined.
If you want more fancy words: A function that is holomorphic on the whole complex plane is called entire.
Some functions are a bit more subtle.
- The principal square root
is holomorphic wherever it is defined, because I excluded the negative reals in the definition. If you define the square root over the negative reals, then it won't be holomorphic... or even continuous! This is why it's so important to restrict the principal square root to the slit plane
.
- The principal log
is holomorphic for the same reason. Its derivative is
(with domain being the slit plane).
Not everything is holomorphic.
- Unsurprising Counterexample:
is not holomorphic. It has a "sharp corner" at
.
- Surprising Counterexample:
is not holomorphic! Very roughly speaking, this is because conjugation messes up rotations.
(Holomorphic functions satisfy some really insanely cool properties. They're honestly miracles. We won't really talk about these miracles, though, since that would mak this post longer than it needs to be.)
Here is the motto I want you to take away from this lesson: Holomorphic functions are really nice, and you should not try and apply any of the theorems we talk about to functions that are not holomorphic. I can't guarantee that the numbers will work out if you do that. Fortunately, basically all sane things that you would consider integrating are holomorphic!
(Next part)
This post has been edited 1 time. Last edited by greenturtle3141, May 19, 2023, 5:18 AM