Use Cauchy's integral formula (Theorem 4.2.4) along with its extension (Theorem 5.1) to compute
$$\int_{C_3(0)}\frac{e^{2z}}{(z-1)^2(z-2)}dz.$$
Note that this is part (i) of problem 3 from chapter 5. There are lots of similar problems there.
An integral using the extension of Cauchy’s integral formula
Edited.
Performing a partial fractions decomposition on the integrand, we find that
$$
\frac{1}{(z-1)^2(z-2)}=\frac{-1}{(z-1)^2}+\frac{-1}{z-1}+\frac{1}{z-2}.
$$
So the integral can be expressed
$$
\int_{C_3(0)}\frac{-e^{2z}}{(z-1)^2}\ dz+\int_{C_3(0)}\frac{-e^{2z}}{z-1}\ dz+\int_{C_3(0)}\frac{e^{2z}}{z-2}\ dz.
$$
Note both the poles $1$ and $2$ lie inside the circle of radius $3$ centered at $0$.
Using the Cauchy Integral Formula, we find that the second integral evaluates to $2\pi i(-e^{2\cdot1})=-2\pi ie^2$ and the third integral is $2\pi i(e^{2\cdot2})=2\pi ie^4$.
To solve the first integral, recall that
$$
f'(z_0)=\frac{1}{2\pi i}\int_\gamma\frac{f(z)}{(z-z_0)^2}\ dz.
$$
This implies
$$
\int_{C_3(0)}\frac{-e^{2z}}{(z-1)^2}\ dz=-2\pi i\bigg(\frac{1}{2\pi i}\bigg)\int_{C_3(0)}\frac{e^{2z}}{(z-1)^2}\ dz,
$$
which evaluates to $-2\pi i(2e^{2\cdot1})=-4\pi ie^2$.
So the sum of the integrals is $-4\pi ie^2-2\pi ie^2+2\pi ie^4=2\pi ie^2(e^2-3)$.
Thanks for the tip, @felyahia.
The fraction decomposition you made is not correct, check your calculations again
Let's add an additional path that separates 1 and 2. and let's integrate on two closed path $\gamma_1$ and $\gamma_2$ counterclockwise ($C_3(0)=\gamma_1\gamma_2$), the point 1 is inside $\gamma_1$ and outside $\gamma_2$, and the point 2 is inside $\gamma_2$ and outside $\gamma_1$.
$\int_{C_3(0)} \frac{exp(2z)}{(z-1)^2(z-2)}dz=\int_{\gamma_1} \frac{exp(2z)}{(z-1)^2(z-2)}dz+\int_{\gamma_2} \frac{exp(2z)}{(z-1)^2(z-2)}dz$
$\int_{\gamma_1} \frac{exp(2z)}{(z-1)^2(z-2)}dz=\int_{\gamma_1} \frac{exp(2z)/z-2}{(z-1)^2}dz$
the function $f_1(z)=\frac{exp(2z)}{z-2}$ is homolorphic on and inside $\gamma_1$ then by appying Cauchy theorem extension we get:
$\int_{\gamma_1} \frac{f_1(z)}{(z-1)^2}dz=2\pi i f'_1(1)$
= -6$\pi$i $exp(2)$
$\int_{\gamma_2} \frac{exp(2z)}{(z-1)^2(z-2)}dz=\int_{\gamma_2} \frac{exp(2z)/(z-1)^2}{(z-2)}dz$
=$\int_{\gamma_2} \frac{f_2(z)}{z-2}dz$
the function $f_2(z)=\frac{exp(2z)}{(z-1)^2}$ is homolorphic on and inside $\gamma_2$ then by appying Cauchy theorem we get:
$\int_{\gamma_2} \frac{f_2(z)}{(z-2)}dz=2\pi i f_2(2)$
=$2\pi i exp(4)$
Therefore
$\int_{C_3(0)} \frac{exp(2z)}{(z-1)^2(z-2)}dz=2\pi i$ exp(2)$(exp(2)-3)$
I used Mathematica to evaluate the integral with contour $\gamma(t)=3e^{it}$ and it came out to be the same as your answer. Nicely done.
Trying to solve this in python using:
$$\int_\gamma f(z)dz=\int_a^bf(\gamma(t))\cdot\gamma'(t)dt$$
Since Python's numerical integration does not support complex arguments, I have tried breaking the integral into real and imaginary parts. For some reason when I try to use scipy.real()
and scipy.imag()
to break the function values into their respective parts, I still get: TypeError: can't convert complex to float
My code is below, pretty short but still does not work. I was to believe that real
and imag
both returned floats since the real and imaginary parts of a complex numbers can be represented as ordered pairs of real numbers...
from scipy import integrate,real,imag
from numpy import pi
from math import exp
def complex_quad(integrand, a, b): #attempt to break the integral into its real and imaginary parts
def r(x):
return real(integrand(x)) #for some reason I get 'can't convert complex to float' here
def i(x):
return imag(integrand(x)) #probably here too, but the other one throws exception first
ri = integrate.quad(r, a, b) #real part of integral
ii = integrate.quad(i, a, b) #imaginary part
return (ri[0] + 1j*ii[0], ri[1:], ii[1:])
integrand=lambda t: ((exp(2*3*exp(t*1j)))/(((3*exp(t*1j)-1)**2)*(3*exp(t*1j)-2)))*3j*exp(t*1j)#integrand is(f(path(z))*dpath(z))
complex_quad(integrand,0,2*pi)##integral(f(path(z))*dpath(z)) from 0 to 2*pi