# Computing $\int _0^{\infty }e^{-b x} x^{b-1} \log \left((1-a x)^2\right)dx$ or $\mathbb E \log\left[(c- \chi^2_{2b} )^2\right]$

For $$a>0,b\geq 1$$, what is the value of the following integral?

$$\int _0^{\infty }e^{-b x} x^{b-1} \log \left((1-a x)^2\right)dx$$

Motivation: I need the following expectation for random variable $$X$$ where $$2b X$$ is distributed as Chi-squared with $$2b$$ degrees of freedom:

$$E \log\left[(1-a X)^2\right]$$

The corresponding integral is

$$\int_0^\infty \frac{\left(\frac{1}{b}\right)^{-b} e^{-b x} x^{b-1} \log \left((1-a x)^2\right)}{\Gamma (b)}$$

Mathematica gets the following formulas for $$b=1,\ldots,6$$ in terms of $$\operatorname{Ei}(x)=-\int_{-z}^\infty e^{-t}/t \mathbb{d}t$$

$$\begin{array}{ll} b=1&-2 e^{-1/a} \text{Ei}\left(\frac{1}{a}\right)\\ b=2&2-\frac{2 (a+2) e^{-2/a} \text{Ei}\left(\frac{2}{a}\right)}{a}\\ b=3&\frac{3 a (a+1)-(2 (a+3) a+9) e^{-3/a} \text{Ei}\left(\frac{3}{a}\right)}{a^2}\\ b=4&\frac{a ((11 a+16) a+16)-2 (3 ((a+4) a+8) a+32) e^{-4/a} \text{Ei}\left(\frac{4}{a}\right)}{3 a^3}\\ b=5&\frac{5 a ((2 (5 a+9) a+25) a+25)-(4 (3 (2 (a+5) a+25) a+125) a+625) e^{-5/a} \text{Ei}\left(\frac{5}{a}\right)}{12 a^4}\\ b=6&\frac{a ((((137 a+288) a+486) a+648) a+648)-12 (5 ((((a+6) a+18) a+36) a+54) a+324) e^{-6/a} \text{Ei}\left(\frac{6}{a}\right)}{30 a^5} \end{array}$$

What is the general formula in terms of $$b$$?

The code to compute the formulas (takes about 2 minutes to run)

$Assumptions = {x > 0, a > 0}; dist[n_] = TransformedDistribution[x/n, x \[Distributed] ChiSquareDistribution[n]]; pdf[n_, x_] = PDF[dist[n], x]; mean[b_?IntegerQ] := Integrate[Log[(1 - a x)^2] pdf[2 b, x], {x, 0, 1/a, \[Infinity]}]; formulas = FullSimplify@mean[#] & /@ Range[6]  Background Solving for $$a$$ in $$E[\log(1-a X^2)^2]=0$$ gives the largest convergent learning rate for linear least squares mini-batch SGD with batch size $$2b$$, step size $$a$$ and observations $$X$$ distributed as standard normal in $$d=1$$ dimensions. Batch-size 1 case is also known as LMS filter. Stability of LMS filter w.r.t. to step size is not fully understood, so characterizing it completely for a simple case of Gaussian observations is interesting. Related discussion here addresses the issue of convergence with batch size 1 and $$d\ge 1$$ Curiosuly, 1d iteration appears to become more unstable with increased batch size. In other words, applying random iteration several times and averaging updates at each step, can turn a stable random iteration into an unstable one. Notebook • Can you please write the expectation for$b\in\Bbb N$as an integral explicitly ? Commented Jan 18 at 13:11 • @Yaroslav Bulatov The Mathematica code you included evaluates$2 E[ \log(1-a X) ] $rather than the quantity you mention in your question. Commented Jan 18 at 16:19 • @Yaroslav Bulatov: Can you provide some motivation for your question? Why are you interested in this problem? Commented Jan 18 at 16:20 • @ТymaGaidash added explicit integral Commented Jan 18 at 19:03 • @Przemo added brackets to avoid ambiguity and background Commented Jan 18 at 19:06 ## 3 Answers If you are interested I found a compact formula in the case of $$a\in\mathbb{R}\setminus\{0\}$$ and $$b\in(0,\infty)$$: Using Feymann's trick: $$F(n)=\int_{0}^{\infty}e^{-bx}x^{b-1}(1-ax)^n dx$$ $$\int_{0}^{\infty}e^{-bx}x^{b-1}\ln((1-ax)^2) dx=2F'(0)$$ $$F(n)=\int_{0}^{\infty}e^{-bx}x^{b-1}\sum_{k=0}^{n}\binom{n}{k}\left(-ax\right)^{k}dx$$ $$F(n)=\sum_{k=0}^{n}\binom{n}{k}\left(-a\right)^{k}b^{-b-k}\Gamma\left(b+k\right)$$ Using the $$6$$th formula from function.wolfram.com $$U(a,a+n,z)=z^{-a}\sum_{k=0}^{n-1}\binom{n-1}{-k+n-1}(a)_k z^{-k}$$ $$U(a,a+n+1,z)=\frac{z^{-a}}{\Gamma(a)}\sum_{k=0}^{n}\binom{n}{k}\Gamma(a+k) z^{-k}$$ $$\sum_{k=0}^{n}\binom{n}{k}\Gamma(a+k) z^{-k}=\Gamma(a)z^{a}U(a,a+n+1,z)$$ $$F(n)=\Gamma(b)\cdot \left(-\frac{1}{a}\right)^{b}U\left(b,b+n+1,-\frac{b}{a}\right)$$ $$\bbox[15px,#E0EFFF,border:5px groove #0058B3]{\int_{0}^{\infty}e^{-bx}x^{b-1}\ln\left((1-ax)^{2}\right)dx=2\Gamma(b)\cdot \Re\left[\left(-\frac{1}{a}\right)^{b}U^{(0,1,0)}\left(b,b+1,-\frac{b}{a}\right)\right]}$$ Where: • $$U(a,b,z)$$ is the Tricomi confluent hypergeometric function • $$\displaystyle U^{(0,1,0)}(a,b,z):=\frac{\partial}{\partial b}U(a,b,z)$$ Example with random numbers: $$a=2.8$$ and $$b=4.32$$ • How would you take the real part? Commented Jan 19 at 13:12 • @ТymaGaidash the short answer is that since he is using Wolfram he can simply write "Re" in the command. The long answer is that it must transform$U(a,b,-z)$in terms of$U(a,b,z)$and the hypergeometric function$_1F_1$and then since$z>0$it takes the real part in a simple way considering$(-1)^b=e^{\pi i b}$. Here the transformation: functions.wolfram.com/HypergeometricFunctions/HypergeometricU/… However, even this way the formula works and is very compact Commented Jan 19 at 14:00 • @MathAttack nice! Curious, how did you find this function? Commented Jan 19 at 21:21 • @YaroslavBulatov functions.wolfram.com/HypergeometricFunctions/HypergeometricU/… the 6th formula, I'll add it to the answer so it's more complete. Commented Jan 20 at 1:16 With help of Mathematica. $$\int_0^{\infty } e^{-b x} x^{-1+b} \ln \left((1-a x)^2\right) \, dx=\color{blue}{\\\frac{2\Gamma (b)}{b^b} \left(\ln \left(\frac{a}{b}\right)+\psi(b)\right)+\frac{2\pi}{b^{b}} G_{4,3}^{2,2}\left(\frac{a}{b}\left| \begin{array}{c} 0,1-b,\frac{1}{2},1 \\ 0,0,\frac{1}{2} \\ \end{array}\right. \right)}$$ Using Mellin,Inverse Mellin transform and some tricks: $$\int_0^{\infty } e^{-b x} x^{-1+b} \ln \left((1-a x)^2\right) \, dx=\\\underset{t\to 0}{\text{lim}}\frac{\partial }{\partial t}\left(\int_0^{\infty } e^{-b x} x^{-1+b} (1-a x)^{2 t} \, dx\right)=\\\mathcal{M}_s^{-1}\left[\underset{t\to 0}{\text{lim}}\frac{\partial }{\partial t}\left(\int_0^{\infty } \mathcal{M}_a\left[e^{-b x} x^{-1+b} (1-a x)^{2 t}\right](s) \, dx\right)\right](a)=\\\mathcal{M}_s^{-1}\left[\underset{t\to 0}{\text{lim}}\frac{\partial }{\partial t}\left(\int_0^{\infty } \frac{e^{-b x} (-x)^{-s} x^{-1+b} \Gamma (s) \Gamma (-s-2 t)}{\Gamma (-2 t)} \, dx\right)\right](a)=\\\mathcal{M}_s^{-1}\left[\underset{t\to 0}{\text{lim}}\frac{\partial }{\partial t}\frac{(-1)^{-s} b^{-b+s} \Gamma (b-s) \Gamma (s) \Gamma (-s-2 t)}{\Gamma (-2 t)}\right](a)=\\\mathcal{M}_s^{-1}\left[\underset{t\to 0}{\text{lim}}\frac{2 (-1)^{-s} b^{-b+s} \Gamma (b-s) \Gamma (s) \Gamma (-s-2 t) (-\psi ^{(0)}(-s-2 t)+\psi ^{(0)}(-2 t))}{\Gamma (-2 t)}\right](a)=\\\mathcal{M}_s^{-1}\left[-2 (-1)^{-s} b^{-b+s} \Gamma (b-s) \Gamma (-s) \Gamma (s)\right](a)=\\\mathcal{M}_s^{-1}\left[\frac{2 (-1)^{-s} b^{-b+s} \pi \csc (\pi s) \Gamma (b-s)}{s}\right](a)=\\\mathcal{M}_s^{-1}\left[\frac{2 b^{-b+s} \pi \Gamma (1-s) \Gamma (b-s) \Gamma (s)^2}{\Gamma \left(\frac{1}{2}-s\right) \Gamma \left(\frac{1}{2}+s\right) \Gamma (1+s)}\right](a)=\\\color{blue}{\\\frac{2\Gamma (b)}{b^b} \left(\ln \left(\frac{a}{b}\right)+\psi(b)\right)+\frac{2\pi}{b^{b}} G_{4,3}^{2,2}\left(\frac{a}{b}\left| \begin{array}{c} 0,1-b,\frac{1}{2},1 \\ 0,0,\frac{1}{2} \\ \end{array}\right. \right)}$$ Inverse Mellin Transfrom for: $$-1<\Re(s)<0$$ where: $$G_{4,3}^{2,2}\left(\frac{a}{b}| \begin{array}{c} 0,1-b,\frac{1}{2},1 \\ 0,0,\frac{1}{2} \\ \end{array} \right)$$ is the Meijer G-function. MMA code: 2 b^-b Gamma[b] Log[a/b] + 2 b^-b \[Pi] MeijerG[{{0, 1 - b}, {1/2, 1}}, {{0, 0}, {1/2}}, a/b] + 2 b^-b Gamma[b] PolyGamma[0, b] MeijerG function can be expressed by hypergeometric function: $$G_{4,3}^{2,2}\left(\frac{a}{b}| \begin{array}{c} 0,1-b,\frac{1}{2},1 \\ 0,0,\frac{1}{2} \\ \end{array} \right)=-\frac{b \Gamma (-1+b) \, _3F_3\left(1,1,\frac{3}{2};2-b,\frac{3}{2},2;-\frac{b}{a}\right)}{a \pi }+\frac{\left(\frac{a}{b}\right)^{-b} \Gamma (1-b) \Gamma (b)^2 \, _3F_3\left(b,b,\frac{1}{2}+b;b,\frac{1}{2}+b,1+b;-\frac{b}{a}\right)}{\Gamma \left(\frac{1}{2}-b\right) \Gamma \left(\frac{1}{2}+b\right) \Gamma (1+b)}$$, but for: $$b\in \mathbb{Z}$$ is removable singularity Numericall check: • Could you numerically check the final solution for the exmple considered in the other answer? I think the G-function you found can be expressed as a generalized hypergeometric function, these cases are given here en.m.wikipedia.org/wiki/Meijer_G-function – Amir Commented Jan 20 at 15:08 • A clarification:I did not vote down your answer. Just made some comments to understand your solution better. – Amir Commented Jan 20 at 16:58 • Thanks for the update! What do you mean by "... but for:$b\in \mathbb{Z}$and$b>0$is singular." Does it work for real$b>0\$.
– Amir
Commented Jan 20 at 17:10
• @Amir If I gives b=1 Mathematica say: Indeterminate expression,Maple gives: Error, (in GAMMA) numeric exception: division by zero.,you need use a Limit.Which is why MeijerG is better than Hypergeometric function. ` Commented Jan 20 at 17:17

I focus on the given expectation:

$$\mathbb E \log\left[(1-a X)^2\right]$$

for random variable $$X$$ where $$2bX$$ is distributed as Chi-squared with $$2b$$ degrees of freedom. Let $$Y$$ denote a chi-sqaured RV with $$2b$$ degrees of freedom. Then,

$$\mathbb E \log\left[(1-a X)^2\right]=2\log(\frac{a}{2b})+\mathbb E \log\left[\left (\frac{2b}{a}- Y \right )^2\right]=2\log(\frac{a}{2b})+f_b\left (\frac{2b}{a} \right).$$

where $$f_b$$ is defined as follows:

$$f_b(c):=\mathbb E \log\left[\left (c- Y_{2b} \right )^2\right].$$

Now I derive a simple recursive formula to find $$f_b$$ based on $$f_{b-1}$$. As $$Y_{2b}=Y_{2(b-1)}+Y_2$$

where $$Y_{2(b-1)}, Y_2$$ are independent, we can write

$$f_b(c)=\mathbb E \log\left[\left (c-Y_2- Y_{2(b-1)} \right )^2\right]=\mathbb E \left[f_{b-1}(c-Y_2)\right]=\int_0^\infty f_{b-1}\left(c-x\right) \, \dfrac{1}{2} \mathrm{e}^{-\frac{x}{2}} dx.$$

Hence, the recurrence relation:

$$f_1(c)=2\ln\left(c\right)+2\operatorname{E}_1\left(-\dfrac{c}{2}\right)\,\mathrm{e}^{-\frac{c}{2}}=2\ln\left(c\right)-2\operatorname{Ei}\left(\dfrac{c}{2}\right)\,\mathrm{e}^{-\frac{c}{2}}$$

$$f_b(c)=\int_0^\infty f_{b-1}\left(c-x\right) \, \dfrac{1}{2} \mathrm{e}^{-\frac{x}{2}} dx$$

can be used to calculate $$f_b(c)$$ recursively; note that $$\operatorname{Ei}'(x)=\frac{e^{-x}}{x}$$ can be used along with integration by parts.

Based on your calculations for $$b=1,\dots,6$$, I doubt that a simple formula for $$f_b(c)$$ for any $$b\in \mathbb N$$ can be derived.

If one guesses a general formula, this recurrence can be used to prove it by induction.