Cauchy principal value integral




The correct value of integrate ( 1/x,  x,  -1, 2 ) 
 is log(2) = 0.693147..  when considered as a 
 principal value integral, since we can write this 
 as limit ( i1 + i2 + i3, eps,  0 ), where
  i1 = integrate(1/x,x,-1,-eps) = - integrate(1/x,x,eps,1)
          (change var x -> y = -x ),

i2 = integrate(1/x,x,eps,1),

i3 = integrate(1/x,x,1,2) = log(2)

so i1 + i2 = 0 before taking the limit eps -> 0.

1.  The maxima function integrate(...)  seems to know 
   something about "principal value", since a message is 
   printed to the screen, but integrate gets the wrong answer.

(%i1) (fpprintprec:8, display2d:false )$

(%i2) integrate(1/x,x,-1,2);
Principal Value
(%o2) log(2)+2*%i*%pi

We know the integral must be a real number, so
we know integrate(..) cannot be trusted here.
Integrate appears to be closing the complex plane
contour for a case where Jordan's lemma is not
satisfied?

2. ldefint attempts to use limit (...)  using the indefinite integral
   and gets the right answer, but this is only luck, since ldefint
  presumably does not know that we want to interpret this
  as a principal value integral. In fact if you work with the
  indefinite integral by hand, worrying only about the end 
  points (-1,2) you get totally different answer.

(%i3) ldefint(1/x,x,-1,2);
(%o3) log(2)

Not clear at all what ldefint is doing, since using limit
directly gives a completely different answer to
any of the other methods

(%i5) integrate(1/x,x);
(%o5) log(x)
(%i6) limit(%,x,2,minus) - limit(%,x,-1,plus);
(%o6) log(2)-log(-1)
(%i7) float(%);
(%o7) 0.693147-3.1415927*%i

4. Finally, quad_qawc returns the correct numerical
    value for log(2):

(%i4) quad_qawc(1,x,0,-1,2);
(%o4) [0.693147,0.0,25,0]
----------------------------------
Perhaps integrate should check the integrand 
against conditions of Jordan's lemma before
returning an answer which is wrong.

Ted Woollett