# Integral related to the softplus function

Let $$f(x) = \log(1+e^{2x+1}) - 2\log(1 + e^{2x}) + \log(1 + e^{2x-1}).$$ According to Wolfram Alpha, $$\int_{-\infty}^\infty f(x)\,dx = \frac 12.\tag{*}$$ $$f(x)$$ is a "bump function" built out of the softplus function $$y=\log(1 + e^x)$$, that I want to use as a kernel for nonparametric regression. I want to normalize $$f(x)$$ to have integral $$1$$, and the definite integral (*) gives the normalizing factor.

But I can't figure out how to do the integral by hand. Substitution gives (and Wolfram Alpha confirms) $$\int f(x)\,dx = \operatorname{Li}_2(-e^{2x}) - \frac12\operatorname{Li}_2(-e^{2x-1}) - \frac12\operatorname{Li}_2(-e^{2x+1}) + C,$$ where $$\operatorname{Li}_2(x)$$ is the dilogarithm function. I haven't had any success in applying dilogarithm identities to the above, though.

Can anyone give a derivation of $$(*)$$?

• Your real problem is to understand how to obtain this $\int_{-\infty}^\infty f(x)\,dx = \frac 12$? Btw from where is this problem? Oct 8, 2019 at 15:58
• Yes, exactly. The context of the question is that f(x) is a "bump function" built out of the softmax function y=log(1 + e^x), that I want to use as a kernel for nonparametric regression. I want to normalize f(x) to have integral 1, and the definite integral (*) gives the normalizing factor.
– fmg
Oct 8, 2019 at 16:30
• You may ignore this, as it's kinda off topic. But what is the use of all this in artificial intelligence? It looks interesting to me and I want to learn some AI too, mind sharing some tips? Oct 8, 2019 at 17:14
• The functions nf(x/n), n=1,2,... is a sequence of bump function centered at x=0. Such functions are typically used as kernels for nonparametric kernel regression. Since f(x) is a linear combination of translates of the softplus function, these regression functions are the outputs of a neural network with a single hidden layer with softplus activation. Softplus is a smooth approximation rectified linear function r(x)=max(x, 0), which is the kind of activation function you'll typically see in hidden layers of neural networks. Because it's smooth, softplus is often more convenient to work with.
– fmg
Oct 8, 2019 at 17:28

Equal to $$I(1/2)$$ where, for real $$a>0$$, \begin{align}I(a)&=\int_{-\infty}^{\infty}\log\frac{\cosh(x+a)\cosh(x-a)}{\cosh^2 x}\,dx\\&=\int_{-\infty}^{\infty}\int_{0}^{a}\left(\tanh(x+y)-\tanh(x-y)\right)\,dy\,dx\\&=\int_{0}^{a}\left.\log\frac{\cosh(x+y)}{\cosh(x-y)}\right|_{x=-\infty}^{x=\infty}\,dy=4\int_{0}^{a}y\,dy=2a^2.\end{align}
$$I=\int_{-\infty}^\infty \ln\left(\frac{(1+e^{2x}\cdot e)(1+e^{2x}/e)}{(1+e^{2x})^2}\right)dx\overset{e^{2x}\to x}=\frac12 \int_0^\infty\ln\left(\frac{(1+ex)(1+x/e)}{(1+x)^2}\right)\frac{dx}{x}$$ $$\overset{IBP}=\frac12\int_0^\infty \ln x \left(\frac{1}{1+x}-\frac{1}{e+x}\right)dx+\frac12\int_0^\infty \ln x \left(\frac{1}{1+x}-\frac{e}{1+ex}\right)dx$$
$$\int_0^\infty \ln x \left(\frac{1}{1+x}-\frac{e}{1+ex}\right)dx\overset{x\to \frac{1}{x}}=\int_0^\infty \ln x \left(\frac{1}{1+x}-\frac{1}{e+x}\right)dx$$ $$\Rightarrow I=\int_0^\infty \ln x \left(\frac{1}{1+x}-\frac{1}{e+x}\right)dx\overset{x\to \frac{e}{x}}=\int_0^\infty \ln \left(\frac{e}{x}\right) \left(\frac{1}{1+x}-\frac{1}{e+x}\right)dx$$
Summing up the two integrals from above gives: $$2I=\int_0^\infty \left(\frac{1}{1+x}-\frac{1}{e+x}\right)dx\Rightarrow I=\frac12 \ln\left(\frac{1+x}{e+x}\right)\bigg|_0^\infty=\frac12$$