# Incorrect result for integral of (cos z) / z

I am confused by the following result: I'd like to integrate cos(z) / z on a circle around the origin. I tried:

var('z,t')

f = (cos(z))/z

show(f)

gamma = e^(i * t)

dg = gamma.diff(t)

h = f(z=gamma) * dg
print(h)
show(h.integrate(t, 0, 2 * pi))


and I get:

I*cos(e^(I*t))
0


If I put the same integral into WolframAlpha, I get the result I was expecting (2 pi i).

Is this a bug, or have I specified the problem incorrectly?

edit retag close merge delete

Sort by » oldest newest most voted Which version of sage do you use ? Mine gives

sage: h.integrate(t,algorithm='maxima')
1/2*Ei(I*e^(I*t)) + 1/2*Ei(-I*e^(I*t))
sage: h.integrate(t,algorithm='giac')
cos_integral(e^(I*t))
sage: h.integrate(t,algorithm='sympy')
cos_integral(e^(I*t))


So one problem is that maxima is not using the correct primitive.

But well, at least one of our integrator gives a correct result in sage 9.4.beta2 :

sage: h.integrate(t,0,2*π,algorithm='maxima')
0
sage: h.integrate(t,0,2*π,algorithm='giac')
2*I*pi
sage: h.integrate(t,0,2*π,algorithm='sympy')
0

more

My About tab says:

┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.1, Release Date: 2020-05-20                     │
│ Using Python 3.7.3. Type "help()" for help.                        │
└────────────────────────────────────────────────────────────────────┘