How to calculate $\int \frac{1}{1+\exp(-r\sin(tx))}\,dx$

155 Views Asked by At

How would one calculate the indefinite integral:

$$\int \frac{1}{1+\exp(-r\sin(tx))}\,dx,$$

where $r >0,t>0$ are some constants? Should I use series expansion? Definite integral solution would also be of assistance.

UPDATE:

This problem originates from my application of generalized linear models where my link function is a composition of a sigmoid and a sine function. I'm trying to formulate the Akaike information criterion for sinusoidal binary classifier.

3

There are 3 best solutions below

13
On BEST ANSWER

This is not an answer but it is too long for a comment.

If, as qbert suggested in a comment, we make the approximation $\exp(-r\sin(tx))\approx 1-r\sin(tx)$, we then have $$I=\int\frac{dx}{1+\exp\left(-r\sin(tx)\right)}\approx \int\frac{dx}{2-r \sin (t x)}=-\frac{2 \tan ^{-1}\left(\frac{r-2 \tan \left(\frac{t x}{2}\right)}{\sqrt{4-r^2}}\right)}{t\sqrt{4-r^2} }\tag 1$$

If we continue the expansion $$\exp(-r\sin(tx))\approx 1-r\sin(tx)+\frac 12 r^2 \sin^2(tx)$$ we can still integrate and get the ugly $$I\approx \frac{2 }{t\sqrt{3}}\left(\frac{\tan ^{-1}\left(\frac{r-\left(1+i \sqrt{3}\right) \tan \left(\frac{t x}{2}\right)}{\sqrt{-r^2+2 i \sqrt{3}-2}}\right)}{\sqrt{r^2+2-2 i \sqrt{3}}}-\frac{\tan ^{-1}\left(\frac{r-\left(1-i \sqrt{3}\right) \tan \left(\frac{t x}{2}\right)}{\sqrt{-r^2-2 i \sqrt{3}-2}}\right)}{\sqrt{r^2+2+2 i \sqrt{3}}}\right)\tag 2$$

Edit

Let $tx=y$ which makes $$I=\int\frac{dx}{1+\exp\left(-r\sin(tx)\right)}=\frac 1t \int \frac{dy}{1+\exp\left(-r\sin(y)\right)}$$ and compute $$J=\int_0^a \frac{dy}{1+\exp\left(-r\sin(y)\right)}$$ for a few values to get the following results $$\left( \begin{array}{ccccc} r & a & \text{exact} & (1) & (2) \\ 0.25 & 0.1 & 0.050312 & 0.050315 & 0.050312 \\ 0.25 & 0.2 & 0.101246 & 0.101267 & 0.101245 \\ 0.25 & 0.3 & 0.152791 & 0.152863 & 0.152789 \\ 0.25 & 0.4 & 0.204932 & 0.205101 & 0.204928 \\ 0.25 & 0.5 & 0.257646 & 0.257975 & 0.257636 \\ 0.25 & 0.6 & 0.310907 & 0.311470 & 0.310887 \\ 0.25 & 0.7 & 0.364681 & 0.365560 & 0.364644 \\ 0.25 & 0.8 & 0.418929 & 0.420216 & 0.418869 \\ 0.25 & 0.9 & 0.473609 & 0.475396 & 0.473517 \\ 0.25 & 1.0 & 0.528673 & 0.531053 & 0.528541 \\ & & & & \\ 0.50 & 0.1 & 0.050624 & 0.050635 & 0.050624 \\ 0.50 & 0.2 & 0.102491 & 0.102578 & 0.102488 \\ 0.50 & 0.3 & 0.155578 & 0.155875 & 0.155567 \\ 0.50 & 0.4 & 0.209852 & 0.210564 & 0.209816 \\ 0.50 & 0.5 & 0.265265 & 0.266665 & 0.265179 \\ 0.50 & 0.6 & 0.321759 & 0.324180 & 0.321583 \\ 0.50 & 0.7 & 0.379263 & 0.383092 & 0.378946 \\ 0.50 & 0.8 & 0.437698 & 0.443360 & 0.437174 \\ 0.50 & 0.9 & 0.496976 & 0.504919 & 0.496170 \\ 0.50 & 1.0 & 0.557002 & 0.567677 & 0.555831 \\ & & & & \\ 0.75 & 0.1 & 0.050936 & 0.050961 & 0.050936 \\ 0.75 & 0.2 & 0.103734 & 0.103935 & 0.103726 \\ 0.75 & 0.3 & 0.158357 & 0.159053 & 0.158318 \\ 0.75 & 0.4 & 0.214748 & 0.216435 & 0.214623 \\ 0.75 & 0.5 & 0.272828 & 0.276184 & 0.272521 \\ 0.75 & 0.6 & 0.332500 & 0.338375 & 0.331867 \\ 0.75 & 0.7 & 0.393651 & 0.403054 & 0.392499 \\ 0.75 & 0.8 & 0.456155 & 0.470221 & 0.454241 \\ 0.75 & 0.9 & 0.519874 & 0.539828 & 0.516918 \\ 0.75 & 1.0 & 0.584663 & 0.611767 & 0.580363 \\ & & & & \\ 1.00 & 0.1 & 0.051248 & 0.051292 & 0.051247 \\ 1.00 & 0.2 & 0.104975 & 0.105341 & 0.104957 \\ 1.00 & 0.3 & 0.161125 & 0.162410 & 0.161029 \\ 1.00 & 0.4 & 0.219610 & 0.222767 & 0.219298 \\ 1.00 & 0.5 & 0.280309 & 0.286674 & 0.279541 \\ 1.00 & 0.6 & 0.343080 & 0.354373 & 0.341490 \\ 1.00 & 0.7 & 0.407757 & 0.426074 & 0.404851 \\ 1.00 & 0.8 & 0.474159 & 0.501929 & 0.469328 \\ 1.00 & 0.9 & 0.542097 & 0.582009 & 0.534637 \\ 1.00 & 1.0 & 0.611372 & 0.666278 & 0.600530 \end{array} \right)$$

Edit

We can go further with as many terms as wished in the expansion of the exponential using $$1+\exp\left(-r\sin(y)\right)=2+\sum_{k=1}^n \frac{(-1)^k}{k!}(r\sin(y))^k$$ So, let the $a_i$'s to be the roots of the polynomial $$2+\sum_{k=1}^n \frac{(-1)^k}{k!}z^k=0$$ If $n$ is even, all roots will be complex; if $n$ is odd, only one real root.

Now, using partial fraction decomposition to get by the end $$\frac 1{2+\sum_{k=1}^n \frac{(-1)^k}{k!}(r\sin(y))^k}=n!\sum_{k=1}^n \frac {b_k}{r\sin(y)-a_k}$$ making $$\int \frac {dy}{2+\sum_{k=1}^n \frac{(-1)^k}{k!}(r\sin(y))^k}=2n!\sum_{k=1}^n \frac{b_k }{\sqrt{a_k^2-r^2}}\tan ^{-1}\left(\frac{r-a_k \tan \left(\frac{y}{2}\right)}{\sqrt{a_k^2-r^2}}\right)$$

Integrating for $0$ to $1$, we should get the following results $$\left( \begin{array}{ccccccc} r & \text{exact} & n=1 & n=2 & n=3 & n=4 & n=5 \\ 0.25 & 0.528673 & 0.531053 & 0.528541 & 0.528679 & 0.528673 & 0.528673 \\ 0.50 & 0.557002 & 0.567677 & 0.555831 & 0.557106 & 0.556994 & 0.557002 \\ 0.75 & 0.584663 & 0.611767 & 0.580363 & 0.585252 & 0.584599 & 0.584669 \\ 1.00 & 0.611372 & 0.666278 & 0.600530 & 0.613421 & 0.611072 & 0.611410 \\ 1.25 & 0.636895 & 0.736151 & 0.614934 & 0.642362 & 0.635901 & 0.637052 \\ 1.50 & 0.661057 & 0.830489 & 0.622695 & 0.673416 & 0.658420 & 0.661563 \\ 1.75 & 0.683742 & 0.968709 & 0.623655 & 0.708808 & 0.677773 & 0.685103 \\ 2.00 & 0.704888 & 1.204110 & 0.618349 & 0.752337 & 0.692940 & 0.708099 \end{array} \right)$$

5
On

I trust Wolfram alpha in that the indefinite integral is hopeless. However, if you happen to encounter this integrand as a definite integral over a symmetric interval, then things do work out nicely and you may compute as follows $$ I=\int_{-a}^a\frac{1}{1+\exp\left(-r\sin(tx)\right)}\mathrm dx= \int_{-a}^a\frac{1}{1+\exp\left(r\sin(tx)\right)}\mathrm dx $$ By a standard symmetry argument. Then, $$ 2I=\int_{-a}^a\frac{1}{1+\exp\left(-r\sin(tx)\right)}+ \frac{1}{1+\exp\left(r\sin(tx)\right)}\mathrm dx\\ =\int_{-a}^a\frac{2+\exp\left(-r\sin(tx)\right)+\exp\left(r\sin(tx)\right)}{2+\exp\left(-r\sin(tx)\right)+\exp\left(r\sin(tx)\right)}\mathrm dx=2a $$ and $I=a$.

Hope this helped!

1
On

Note that:

$$\sum _{n=0}^{\infty } (-\exp (-x))^n=\frac{1}{1+e^{-x}}$$

and:

$$\sum _{j=0}^{\infty } \frac{x^j}{j!}=\exp (x)$$

so,

$\color{red}{\int \frac{1}{1+\exp (-r \sin (t x))} \, dx}=\\ =\int \left(\sum _{n=0}^{\infty } (-1)^n e^{-n r \sin (t x)}\right) \, dx\\= \int \left(\sum _{n=0}^{\infty } \left(\sum _{j=0}^{\infty } \frac{(-1)^j n^j r^j \sin ^j(t x)}{j!}\right)\right) \, dx\\ =\sum _{n=0}^{\infty } \left(\sum _{j=0}^{\infty } \int \frac{(-1)^j n^j r^j \sin ^j(t x)}{j!} \, dx\right)\\ =\sum _{j=0}^{\infty } \left(\sum _{n=0}^{\infty } \frac{(-1)^{1+j+n} n^j r^j \cos (t x) \, _2F_1\left(\frac{1}{2},\frac{1-j}{2};\frac{3}{2};\cos ^2(t x)\right) \sin ^{1+j}(t x) \sin ^2(t x)^{-\frac{1}{2}-\frac{j}{2}}}{t j!}\right)\\ =\color{red}{\sum _{j=0}^{\infty } \frac{(-1)^{1+j} r^j \cos (t x) \, _2F_1\left(\frac{1}{2},\frac{1-j}{2};\frac{3}{2};\cos ^2(t x)\right) \sin ^{1+j}(t x) \sin ^2(t x)^{\frac{1}{2} (-1-j)} \left(2^j \zeta (-j,0)+\left(-1+2^j\right) \zeta (-j)\right)}{t j!}+C}$

where: $\, _2F_1\left(\frac{1}{2},\frac{1-j}{2};\frac{3}{2};\cos ^2(t x)\right)$ is Hypergeometric2F1

$ \zeta (-j,0)$,$\zeta (-j)$ is HurwitzZeta and Zeta.