Re: Condition generation for complex integrals

*To*: mathgroup at smc.vnet.net*Subject*: [mg48928] Re: [mg48896] Condition generation for complex integrals*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>*Date*: Thu, 24 Jun 2004 05:35:44 -0400 (EDT)*References*: <200406220931.FAA10292@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

What is right and wrong in this type of question depends on the choice of path of integration. Mathematica by default integrates along straight lines and so to get the right answer it has to choose the correct branch of the integral. Obviously the algorithmic technology for dealing with branch cuts is still highly imperfect. Before version 5 appeared I used to have strong doubts about the desirability, at this stage, of returning answers to definite integrals in conditional form. But I remember quite a few postings to this list complaining about the old way of doing things and insisting on the desirability of the If[....] based approach... In fact, in my own work, on the the very few occasions recently when I needed to use Integrate with symbolic limits I found it convenient to use SetOptions[Integrate,GenerateConditions->False] which, I think, ought to be the default setting. However, there is one other thing that can be quite useful, if one knows what one is doing, of course. One can try telling Mathematica to integrate along a piecewise linear path rather than along a straight line. For example: FullSimplify[ Integrate[1/z, {z, z1, z2}] /. {z1 -> 1 - I, z2 -> -2}] (1/4)*(5*I*Pi + Log[4]) is wrong (if one is integrating along the straight line segment). But using the form: FullSimplify[Integrate[1/z, {z, z1, -1, z2}] /. {z1 -> 1 - I, z2 -> -2}] (1/4)*(-3*I*Pi + Log[4]) one can force the right answer for this particular choice of z1 and z2. Of course the answer is now wrong for a different choices of z1 and z2. If you use numerical limits Mathematica gets it right without any forcing: Integrate[1/z, {z, 1 - I, -2}] (1/4)*(-3*I*Pi + Log[4]) In fact the "wrong branch" answer that Mathematica returns FullSimplify[ Integrate[1/z, {z, z1, z2}] /. {z1 -> 1 - I, z2 -> -2}] (1/4)*(5*I*Pi + Log[4]) is the right answer for a different path, e.g.: FullSimplify[Integrate[1/z, {z, 1 - I, 1 + I, -2}]] (1/4)*(5*I*Pi + Log[4]) So one does have some control over these things and I doubt that one can expect much more in any near future. Andrzej Kozlowski Chiba, Japan http://www.mimuw.edu.pl/~akoz/ On 22 Jun 2004, at 18:31, Maxim wrote: > When generating conditional results for integrals in the complex > plane, Mathematica often fails even on elementary functions: > > In[1]:= > Integrate[1/z, {z, z1, z2}] > > Out[1]= > If[Im[z2] == 0 && Im[z1] > 0 || Im[z2] == 0 && Im[z1] < 0 || > Im[z2] > 0 && Im[z1] >= 0 || Im[z2] < 0 && Im[z1] <= 0 || > Im[z1] > 0 && Re[z1] > (Im[z1]*Re[z2])/Im[z2] && Im[z2] < 0 || > Im[z2] > 0 && Re[z1] > (Im[z1]*Re[z2])/Im[z2] && Im[z1] < 0, > -Log[z1] + Log[z2], <<1>>] > > This is wrong for z1=-1-I and z2=-1. I believe that the version 5.0.1 > gives a slightly different answer, splitting the above expression into > two If's, but the error still remains. And if the conditional output > is not strictly equivalent to the input expression, then it is worse > than incorrect -- it is misleading: the whole purpose of giving the > answer in the conditional form is to guarantee that the result will be > valid for all values of the parameters. > > Now let's modify the integrand and try > > Integrate[1/(z-I), {z, z1, z2}] > > One would expect to get a result similar to the above, with everything > shifted by I. Instead, there is an extremely complicated condition in > the output, which, incidentally, is also incorrect if z1 or z2 lies on > the branch cut, for example, if z1=-2 and z2=2I. Mathematica expresses > the antiderivative of 1/(z-I) in terms of ArcTan and Log[1+z^2] to > avoid complex numbers in the answer, but in order to obtain an > antiderivative with a simple branch cut structure the most logical > choice of course would be to write the antiderivative as Log[z-I]. > > Next, we can evaluate the third argument of the resulting If > expression to find the value of the integral under different > assumptions, thus potentially obtaining the complete answer for all > possible values of the parameters: > > In[2]:= > Evaluate //@ Integrate[Sqrt[z], {z, z1, z2}] > > Out[2]= > (-z1 + z2)* > If[(Im[z1] - Im[z2])*((-Im[z2])*Re[z1] + Im[z1]*Re[z2]) > 0 || > Im[z2]/(Im[z1] - Im[z2]) >= 0 || > Im[z1]/(-Im[z1] + Im[z2]) >= 0, > (2*(z1 + Sqrt[z1]*Sqrt[z2] + z2))/(3*(Sqrt[z1] + Sqrt[z2])), > If[Im[z1/(z1 - z2)] != 0 || Re[z1/(z1 - z2)] < 0 || > Im[z2/(-z1 + z2)] != 0 || Re[z2/(-z1 + z2)] < 0, > (2/3)*(z1/(Sqrt[z1] + Sqrt[z2]) + Sqrt[z2]), <<1>>]] > > It is possible to go on applying Evaluate, but the second If is > already incorrect for z1=-1-I, z2=-1+I. It seems that Mathematica > primarily knows how to deal with such examples in certain > predetermined cases and has trouble with explicitly specified > conditions: > > In[3]:= > Assuming[Re[z1] < 0 && Re[z2] < 0 && Im[z1] < 0 && Im[z2] > 0, > Integrate[Sqrt[z], {z, z1, z2}]] > Assuming[x1 < 0 && x2 < 0 && y1 < 0 && y2 > 0, > Integrate[Sqrt[z], {z, x1 + I*y1, x2 + I*y2}]] > > Integrate::idiv: Integral of Sqrt[z] does not converge on {z1,z2}. > > Out[3]= > Integrate[Sqrt[z], {z, z1, z2}] > > Out[4]= > If[Im[(x1 + I*y1)/(x1 - x2 + I*(y1 - y2))] != 0 || > Im[(x2 + I*y2)/(-x1 + x2 - I*y1 + I*y2)] != 0 || > Re[(x1 + I*y1)/(x1 - x2 + I*(y1 - y2))] < 0 || > Re[(x2 + I*y2)/(-x1 + x2 - I*y1 + I*y2)] < 0, > (2/3)*(-(x1 + I*y1)^(3/2) + (x2 + I*y2)^(3/2)), <<1>>] > > The last two examples are essentially identical, but for the first one > Mathematica gives an irrelevant message, and the answer to the second > one is simply incorrect if we take x1=-1, y1=-1, x2=-1, y2=1. Thus so > far the usefulness of this feature of Mathematica 5.0 seems rather > limited. > > Maxim Rytin > m.r at inbox.ru > > >

**References**:**Condition generation for complex integrals***From:*ab_def@prontomail.com (Maxim)