c(t)=t+I*t# parametrize the line. c(t):[0,1] -> line in C.
start=0stop=1N=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.
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 curve#The points are denoted z[0], z[1], ..., z[N]
sum(f(z[i])*(z[i+1]-z[i])foriinrange(0,N-1))# approximate integral of e^z dz on line
0.470416979755 + 2.28222422966*I
dc(t)=c.diff(t)# derivative of c(t)answer=integrate(f(c(t))*dc(t),(t,start,stop))# integrate using parametrizationanswer
e^(I + 1) - 1
float(answer.real_part())+float(answer.imag_part())*I#check if answer from parametrization agrees with approximation by taking its floating-point value
0.468693939916 + 2.28735528718*I
# As we can see based on our past 3 cells, problem #3 follows the parametrization, approximation, and especially the Funamental Theorem of Calculus.