Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
0

Wrong answer for complex integral with maxima

asked 0 years ago

Nate Eldredge gravatar image

I was trying to do the contour integral C|z1|2dz along the upper unit semicircle, and tried

t = var('t')
integrate(abs(exp(i*t)-1)^2*i*exp(i*t), (t,0,pi))

The answer returned was 83, which is wrong. The correct answer is 4iπ, which is given by the giac and sympy solvers.

It seems that maybe it is ignoring the absolute value, as we do have C(z1)2dz=83.

Is this a bug in Maxima and/or Sage, or am I doing something silly?

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
2

answered 0 years ago

dan_fulea gravatar image

Yes, the absolute value is omitted, as seen from integrating without limits, then differentiating the result:

sage: assume(t, 'real')
sage: integrate(abs( (exp(i*t) - 1)^2 ) * i * exp(i*t), t).diff().factor()
I*(e^(I*t) - 1)^2*e^(I*t)

The problem is that the machine was not really educated to take the absolute value correctly, here it must isolate the real and imaginary parts, compute the absolute value, then integrate this value. In giac we have the right answer:

sage: integrate(abs(exp(i*t) - 1)^2 * i * exp(i*t), (t, 0, pi), algorithm='giac')
-I*pi - 4

The expectation that the computer does and must do always the right thing is not really realistic. If it is a must, then the implementers must be written on a black list and punished. However, the implementers are on my list at the top, they did the best, and combined with human common sense and checks the work is almost always done.

In our case, let us explicitly help the integrator:

sage: integrate( (real(exp(i*t) - 1)^2 + imag(exp(i*t) - 1)^2) * i * exp(i*t), t, 0, pi)
-I*pi - 4

sage: integrate(abs((cos(t) + i*sin(t) - 1)^2) * i * exp(i*t), (t, 0, pi))
-I*pi - 4
Preview: (hide)
link
0

answered 0 years ago

Emmanuel Charpentier gravatar image

FWIW :

sage: var("t")
t
sage: integrate(abs(exp(i*t).demoivre()-1)^2*i*exp(i*t), (t,0,pi))
-I*pi - 4

HTH,

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 0 years ago

Seen: 233 times

Last updated: Apr 01 '24