Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spurious I*pi in improper definite integral #23337

Open
oscarbenjamin opened this issue Apr 8, 2022 · 6 comments
Open

Spurious I*pi in improper definite integral #23337

oscarbenjamin opened this issue Apr 8, 2022 · 6 comments

Comments

@oscarbenjamin
Copy link
Contributor

The problem here is the I*pi in this integral:

In [57]: integrate(f, (x, 1, 3))
Out[57]: -- π

The antiderivative has a log term that gives an I*pi for x<3:

In [50]: f = 1/(x-3)

In [51]: F = integrate(f, x)

In [52]: F
Out[52]: log(x - 3)

In [53]: F.subs(x, 1)
Out[53]: log(2) + π

If this antiderivative is used to compute an integral where both limits are less than 3 then the term cancels:

In [54]: integrate(f, (x, 1, 2))
Out[54]: -log(2)

In [55]: F.subs(x, 2) - F.subs(x, 1)
Out[55]: -log(2)

If the upper limit is 3 though then F(3) is computed as something like limit(F(b), b, 3, '-'):

In [56]: F.limit(x, 3, '-')
Out[56]: -

Since limit removes the I*pi it doesn't cancel in the definite integral:

In [57]: integrate(f, (x, 1, 3))
Out[57]: -- π

Probably the fundamental theorem of calculus should be applied here as limit(F(b) - F(1), b, 3, '-') so that the I*pi cancels before taking the limit:

In [58]: b = symbols('b')

In [59]: (F.subs(x, b) - F.subs(x, 1))
Out[59]: log(b - 3) - log(2) - π

In [60]: (F.subs(x, b) - F.subs(x, 1)).limit(b, 3, '-')
Out[60]: -
@jksuom
Copy link
Member

jksuom commented Apr 8, 2022

1/(x - 3) is not locally integrable at x = 3, so a definite integral does not exist in a domain containing 3, but we can compute principal values:

In [13]: Integral(1/(x - 3), (x, 1, 4)).principal_value()                       
Out[13]: -log(2)

@oscarbenjamin
Copy link
Contributor Author

The integral does not exist but usually a divergent integral of definite sign is given as either oo or -oo:

In [98]: integrate(x, (x, 0, oo))
Out[98]: ∞

In [99]: integrate(1/x, (x, 0, 1))
Out[99]: ∞

In [100]: integrate(tan(x), (x, 0, pi/2))
Out[100]: ∞

These are all consistent with improper integrals as limits of proper integrals and the limit notion of oo.

@jksuom
Copy link
Member

jksuom commented Apr 9, 2022

It looks like the limit of x + I*pi should be oo + I*pi by default as x -> oo; that is, the imaginary part should be preserved. (But x + pi should become just oo.)

@oscarbenjamin
Copy link
Contributor Author

Currently limit ignores all finite parts if the result is infinite:

In [114]: limit(x+I, x, oo)
Out[114]: ∞

In [115]: limit(I*x+1, x, oo)
Out[115]: ∞⋅

In [116]: limit((1+I)*x + (1-I), x, oo)
Out[116]: ∞⋅sign(1 + )

How in general would you define what should be included? Is it just that the identity

limit(f(x), x, a) = limit(re(f(x)), x, a) + I*limit(im(f(x), x, a))

should hold? Then if either real or imaginary part has a finite limit that should be preserved regardless of if the other has an infinite limit?

@jksuom
Copy link
Member

jksuom commented Apr 9, 2022

That identity should probably hold. But the implementation should not be based on limit(re... and limit(im.. as real and imaginary parts tend to be complicated and have no derivatives (so are not meromorphic).

@anutosh491
Copy link
Member

How scale-able is this concept though . I see the error here but we might be seeing good amount of changes in even basic limits ( of functions involving branch cuts mainly) once we introduce this ! For eg

>>> log(0-)
log(0+) + I*Pi
>>> limit(log(x), x, 0, '-')
-oo + I*Pi    

I don't see wolfram making such considerations (splitting about re and im parts ) and then computing limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants