integration

41 days ago by bennettmeredith

# Let f(z)= z^5+2z^4+3z^3+4z^2+5z+6. Find the number of roots of f(z) inside the circles |z|=1 and |z|=2 by using the argument principle: the number of roots is the integral of f'(z)/f(z) around the circle divided by 2 pi i. The integral around the circle will be approximated numerically. 
       
f(z) = z^5+2*z^4+3*z^3+4*z^2+5*z+6 g(z) = f(z).diff()/f(z) # define the integrand g(z) 
       
(5*z^4 + 8*z^3 + 9*z^2 + 8*z + 5)/(z^5 + 2*z^4 + 3*z^3 + 4*z^2 + 5*z +
6)
(5*z^4 + 8*z^3 + 9*z^2 + 8*z + 5)/(z^5 + 2*z^4 + 3*z^3 + 4*z^2 + 5*z + 6)
c(t) = exp(i*t) # parametrize the circle |z|=1 
       
start = 0.0 stop = 2.0*float(pi) N = 1000 # c(t) maps the interval [start, stop] onto the curve where f(z) is to be integrated. N is number of points to use in approximation of integral. To integrate a different function on a different curve, you need change only the first four entries then execute everything. 
       
line_points = srange(float(start), float(stop), (stop-start)/N,include_endpoint=True) #N+1 points on [start, stop] z = map(c,line_points) #N+1 points on circle |z|=1 #The points are denoted z[0], z[1], ..., z[N] 
       
sum(g(z[i])*(z[i+1]-z[i]) for i in range(0,N-1))/(2.0*float(pi)*i) # approximate integral of g(z)=f'(z)/f(z) on circle |z|=1 divided by 2 pi i. This is the number of zeros of the polynomial inside the circle |z|=1. 
       
-0.00166666154841348 + 8.72683191798304e-6*I
-0.00166666154841348 + 8.72683191798304e-6*I
# The answer is closest to the integer 0, so there are no roots of f(z) inside the circle |z|=1 
       
c(t) = 2*exp(i*t) # parametrize the circle |z|=2 
       
start = 0.0 stop = 2.0*float(pi) N = 1000 # c(t) maps the interval [start, stop] onto the curve where f(z) is to be integrated. N is number of points to use in approximation of integral. To integrate a different function on a different curve, you need change only the first four entries then execute everything. 
       
line_points = srange(float(start), float(stop), (stop-start)/N,include_endpoint=True) #N+1 points on [start, stop] z = map(c,line_points) #N+1 points on circle |z|=2 #The points are denoted z[0], z[1], ..., z[N] 
       
sum(g(z[i])*(z[i+1]-z[i]) for i in range(0,N-1))/(2.0*float(pi)*i) # approximate integral of g(z)=f'(z)/f(z) on circle |z|=2 divided by 2 pi i. This is the number of zeros of the polynomial inside the circle |z|=2. 
       
4.99661704142290 + 0.0157107546470677*I
4.99661704142290 + 0.0157107546470677*I
# The answer is closest to the integer 5, so there are 5 roots of f(z) inside the circle |z|=2