Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168698
Image: ubuntu2004
#Integrate z on the unit circle from 0 to 2pi
f(z) = z # define the integrand
c(t) = e^(I*t) # parameterize the 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)) # The approximating formula
-5.92166523229e-05 - 0.00628289591791*I
dc(t)=c.diff(t) #derivative of c(t) answer=integrate(f(c(t))*dc(t),(t,start,stop)) #integrating using parameterization answer
-2.44929359829e-16*I
float(answer.real_part())+float(answer.imag_part())*I #check if answer from parametrization agrees with approximation by taking its floating-point value
-2.44929359829e-16*I
# As we can see based on the solutions of the approximating sum, the parameterization, we see that the solution is very very close to "0"