Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168703
Image: ubuntu2004
#integrate 1/z on the unit circle
f(z)=1/z # define the integrand
c(t)=e^(I*t) # parameterize the unit circle c(t):[0,2pi]
start=0 stop=2*float(pi) N=1000
line_points = srange(float(start), float(stop), (stop-start)/N,include_endpoint=True) z = map(c,line_points)
sum(f(z[i])*(z[i+1]-z[i]) for i in range(0,N-1)) # approximate integral of 1/z on the unit circle
-0.019719404719 + 6.27686082159*I
dc(t)=c.diff(t) # derivative of c(t) answer=integrate(f(c(t))*dc(t),(t,start,stop)) # integrate using parametrization answer
6.28318530718*I
float(answer.real_part())+float(answer.imag_part())*I # check if answer from parametrization agrees with approximation by taking its floating-point value
6.28318530718*I
# As we can see based on our solutions, the appoximation formula and parameterization is approximately close to I*2*float(pi), or also know as 6.283185*I