Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168695
Image: ubuntu2004
# Integrate (z^2)/z-i on the unit circle around i with radius 1
f(z)=(z^2)/(z-I) #define the integrand
c(t) = cos(t)+I*sin(t)+I # paremeterized at 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 (z^2)/z-I
0.0322264759980253 - 6.28318319579892*I
dc(t)=c.diff(t) # derivative of c(t) answer = integrate(f(c(t))*dc(t),(t,start,stop)) #integrate using parameterization answer
-integrate((I*sin(t) + cos(t) + I)^2*(sin(t) - I*cos(t))/(I*sin(t) + cos(t)), t, 0, 6.28318530718)
float(answer.real_part())+float(answer.imag_part())*I # check if answer from parametrization agrees with approximation # by taking its floating-point value
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_27.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZmxvYXQoYW5zd2VyLnJlYWxfcGFydCgpKStmbG9hdChhbnN3ZXIuaW1hZ19wYXJ0KCkpKkkKIyBjaGVjayBpZiBhbnN3ZXIgZnJvbSBwYXJhbWV0cml6YXRpb24gYWdyZWVzIHdpdGggYXBwcm94aW1hdGlvbiAgICAgICAgICAgICAgICAgICAgICAgICAjIGJ5IHRha2luZyBpdHMgZmxvYXRpbmctcG9pbnQgdmFsdWU="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in <module> File "/tmp/tmpkh7q2f/___code___.py", line 2, in <module> float(answer.real_part())+float(answer.imag_part())*I File "expression.pyx", line 984, in sage.symbolic.expression.Expression.__float__ (sage/symbolic/expression.cpp:5685) TypeError: unable to simplify to float approximation
#Even though things dont seem to have gone well in this problem, even though all of input seems to be correct, we can see that the approximation is very close to -2*I*pi. And for the parameterization, Somehow it did not integrate, but if it were too, I would also be also to -2*I*pi