       Re: large integration result for simple problem: 1/x,, also BesselJ

• To: mathgroup at smc.vnet.net
• Subject: [mg122889] Re: large integration result for simple problem: 1/x,, also BesselJ
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Mon, 14 Nov 2011 07:08:24 -0500 (EST)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <201111110955.EAA08514@smc.vnet.net> <7999FCC4-7E77-4ED4-AEF6-AF3CCFAD0FA7@mimuw.edu.pl> <4EBD4CAB.1090505@eecs.berkeley.edu> <0CA89E70-9E70-4FC8-9E5D-4C16A4934A1F@mimuw.edu.pl> <4EBD5686.5030106@eecs.berkeley.edu> <0FB5E525-5B36-44A8-BB3C-D885A4902D1B@mimuw.edu.pl> <4EBD5BAF.1080300@eecs.berkeley.edu> <201111121233.HAA21872@smc.vnet.net>

```On 12 Nov 2011, at 13:33, Andrzej Kozlowski wrote:

>  Mathematica 8 answer to
> the other integral is different form that in v. 7:
>
> Integrate[1/x, {x, a, b}]
>
> ConditionalExpression[Log[b] - Log[a], ((Im[a] >= Im[b] && Re[a]*Im[b]
> <= Im[a]*Re[b]) ||
>    (Re[a]*Im[b] >= Im[a]*Re[b] && Im[a] <= Im[b])) && ((Re[a/(b -
> a)] >= 0 && a^2 != a*b) ||
>    NotElement[a/(a - b), Reals] || Re[a/(a - b)] >= 1)]
>
> I looks to me like a reasonable answer. ConditionalExpression has now
> replaced If, and it seems to be better integrated with Mathematica's
> Assumptions mechanisms than is the case with If. For example:
>
> Refine[ConditionalExpression[Sqrt[x^2], x > 0]]
>
> ConditionalExpression[x,x>0]
>
> while
>
> Refine[If[x > 0, Sqrt[x^2]]]
>
> If[x>0,Sqrt[x^2]]
>
>
> Andrzej
>

I have investigated this a little more. I think the interesting question here is not how nice is Mathematica's answer but how correct is it? In other words, when is it correct to apply the Newton-Leibniz rule to compute this integral and does Mathematica's get it right? Geometrically the answer is clear: the rule will work if the integration is done along a path not cutting the non-positive real axis. In fact, Mathematica's answer excludes all the cases where Newton-Leibniz's formula can't be used but it also excludes a narrow range of cases where it can. To see that, define a function

cond[a_, b_] := ((Im[a] >= Im[b] &&
Re[a]*Im[b] <= Im[a]*Re[b]) || (Re[a]*Im[b] >= Im[a]*Re[b] &&
Im[a] <= Im[b])) && ((Re[a/(b - a)] >= 0 && a^2 != a*b) ||
NotElement[a/(a - b), Reals] ||
Re[a/(a - b)] >= 1)

Consider the points

{a,b}={1/2+I/2,42/25+(69 I)/50};

Then

cond[a, b]

False

but

Log[b] - Log[a] ==
NIntegrate[1/x, {x, a, b}, WorkingPrecision -> 20]

True

Geometrically, you can see the situation clearly here:

Manipulate[Module[{a = toComplexNumber[u], b = toComplexNumber[v]},
Column[{Row[{cond[toComplexNumber[u], toComplexNumber[v]], "  ",
Chop[Log[b] - Log[a] - NIntegrate[1/x, {x, a, b}]] == 0, "  ", {a, b}}],
Show[Graphics[{Line[{u, v}], Red, Tooltip[Point[u], "a"], Blue, Tooltip[Point[v], "b"]}],
Axes -> True, PlotRange -> {{-2, 2}, {-2, 3}}]}]], {{u, {0.5, 0.5}}, {-2, -2}, {2, 21},
Locator}, {{v, {1, 1}}, {-2, -2}, {2, 2}, Locator},
Initialization :> {cond[a_, b_] = ((Im[a] >= Im[b] && Re[a]*Im[b] <= Im[a]*Re[b]) ||
(Re[a]*Im[b] >= Im[a]*Re[b] && Im[a] <= Im[b])) && ((Re[a/(b - a)] >= 0 && a^2 != a*b) ||
NotElement[a/(a - b), Reals] || Re[a/(a - b)] >= 1);
toComplexNumber[{x_, y_}] :=
Complex[x, y]}]

The Boolean variable (True or False) on the left shows where the Mathematica's condition of validity of the Newton_Leibniz rule holds. The Boolean variable to the right shows where it really holds. You will notice that you will never see a {True, False} combination of Boolean values but there is an area where we get {False,True} - in other words, the Newton-Leibniz formula holds while Integrate's cond returns False. This, however, is  to be expected and not a bad thing - it would be a different matter if the opposite happened.

I think it would be rather easy to change this particular case so that Mathematica would return the perfectly correct answer. After all, we know what it is and it is only a matter of writing it out algebraically. However, the point of Mathematica's approach to integration is that all answers should be derived by Mathematica using general algorithms. Improving just one answer or only a few "high profile" cases would not make Mathematica any better. It seems to me that the fact that Mathematica can get this much right without direct human intervention is quite impressive.

Andrzej Kozlowski

```

• Prev by Date: Re: how to plot new data points to pre-existing figure
• Next by Date: Re: Keeping track of variables used in Mathematica
• Previous by thread: Re: large integration result for simple problem: 1/x,, also BesselJ
• Next by thread: Re: large integration result for simple problem: 1/x,, also BesselJ