Spence function
01-11-2021, 06:13 PM
Post: #1
 Albert Chan Senior Member Posts: 1,657 Joined: Jul 2018
Spence function
(01-08-2021 01:28 AM)Albert Chan Wrote:  For k=1, g(t) is simple enough that Wolfram Alpha can proof it (after a few seconds) I = ∫(ln((2+t)/(2-t)*(2t+1))/t, t = 0 .. 1) = pi^2/4

I just learned how to proof this, using Spence's function (dilogarithm) Break-up Integral to parts, and integrate each:

∫(ln(1+t/2)/t - ln(1-t/2)/t + ln(1+2t)/t) dt
= (-Li2(-t/2)) - (-Li2(t/2)) + (-Li2(-2t)) + C

I = -Li2(-1/2) + Li2(1/2) - Li2(-2)
﻿ ﻿ = LI2(1/2) - (Li2(-2) + Li2(-1/2))

Identity:﻿ ﻿ ﻿ ﻿ Li2(z) + Li2(1-z) = pi^2/6 - ln(z)*ln(1-z)
Let z=1/2: Li2(1/2) * 2 = pi^2/6 - ln(1/2)^2 = pi^2/6 - ln(2)^2

Identity﻿:﻿ ﻿ ﻿ ﻿ Li2(z) + Li2(1/z) = -pi^2/6 - ln(-z)^2/2
Let z=-2:﻿﻿ ﻿ ﻿ Li2(-2) + Li2(-1/2) = -pi^2/6 - ln(2)^2/2

I = (pi^2/6 - ln(2)^2)/2 - (-pi^2/6 - ln(2)^2/2) = pi^2/4
01-11-2021, 06:16 PM (This post was last modified: 01-12-2021 01:00 AM by Albert Chan.)
Post: #2
 Albert Chan Senior Member Posts: 1,657 Joined: Jul 2018
RE: Spence function
(01-07-2021 09:37 PM)Valentin Albillo Wrote: The funny thing about this integral is that its value remains the same if you replace 2.021 by any positive real value !!

I think Spence's function (Dilogarithms) is the key to proof I = pi^2/4, for any k

After transformation, we have I = ∫(g(t) dt, t = 0 .. 1)

$$\exp(g(t)·k\,t) = \Large {(1+(1+t)^k)·(1+({1\over t}+1)^k) \over (1+(1-t)^k)·(1+({1\over t}-1)^k)} = {(1+(1+t)^k)·(t^k+(1+t)^k) \over (1+(1-t)^k)·(t^k+(1-t)^k)}$$

For now, assume k is positive integer → numerator is polynomial of t, with degree 2k.

Let W = exp((2n+1)/k*pi*i), n = 0 .. k-1. In other words, W = roots of x^k = -1

roots of numerator﻿ ﻿ ﻿ , t = W-1, 1/(W-1)
roots of denominator, t = 1-W, 1/(W+1)

Consider just 1 of W (we have k of them), factor it out, scaled away k, and integrate:

$$\displaystyle \int _0^1 \ln\left( {(1-{t \over w-1})·(1-t(w-1)) \over (1-{t \over 1-w})·(1-t(w+1)) }\right) {dt \over t} \normalsize = -Li_2({1\over w-1}) + Li_2({1\over 1-w}) - Li_2(w-1) + Li_2(w+1)$$

I = average of all the k pieces, dropped imaginary parts (since I is real)

For example, for k = 7, these are the integral pieces.

>>> from mpmath import *
>>> Li2 = lambda x: polylog(2, x)
>>> k = 7
>>> W = [exp((2*n+1)/k*pi*1j) for n in range(k)]
>>> for w in W: print -Li2(1/(w-1)) + Li2(1/(1-w)) - Li2(w-1) + Li2(w+1)
...
(2.46740110027234 + 5.0951007958138j)
(2.46740110027234 + 2.21291211873152j)
(2.46740110027234 + 0.940187304494618j)
(2.46740110027234 + 1.22410719457408e-16j)
(2.46740110027234 - 0.940187304494618j)
(2.46740110027234 - 2.21291211873152j)
(2.46740110027234 - 5.0951007958138j)

All the real parts have the same size = pi^2/4 What happened if k is not integer ? Lets try k = 2.021
Amazingly, for any non-zero real k, real part of the integral piece still = pi^2/4

>>> w = exp(pi*1j/2.021)
>>> print -Li2(1/(w-1)) + Li2(1/(1-w)) - Li2(w-1) + Li2(w+1)
(2.46740110027234 + 1.85770404643526j)

Note: this only show how integral evaluated to the same value, for different k's
It is still not a proof, but much closer than what I had before ...
01-12-2021, 02:17 PM
Post: #3
 Albert Chan Senior Member Posts: 1,657 Joined: Jul 2018
RE: Spence function
Here is the proof for non-zero integer k, I = pi^2/4

Let A(w) = re(-Li2(1/(w-1)) + Li2(1/(1-w)) - Li2(w-1) + Li2(1+w))
Code:
  -Li2(1/(w-1)) - Li2(w-1)  +            Li2(1/(1-w))             + Li2(1+w) = (pi*pi/6 + ln(1-w)^2/2)   + (-pi*pi/6 - ln(w-1)^2/2 - Li2(1-w)) + Li2(1+w) = (ln(1-w)^2 - ln(w-1)^2)/2 + (Li2(1+w) - Li2(1-w)) = ln(-(1-w)^2) * (ln(1-w)-ln(w-1))/2 + (Li2(1+w) - Li2(1-w))

We like to show A(w) + A(-w) = pi^2/2, which implied I = average(A(W)) = pi^2/4
Using symmetry, we avoided calculations of Li2(x), since all will cancelled out. (*)

First factor, let w = c+s*i, where c=cos(x), s=sin(x), so that |w|=1
Code:
  -(1-w)^2  = -(1-c-s*i)^2  = -(1-c)^2     +   s^2   + 2*(1-c)*s*i = -(1-2*c+c^2) + (1-c^2) + 2*(1-c)*s*i = 2*(1-c)*c              + 2*(1-c)*s*i = 2*(1-c)*w Similar way, -(1+w)^2 = -2*(1+c)*w

Second factor, by definition, ln(x) = ln(|x|) + arg(x) * i

ln(x) - ln(-x) = (arg(x) - arg(-x)) * i = ±pi * i

Sign depends on phase angle. If we assume arg(w) > 0, we have

ln(1-w) - ln(-(1-w)) = -pi*i
ln(1+w) - ln(-(1+w)) = pi*i

re(ln(-(1-w)^2) * (ln(1-w) - ln(-(1-w)))) = arg(w) * pi
re(ln(-(1+w)^2) * (ln(1+w) - ln(-(1+w)))) = arg(-w) * -pi = (pi - arg(w)) * pi

A(w)﻿﻿ ﻿ = arg(w)*pi/2 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ + re(Li2(1+w) - Li2(1-w))
A(-w) = (pi - arg(w))*pi/2 + re(Li2(1-w) - Li2(1+w))

→ A(w) + A(-w) = pi^2/2 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ QED

Note that k does not appear anywhere in the proof.
So, as long as we pair w with -w, even for non-integer k, above should hold.

---
(*) For odd k, w=-1 does not have anyone to pair with, but evaluation is simple.

A(w) = re(ln(-(1-w)^2) * (ln(1-w)-ln(w-1))/2 + (Li2(1+w) - Li2(1-w)))
A(-1) = pi^2/2 - re(Li(2))

Identity: Li2(z) + Li2(1-z) = pi^2/6 - ln(z) * ln(1-z)
Let z=-1: Li2(-1) + Li2(2) = pi^2/6 - ln(-1) * ln(2)

Li2(-1) = -pi^2/12
Li2(2) = (pi^2/6 - Li2(-1)) - ln(2)*pi*i = pi^2/4 - ln(2)*pi*i

A(-1) = p^2/2 - pi^2/4 = pi^2/4

To keep the symmetry, we can assign A(1) = pi^2/4
01-12-2021, 05:28 PM (This post was last modified: 01-12-2021 05:35 PM by C.Ret.)
Post: #4 C.Ret Member Posts: 129 Joined: Dec 2013
RE: Spence function
(01-11-2021 06:13 PM)Albert Chan Wrote:  I just learned how to proof this, using Spence's function (dilogarithm) Break-up Integral to parts, and integrate each:

Wait a minute !

I just realize that I don't know how to integrate such an integral ; .

When the argument were any real number, I know how to get a rough numeric approximation using one of my useful and capable Hp calculators. Typing a short keystrokes code may help me to compute a value on my HP-15C.

For example,

Code:
g P/R f CLEAR PRGM  f LBL 2  1  -  CHS  g LN  X><Y  /  g RTN  g P/R 0  ENTER  .95  f Intyx 2     flashing runnin9 ....     -1.44063  CHS      1.44063

From this computation carry on my venerable HP-15C, I deduce that Li2( 0.95) ~= 1.44063

Is that right ? If not, what I have done the wrong way ?

But, I suddenly discover that I have no way when argument is a complex (even with Flag 8 Set to complex mode). I even don’t know how to proceed with paper & pencil to integrate in complex plane.

How are mathematicians dealing with the computation of, for example :

I will thanks anyone here who will be kid enough to lead me to the right procedure

best regards.
C.Ret
01-12-2021, 05:41 PM (This post was last modified: 01-31-2021 11:49 AM by Albert Chan.)
Post: #5
 Albert Chan Senior Member Posts: 1,657 Joined: Jul 2018
RE: Spence function
This post extended A(w) + A(-w) = pi^2/2, to a proof that A(w) = pi^2/4

Identity: Li2(z) + Li2(1-z) = pi^2/6 - ln(z)*ln(1-z)

Li2(1-w) = pi^2/6 - ln(w)*ln(1-w) - Li2(w)
Li2(1+w) = pi^2/6 - ln(-w)*ln(1+w) - Li2(-w)

Li2(1+w) - Li2(1-w) = ln(w)*ln(1-w) - ln(-w)*ln(1+w) + (Li2(w) - Li2(-w))

The reason for the conversion is because of this amazingly neat identity

$$\displaystyle\Re(Li_2(e^{iθ})) = \sum_{n=1}^∞ {\cos(nθ) \over n^2} = {\pi^2\over6} - {\pi θ \over 2} + {θ^2 \over 4},\qquad 0 ≤ θ ≤ 2\pi$$

Applying formula for arg(w = e^(ix)) range of (-pi, pi], we have a sawtooth pattern:

Li2(w) - Li2(-w) = pi^2/4 - |arg(w)|*pi/2

From previous post, we have (1±w)^2 = ±2*(1-c)*w, where c = re(w).
Thus, arg(1±w) = arg(w)/2, with possible shifts.

Excluding w = 1, i.e. range(arg(w)) = (-pi,0) + (0,pi]
Let a = arg(w), s = sign(a) = ±1

arg(w) = a
arg(-w) = a - s*pi
arg(1-w) = a/2 - s*pi/2
arg(1+w) = a/2

ln(±w) is pure imaginary, this make pulling out real parts of terms easy.

re(ln(w)*ln(1-w) - ln(-w)*ln(1+w)) = (-a)*(a/2-s*pi/2) + (a-s*pi)*(a/2) = 0

A(w) = re(-Li2(1/(w-1)) + Li2(1/(1-w)) - Li2(w-1) + Li2(1+w))
﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ = |arg(w)|*pi/2 ﻿+ re(Li2(1+w) - Li2(1-w)) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ // previous post, extended to all w
﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ = |arg(w)|*pi/2 ﻿+ re(Li2(w) - Li2(-w)) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ // all log terms disappeared
﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ = |arg(w)|*pi/2 ﻿+ pi^2/4 - |arg(w)|*pi/2
﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ = pi^2/4

Comment: This may be enough to show I = pi^2/4, for any non-zero real k.
01-12-2021, 07:49 PM
Post: #6
 Albert Chan Senior Member Posts: 1,657 Joined: Jul 2018
RE: Spence function
(01-12-2021 05:28 PM)C.Ret Wrote:
(01-11-2021 06:13 PM)Albert Chan Wrote:  I just learned how to proof this, using Spence's function (dilogarithm) Break-up Integral to parts, and integrate each:

Wait a minute !

I just realize that I don't know how to integrate such an integral ; .

Just move complex z inside the function. Let $$u = z\; x\;,\;du = z\;dx$$

$$\displaystyle Li_2(z) = - \int _0^1 {\ln(1-z\;x) \over x} dx$$

This substitution of variable give neat result. Example, let $$u = x^k\;,\;du = k\;x^{k-1}\;dx$$

$$\displaystyle -k \int _0^1 {\ln(1-x^k) \over x} dx = -k \int _0^1 {\ln(1-u) \over x} {du \over k\;x^{k-1}} = - \int _0^1 {\ln(1-u) \over u} du = Li_2(1) = {\pi^2 \over 6}$$

I thought above formula had something to do with Valentin's puzzle ... but no luck.
01-12-2021, 08:24 PM (This post was last modified: 01-14-2021 04:53 PM by C.Ret.)
Post: #7 C.Ret Member Posts: 129 Joined: Dec 2013
RE: Spence function
(01-12-2021 07:49 PM)Albert Chan Wrote:  Just move complex z inside the function. Let $$u = z\; x\;,\;du = z\;dx$$

$$\displaystyle Li_2(z) = - \int _0^1 {\ln(1-z\;x) \over x} dx$$

This substitution of variable give neat result. Example, let $$u = x^k\;,\;du = k\;x^{k-1}\;dx$$

$$\displaystyle -k \int _0^1 {\ln(1-x^k) \over x} dx = -k \int _0^1 {\ln(1-u) \over x} {du \over k\;x^{k-1}} = - \int _0^1 {\ln(1-u) \over u} du = Li_2(1) = {\pi^2 \over 6}$$

I thought above formula had something to do with Valentin's puzzle ... but no luck.

Thank you , for this quick response.

You exactly respond to my question. No more worries now about complex values in integration's limits.

Effectively, integrating from $$0$$ to $$z$$ on variable $$du$$ give the same integration as from $$0$$ to $$1$$ on variable $$dx$$ where $$x=\frac{u}{z}$$

You make my day. I learn something today. (I also discover that Latex is enable on this forum. Two nice discoveries in one post ).

As usual, a lot of nice people to meet here.
Thank you again.
01-12-2021, 11:24 PM
Post: #8
 Albert Chan Senior Member Posts: 1,657 Joined: Jul 2018
RE: Spence function
(01-12-2021 05:28 PM)C.Ret Wrote:  How are mathematicians dealing with the computation of, for example :

(01-12-2021 02:17 PM)Albert Chan Wrote:  Li2(-1) = -pi^2/12
Li2(2) = (pi^2/6 - Li2(-1)) - ln(2)*pi*i = pi^2/4 - ln(2)*pi*i

I was playing around, and tried integrating using Li2(2) as base.
0 to 2+3i → 0 to 2, then 2 to 2+3i

Turns out, we have to use the conjugate of the base.
Anyone knows how and when we apply the conjugate ?

XCas> b := pi^2/4 - ln(2)*pi*i ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ // Li2(2)
XCas> float(b)
2.46740110027 - 2.1775860903*i

XCas> conj(b) - i*int(ln(-1-x*i)/(2+x*i), x = 0. .. 3) ﻿ ﻿ ﻿ // let u = 2+x*i, du = i*dx
-0.280988055379 + 3.01725120637*i

XCas> -int(ln(1-(2+3i)*x)/x, x = 0. .. 1) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ // confirmed Li2(2+3i)
-0.280988055378 + 3.01725120637*i

FYI, picking a closer base speed up integration. (about 5X for above example)
The problem is how to make it right ...
01-13-2021, 05:47 PM
Post: #9
 Albert Chan Senior Member Posts: 1,657 Joined: Jul 2018
RE: Spence function
(01-12-2021 05:41 PM)Albert Chan Wrote:  re(ln(w)*ln(1-w) - ln(-w)*ln(1+w)) = (-a)*(a/2-s*pi/2) + (a-s*pi)*(a/2) = 0

Part of the prove for I = pi^2/4 involved proving above statement.

It may be more elegantly done using geometry arg(w) = ∠COB = θ
arg(1+w) = ∠CAB = θ/2, since |w| = 1

arg(-w) = β = θ ± pi, sign = sign(-θ)
arg(1-w) = arg(-(1+w)) = β/2

re(ln(w)*ln(1-w) - ln(-w)*ln(1+w)) = (-θ)(β/2) + (β)(θ/2) = 0
01-14-2021, 01:55 PM (This post was last modified: 01-14-2021 03:10 PM by Albert Chan.)
Post: #10
 Albert Chan Senior Member Posts: 1,657 Joined: Jul 2018
RE: Spence function
(01-12-2021 11:24 PM)Albert Chan Wrote:  I was playing around, and tried integrating using Li2(2) as base.
0 to 2+3i → 0 to 2, then 2 to 2+3i

Turns out, we have to use the conjugate of the base.
Anyone knows how and when we apply the conjugate ?

By experiments, I figured out how and when to apply conjugate, but don't know why ...
Consider only imaginery part. If Spence integral limits has 1 positive, but the other not, apply conjugate.

>>> from mpmath import *
>>> mp.pretty = True
>>> Li2 = lambda x: polylog(2, x)
>>> F = lambda a, b: quad(lambda x: -ln(1-x)/x, [a, b])

>>> Li2(2+3j)
(-0.28098805537806 + 3.01725120636941j)
>>> F(0, 2+3j)
(-0.28098805537806 + 3.01725120636941j)

>>> conj(Li2(2)) + F(2, 2+3j) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ # 2 is real, no positive imaginery part
(-0.280988055378061 + 3.01725120636941j)

Say, we have Li2(1-1j), how to correct it to Li2(2+3j) ?
We interpolate (1-1j), (2+3j) at the real axis.

x = x1 - y1*(x1-x2)/(y1-y2)﻿ = 1 - (-1)*(1-2)/(-1-3) = 1.25

>>> a, b, x = 1-j, 2+3j, 1.25
>>> conj(Li2(a) + F(a,x)) + F(x,b) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ # == conj(Li2(x)) + F(x,b)
(-0.28098805537806 + 3.01725120636941j)

---

Without a close reference, we could use these identities to convert argument.

#1: Li2(z) + Li2(z/(z-1)) = -ln(1-z)^2/2
#2: Li2(z) + Li2(1-z) = ﻿ pi^2/6 - ln(z) * ln(1-z)
#3: Li2(z) + Li2(1/z) = -pi^2/6 - ln(-z)^2/2

We have to be careful with #3 to get Li2(z), if Li2(z) is real, but Li2(1/z) is complex.
This may be why https://mathworld.wolfram.com/Dilogarithm.html excluded it.

>>> z = 0.95
>>> Li2(z) , -pi**2/6 - ln(-z)**2/2 - Li2(1/z) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ # bad
(1.44063379697004, (1.44063379697004 + 0.322285273652695j))
>>> z = 1/0.95
>>> Li2(z) , -pi**2/6 - ln(-z)**2/2 - Li2(1/z) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ # ok
((1.84791883570185 - 0.161142636826347j), (1.84791883570185 - 0.161142636826347j))

For b = 2+3j, it is ok to apply. 1/b is tiny enough we can sum, instead of integrate.

>>> x = 1/b﻿
>>> s = sum(x**k/(k*k) for k in range(24,0,-1)) # Li2(x)
>>> -pi**2/6 - ln(-b)**2/2 - s
(-0.280988055378061 + 3.01725120636941j)﻿﻿ ﻿ ﻿ ﻿ ﻿ ﻿ # Li2(b)

The other 2 identities seems safe ...

#1: Li2(2+3j) = -ln(-1-3j)^2/2 - Li2(1.1-.3j)
#2: Li2(1.1-.3j) = pi^2/6 - ln(1.1-.3j)*ln(-.1+.3j) - Li2(-.1+.3j)

>>> x = -.1 + .3j
>>> s = sum(x**k/(k*k) for k in range(24,0,-1)) # Li2(x)
>>> s = pi**2/6 - ln(1.1-.3j)*ln(-.1+.3j) - s ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ # Li2(1-x)
>>> -ln(-1-3j)**2/2 - s ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ # Li2(b)
(-0.28098805537806 + 3.01725120636941j)
01-14-2021, 03:30 PM
Post: #11
 Albert Chan Senior Member Posts: 1,657 Joined: Jul 2018
RE: Spence function
(01-14-2021 01:55 PM)Albert Chan Wrote:  >>> a, b, x = 1-j, 2+3j, 1.25
>>> conj(Li2(a) + F(a,x)) + F(x,b) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ # == conj(Li2(x)) + F(x,b)
(-0.28098805537806 + 3.01725120636941j)

This is how WolframAlpha interpret F(a, b):

∫(-ln(1-x)/x, x = 1-I .. 2+3I)
= (Li2(2+3I) - conj(Li2(1.25))) + (Li2(1.25) - Li2(1-I))
= (Li2(2+3I) - Li2(1-I)) + (Li2(1.25) - conj(Li2(1.25)))
= (Li2(2+3I) - Li2(1-I)) + 2I * im(Li2(1.25))

Do not calculate F(a, b) directly !
Because of the discontinuity crossing the real axis, it it very hard to evaluate accurately.

Since we are interested with Li2(2+3I), interpolation of integral limits is not necessary.
Any real x will do. Preferably Li2(x) is also real, so no need to worry about conjugates.

>>> pi*pi/6 + F(1, 2+3j) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ # x = 1
(-0.280988055378061 + 3.01725120636941j)

This simple shift doubled the speed of integration, compared against F(0, 2+3j)
01-31-2021, 03:24 PM (This post was last modified: 01-31-2021 08:18 PM by Albert Chan.)
Post: #12
 Albert Chan Senior Member Posts: 1,657 Joined: Jul 2018
RE: Spence function
Chaos in Numberland: The secret life of continued fractions, by John D. Barrow

In this great article, there was an identity that we can prove, using Spence function.
(section: What is chaos ?, equation 36, where h = Kolmogorov, or metric, entropy of the mapping) Do integration by parts, where $$u = \ln(x), v = \ln(1+x)$$

$$\displaystyle \int {\ln(x) \over 1+x}\,dx = \int \ln(x)\,d(\ln(1+x)) = \ln(x)\ln(1+x)\;+ \int {-\ln(1+x) \over x}\,dx$$

Adding limit of integration, x = 0 to 1, last term = Li2(-1)

At x=1, uv = ln(1) ln(2) = 0
At x=0, uv = ln(0) ln(1) = -∞ * 0 = ?

Note: At x=0, v = ln(1+x) = 0 , v' = 1/(1+x) = 1

$$\displaystyle \lim_{x \to 0} {u \over v^{-1}} = \lim_{x \to 0} {u' \over -v^{-2}\;v'} = \lim_{x \to 0} {-v^2 \over x} = \lim_{x \to 0} {-2v\,v' \over 1} = 0$$

Or, we can avoid repeated applications of L'Hospital rule, by letting x = 1/n

$$\displaystyle \lim_{ x \to 0}\,(uv) = \lim_{n \to ∞} \left[ \left({-\ln(n) \over n}\right) \ln\left(\left(1+{1\over n}\right)^n\right) \right] = (-0) (1) = 0$$

For n → ∞, n ≫ ln(n) ; e = limit((1+1/n)^n, n=inf), by definition

Either way, uv term disappered, and we are left with last term, Li2(-1) = -pi^2/12

$$\displaystyle h = {-2 \over \ln(2)} \int_0^1 {\ln(x) \over 1+x}\,dx = {-2 \over \ln(2)} {-\pi^2 \over 12} = {\pi^2 \over 6\ln(2)}$$
04-04-2021, 10:57 PM
Post: #13
 Albert Chan Senior Member Posts: 1,657 Joined: Jul 2018
RE: Spence function
(03-24-2017 05:12 PM)emece67 Wrote:  $\int_{-1}^\infty{\ln(x+1)\over x^2+1}dx={3\pi\ln(2)\over8}\approx0.8165947838638507989377583368391052\ldots$

I was curious to the proof of this. Turns out, it can be solved using Spence function.
Break up integral to three parts, then normalized to unit interval.

$$\displaystyle \int_{-1}^0 + \int_0^1 + \int_1^∞ = \int_0^1 \left[ {\ln(1-x)\over 1+x^2} + {\ln(1+x)\over 1+x^2} + {\ln(1+{1\over x})\over 1+x^2} \right]dx = \int_0^1 \left[ {\ln(1-x)\over 1+x^2} + {2\ln(1+x)\over 1+x^2} - {\ln(x)\over 1+x^2} \right]dx$$

(01-12-2021 07:49 PM)Albert Chan Wrote:  Just move complex z inside the function. Let $$u = z\; x\;,\;du = z\;dx$$

$$\displaystyle Li_2(z) = - \int _0^1 {\ln(1-z\;x) \over x} dx$$

What is interesting is the first term. To match above form, we integrate from the right.

$$\displaystyle I_1 =\int_0^1 {\ln(1-x)\over 1+x^2} dx = \int_0^1 {\ln(x)\;dx\over 1+(1-x)^2}$$

Do integration by part, u=-ln(x), v=atan(1-x), ∫u dv = u*v - ∫v du

$$\displaystyle I_1 = -\ln(x)\;atan(1-x)\bigg|_0^1\; +\int_0^1 {atan(1-x) \over x}\;dx$$

We have -∞ + ∞ !!!
But, if we left it alone for a while, infinity cancelled (08-22-2020 04:10 PM)Albert Chan Wrote:
Code:
erf (-x) = - erf(x)    → erf (ix) = i erfi(x) tan (-x) = - tan(x)    → tan (ix) = i tanh(x) tanh(-x) = - tanh(x)   → tanh(ix) = i tan(x)

tan(x) = i tanh(-xi) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ → atan(x) = i atanh(-xi)
atanh(x) = 1/2*ln((1+x)/(1-x)) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ → atan(x) = i/2 * ln((1-xi)/(1+xi)) = i/2 * ln((i+x)/(i-x))

$$\displaystyle \int_0^1 {atan(1-x) \over x}\;dx = \int_0^1 {{i\over2} \ln\left({i+(1-x) \over i-(1-x)}\right)\over x}\;dx = {i\over2} \int_0^1 \left[ {\ln\left({1+i \over -1+i}\right)\over x} + {\ln\left(1-{x \over 1+i}\right)\over x} - {\ln\left(1-{x \over 1-i}\right)\over x} \right]\;dx$$

i/2 * ln((1+i)/(-1+i)) = i/2 * ln(-i) = i/2 * (-i*pi/2) = pi/4
The other 2 terms have Li2 form, we are ready for I1 now.

$$\displaystyle I_1 = \ln(x)\left({\pi\over4}-atan(1-x)\right)\bigg|_0^1\; + {i\over2} \left( Li_2({1\over1-i}) - Li_2({1\over1+i})\right)$$

Using L'Hospital Rule, first term is zero.
I1 = i/2*(Li2(1/(1-i)) - Li2(1/(1+i))) = pi*log(2)/8-C ≈ -0.643767

The other terms are done similarly ...
04-05-2021, 03:24 AM (This post was last modified: 04-05-2021 04:01 PM by Albert Chan.)
Post: #14
 Albert Chan Senior Member Posts: 1,657 Joined: Jul 2018
RE: Spence function
(04-04-2021 10:57 PM)Albert Chan Wrote:  The other terms are done similarly ...

My mistake, only last term can be done similar way.

Quote:$$\displaystyle \int_{-1}^0 + \int_0^1 + \int_1^∞ = \int_0^1 \left[ {\ln(1-x)\over 1+x^2} + {\ln(1+x)\over 1+x^2} + {\ln(1+{1\over x})\over 1+x^2} \right]dx = \int_0^1 \left[ {\ln(1-x)\over 1+x^2} + {2\ln(1+x)\over 1+x^2} - {\ln(x)\over 1+x^2} \right]dx$$

To save time, I confirm my math in XCas (simplify Li2 mess using Wolfram Alpha)

I3 = int(-ln(x)/(1+x*x), x=0..1.)
﻿ ﻿ ﻿ ﻿ = preval(-ln(x)*atan(x),0,1) + int(atan(x)/x, x=0..1.)
﻿ ﻿ ﻿ ﻿ = i/2 * int(ln(1-x*i)/x - ln(1+x*i)/x, x=0..1.)
﻿ ﻿ ﻿ ﻿ = i/2 * (Li2(-i)-Li2(i))
﻿ ﻿ ﻿ ﻿ = C ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ // Catalan's constant ≈ 0.915966

Using indefinite formula (confirmed by taking the derivative to match):

$$\displaystyle \int {\ln(x+a) \over x+b}\;dx = Li_2\left( {x+a \over a-b} \right) + \ln(x+a) \ln\left({x+b \over b-a} \right)$$

I2 = 2 * int(ln(1+x)/(1+x^2), x=0..1)
﻿ ﻿ ﻿ ﻿ = i * int(ln(1+x)/(x+i) - ln(1+x)/(x-i), x=0..1)
﻿ ﻿ ﻿ ﻿ = i * preval(F(x), 0, 1)

F(x) = Li2((1+x)/(1-i)) - Li2((1+x)/(1+i)) + log(1+x)*(log((i+x)/(i-1)) - log((i-x)/(i+1))) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ (*)
F(1) = Li2(1+i) - Li2(1-i) - i*log(2)*pi = 2i*C - i/2*log(2)*pi
F(0) = Li2(1/(1-i)) - Li2(1/(1+i)) = 2i*C - i/4*log(2)*pi

I2 = i*(F(1) - F(0)) = 1/4*log(2)*pi

I1 = i/2*(Li2(1/(1-i)) - Li2(1/(1+i))) = 1/8*log(2)*pi - C, from previous post

$$\displaystyle\int_{-1}^∞{\ln(x+1)\over 1+x^2}dx = I = I_1 + I_2 + I_3 = {3\over8}\ln(2)\,\pi$$

---

(*) difference of logs may not be combined, into log(i*(x+i)/(x-i))
Example:

$$\displaystyle \int {\ln(-x-a) \over x+b}\;dx = Li_2\left( {x+a \over a-b} \right) + \ln(-x-a) \ln\left({x+b \over b-a} \right)$$

Difference is *NOT* $$\displaystyle \int {\ln(-1) \over x+b}\;dx = i\pi\ln(x+b)$$

For the same reason, log(x*y) may not be splitted, to log(x) + log(y)
Previous post had this bug (which turns out not to matter, trying to match Li2 form)

Now that we have F(x), we can confirm again I1 is correct.

I1 = i/2*(F(0) - F(-1)) = i/2*F(0) = 1/8*log(2)*pi - C
04-05-2021, 04:58 PM (This post was last modified: 04-05-2021 11:29 PM by Albert Chan.)
Post: #15
 Albert Chan Senior Member Posts: 1,657 Joined: Jul 2018
RE: Spence function
I = i/2*(F(∞)-F(-1)) = i/2*F(∞) = 3/8*log(2)*pi

→ F(∞) = (-3i/4)*log(2)*pi ≈ -1.63319*i

>>> Li2 = lambda x: polylog(2,x)
>>> F1 = lambda x: Li2((1+x)/(1-j)) - Li2((1+x)/(1+j))
>>> F2 = lambda x: ln(1+x)*((ln((j+x)/(j-1)) - ln((j-x)/(j+1))))
>>> F = lambda x: F1(x) + F2(x)
>>> print F(1e18)
(0.0 - 1.6331895677277j)

Numerically, numbers agreed, suggesting F(x) is indeed correct.
We may be able to proof this:

Examining F1(x), Li2 arguments are complex conjugate of each other.
Conjugate symmetry applied to polylog functions, Lip(z) = Σ(zk/kp, p=1..inf)

With Li2(conj(z)) = conj(Li2(z)), F1 is purely imaginery.

F1 = 2*im(Li2((1+x)/(1-j))) * i

(01-14-2021 01:55 PM)Albert Chan Wrote:  #3: Li2(z) + Li2(1/z) = -pi^2/6 - ln(-z)^2/2

F1/i
= 2*im(Li2(z)) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ -- z = (1+x)/(1-j) = (1+x)/2 + (1+x)/2*i
≈ -im(ln(-z)^2) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ -- apply #3. when z is big, Li2(1/z) ≈ 0
= -im((ln(abs(z)) - 3/4*pi*i)^2)
= 3/2*pi*ln(abs(z))
= 3/2*pi*ln((1+x)/sqrt(2))
= 3/2*pi*ln(1+x) - 3/4*ln(2)*pi

F2/ln(1+x) = ln((i+x)/(i-1)) - ln((i-x)/(i+1))

RHS, arguments inside log are also conjugate of each other.
As expected, F2 is also purely imaginery.

Cas> simplify(conj((i+x)/(i-1)) - (i-x)/(i+1)) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ → 0

F2/ln(1+x)/i
= 2*arg((i+x)/(i-1))
= 2*arg((1-x) - (1+x)*i)
≈ 2*arg(-x - x*i) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ -- when x grows big, +1 has little effect
= -3/2*pi

F(∞) = limit(F1+F2, x=∞) = -3/4*ln(2)*pi*i

→ I = i/2*F(∞) = 3/8*ln(2)*pi

---

An efficient way to integrate, for $$\large\int_{-1}^x$$

>>> I = lambda x: ln(1+x)*atan2(1+x,1-x) - im(Li2((1+x)*(.5+.5j)))
>>> for x in range(5): print x, I(x)
...
0 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ -0.643767332889269
1 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ -0.371569071601318
2 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ -0.0888721439284095
3 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ 0.0860509375677831
4 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ 0.200606431044641

>>> I(1e18)
mpf('0.81659478386384876')
04-11-2021, 03:22 AM
Post: #16
 Albert Chan Senior Member Posts: 1,657 Joined: Jul 2018
RE: Spence function

Very beautiful ! We can proof I the same way, just different integral limits.

I = int(ln(1+x)/(1+x²), x=-1 .. ∞) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ // x=tan(θ), dx = sec(θ)^2 dθ
﻿ ﻿ = int(ln(1+tan(θ)), θ=-pi/4 .. pi/2)
﻿ ﻿ = int(ln(√2), θ=-pi/4 .. pi/2) + int(ln(cos(θ-pi/4)) - ln(cos(θ)), θ=-pi/4 .. pi/2)

When we fold the second term, it disappeared !

∫(f(x), x=a..b) = ∫(f(x) + f(a+b-x), x=a..b) / 2

int(ln(cos(θ-pi/4)) - ln(cos(θ)) + ln(cos(-θ)) - ln(cos(pi/4-θ)), θ=-pi/4 .. pi/2) / 2 = 0

All is left is the first term, I = 3/8*ln(2)*pi
05-04-2021, 03:17 PM
Post: #17
 Albert Chan Senior Member Posts: 1,657 Joined: Jul 2018
RE: Spence function
(04-11-2021 03:22 AM)Albert Chan Wrote:  I = int(ln(1+x)/(1+x²), x=-1 .. ∞) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ // x=tan(θ), dx = sec(θ)^2 dθ
﻿ ﻿ = int(ln(1+tan(θ)), θ=-pi/4 .. pi/2)
﻿ ﻿ = int(ln(√2), θ=-pi/4 .. pi/2) + int(ln(cos(θ-pi/4)) - ln(cos(θ)), θ=-pi/4 .. pi/2)

Simplify steps, tan(θ) = sin(θ)/cos(θ), then cos(θ) + sin(θ) = √(2)*cos(θ-pi/4) can all be skipped.
Folding tan(θ) integrand directly is easier.

I = ∫(ln(1+tan(θ)), θ=-pi/4 .. pi/2)
2*I = ∫(ln(1+tan(α)) + ln(1+tan(β)), α=-pi/4 .. pi/2) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ // where α = θ, β = pi/4 - α
﻿ ﻿ ﻿ ﻿ ﻿ ﻿ = ∫(ln(1 + tan(α) + tan(β) + tan(α)*tan(β)), α=-pi/4 .. pi/2)

tan(α+β) = (tan(α) + tan(β)) / (1 - tan(α)*tan(β)) = tan(pi/4) = 1

1 + tan(α) + tan(β) + tan(α)*tan(β) = 1 + (1 - tan(α)*tan(β)) + tan(α)*tan(β) = 2

2*I = ∫(ln(2), α=-pi/4 .. pi/2)

I = ln(2) * (pi/2 + pi/4) / 2 = 3/8*ln(2)*pi « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)