rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

bug in PV evaluation #3862

Open rtoy opened 3 months ago

rtoy commented 3 months ago

Imported from SourceForge on 2024-07-08 20:10:24 Created by dprodanov on 2015-09-17 19:52:28 Original: https://sourceforge.net/p/maxima/bugs/3024


:::text
integrate(1/(1 - exp(%i*x))^(1/2), x, 0, 2*%pi);

The answer is 0 but should be 2 * %pi by the residue theorem. On the other hand, the case

:::text
integrate(1/(1 - exp(%i*x)), x, 0, 2*%pi);

is handled properly

rtoy commented 3 months ago

Imported from SourceForge on 2024-07-08 20:10:25 Created by rswarbrick on 2015-10-03 23:09:26 Original: https://sourceforge.net/p/maxima/bugs/3024/#2f85


One interesting fact is that if you ask Maxima to come up with an antiderivative, it succeeds:

:::text
(%i1) antideriv: integrate(1/(1 - exp(%i*x))^(1/2), x);

(%o1) %i*log(sqrt(1-%e^(%i*x))+1)-%i*log(sqrt(1-%e^(%i*x))-1)

and the real part of this expression goes from - %pi at x = 0 through to %pi at x = 2 * %pi, as you'd expect.

If you do the definite integral and trace the integrator function, you see it compute the following antiderivative:

:::text
(%i2) integrate(1/(1 - exp(%i*x))^(1/2), x, 0, 2*%pi);
  0: (INTEGRATOR
      ((MEXPT SIMP)
       ((MPLUS SIMP) 1
        ((MTIMES SIMP) -1 ((MEXPT SIMP) $%E ((MTIMES SIMP) $%I $X))))
       ((RAT SIMP) -1 2))
      $X)
    1: (INTEGRATOR
        ((MTIMES SIMP) -1 $%I
         ((MEXPT SIMP) ((MPLUS SIMP) 1 ((MTIMES SIMP) -1 $X))
          ((RAT SIMP) -1 2))
         ((MEXPT SIMP) $X -1))
        $X)
    1: INTEGRATOR returned
         ((MTIMES SIMP) -1 $%I
          ((MPLUS SIMP)
           ((%LOG SIMP)
            ((MABS SIMP)
             ((MPLUS SIMP) -1
              ((MEXPT SIMP) ((MPLUS SIMP) 1 ((MTIMES SIMP) -1 $X))
               ((RAT SIMP) 1 2)))))
           ((MTIMES SIMP) -1
            ((%LOG SIMP)
             ((MPLUS SIMP) 1
              ((MEXPT SIMP) ((MPLUS SIMP) 1 ((MTIMES SIMP) -1 $X))
               ((RAT SIMP) 1 2)))))))
  0: INTEGRATOR returned
       ((MPLUS SIMP)
        ((MTIMES SIMP) $%I
         ((%LOG SIMP)
          ((MPLUS SIMP) 1
           ((MEXPT SIMP)
            ((MPLUS SIMP) 1
             ((MTIMES SIMP) -1 ((MEXPT SIMP) $%E ((MTIMES SIMP) $%I $X))))
            ((RAT SIMP) 1 2)))))
        ((MTIMES SIMP) -1 $%I
         ((%LOG SIMP)
          ((MABS SIMP)
           ((MPLUS SIMP) -1
            ((MEXPT SIMP)
             ((MPLUS SIMP) 1
              ((MTIMES SIMP) -1 ((MEXPT SIMP) $%E ((MTIMES SIMP) $%I $X))))
             ((RAT SIMP) 1 2)))))))
(%o2) 0

which is:

:::text
(%o4) %i*log(sqrt(1-%e^(%i*x))+1)-%i*log(abs(sqrt(1-%e^(%i*x))-1))

(notice the abs functions). The imaginary parts agree, but the real parts do not.