When I was reading a paper, I found an strange derivation like $$\int^{+\infty}_{-\infty}\mathrm{ln}(1+e^w)f(w)dw\\=\int^0_{-\infty}\ln(1+e^w)f(w)+\int^\infty_0[\ln(1+e^{-w})+w]f(w)dw$$ when $w$ is the normal random variable and $f(w)$ is the normal density.
Why is that natural log integration broken up into that?
I think it just need a simple principle.
Thank you.
Note that $1+e^{-w}=1+\frac{1}{e^{w}}=\frac{1+e^{w}}{e^{w}}$.
Taking the ln, we obtain $\ln(1+e^{-w})=\ln(\frac{1+e^{w}}{e^{w}})=\ln(1+e^{w})-\ln(e^{w})=\ln(1+e^{w})-w$
Therefore $\ln(1+e^{w})=\ln(1+e^{-w})+w$.
It follows that $\int_0^\infty \ln(1+e^{w}) f(w) dw =\int_0^\infty (\ln(1+e^{-w})+w) f(w) dw$.