4

I am trying to solve for integral

But it is returning the same. I need this to complete my research. Please help.

The expression used by me in mathematica is:

Integrate[Log2[1+x^2]*(PDF[NormalDistribution[\[Mu], \[Sigma]], x]),{x,-Infinity,Infinity}]
  • 1
    If it is returning the same, then Mathematica does not want to compute it. Try doing it numerically. Also, if there's a next time, can you, please, consider posting your question appropriately? Thanks in advance! – bmf Mar 03 '23 at 04:13
  • Welcome to the Mathematica Stack Exchange. Please load Mathematica code (not an image) so that respondents can copy the same to their notebooks and experiment with it. How do you know that a closed-form solution exists for this integral? – Syed Mar 03 '23 at 04:14
  • While I have upvoted the answer by @BobHanlon as I find it useful, I am befuddled -to say the least- by the upvote in the question. Would the person who upvoted care to elaborate on the rationale? – bmf Mar 03 '23 at 05:50
  • The basic problem that I have to solve is: Find the expected value of log2(1+b*(x^2)) where x is a non-standard normal random variable and b is a constant – VIBHOR SINGAL Mar 03 '23 at 07:29
  • If b is close to zero we get: b Sqrt[2 \[Pi]] \[Sigma] (\[Mu]^2 + \[Sigma]^2). See: AsymptoticIntegrate[ E^(-((x - \[Mu])^2/(2 \[Sigma]^2))) Log[1 + b x^2], {x, -Infinity, Infinity}, {b, 0, 1}] – Mariusz Iwaniuk Mar 03 '23 at 10:54

3 Answers3

6

It is obvious to consider a numerical solution

int[\[Mu]_?NumericQ, \[Sigma]_?NumericQ] := 
NIntegrate[E^(-((x - \[Mu])^2/(2 \[Sigma]^2))) Log[1 + x^2]/(2 Pi \[Sigma] Log[2]), {x, -Infinity, \[Mu] - \[Sigma], \[Mu], \[Mu] + \[Sigma], Infinity} ]

Show[Table[ LogLogPlot[int[[Mu], [Sigma]], {[Sigma], .05, 10} ], {[Mu], Range[0, 2, .1]}] ]

enter image description here

addendum

Thanks to@yarchik's comment!

Knowing DiracDelta[x-\[Mu]]=Limit[E^(-((x - \[Mu])^2/(2 \[Sigma]^2)))/(Sqrt[2Pi]\[Sigma]),\[Sigma]->0] it follows

`int[\[Mu],0]==Log[1+\[Mu]^2]/(Sqrt[2Pi] Log[2])` 
Ulrich Neumann
  • 53,729
  • 2
  • 23
  • 55
  • I have a bit of doubts that your results at $\sigma\rightarrow0$ are accurate. Your graph shows that for $\mu=2$ and $\sigma=0$ the value is $\approx 3$, but it should be $\log(1+\mu^2)/\log(2)=\log(5)/\log(2)=2.3$. Notice that integral is trivial for $\sigma=0$. – yarchik Mar 03 '23 at 15:34
  • @yarchik Thanks for the hint , see my modified answer – Ulrich Neumann Mar 03 '23 at 16:06
4
Clear["Global`*"]

$Assumptions = μ ∈ Reals && σ > 0;

(int = Inactive[Integrate][
  Log2[1 + x^2] PDF[NormalDistribution[μ, σ], x],
  {x, -∞, ∞}])//TraditionalForm

enter image description here

The integral does not evaluate; however, when μ == 0

int0 = int /. μ -> 0 // Activate

(* -(1/(σ^2 Log[ 2]))(HypergeometricPFQ[{1, 1}, {3/2, 2}, 1/( 2 σ^2)] + σ^2 (EulerGamma - π Erfi[1/( Sqrt[2] σ)] + Log[2] - 2 Log[σ])) *)

Block[{$MaxExtraPrecision = 200}, LogLogPlot[int0, {σ, 10^-4, 10}, PlotRange -> All, PlotPoints -> 100, MaxRecursion -> 5, WorkingPrecision -> 120, AxesLabel -> (Style[#, 14] & /@ {HoldForm@σ, HoldForm@int0})]] // Quiet

enter image description here

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
  • The condition over μ and σ is very stringent, and we cannot consider it 0. Is there any other approximation that can be used? Thankyou for the help. – VIBHOR SINGAL Mar 03 '23 at 07:26
1

For the benefit of cut-and-pasters, there is an alternate form at the bottom.

$\text{expr}=\text{FullSimplify}[\text{PDF}[\text{NormalDistribution}[0,\sigma ],x]]$

$\frac{e^{-\frac{x^2}{2 \sigma ^2}}}{\sqrt{2 \pi } \sigma }$

$\text{Assuming}\left[\sigma \in \mathbb{R}\land \sigma >0,\int_{-\infty }^{\infty } \text{expr} \log \left(x^2+1\right) \, dx\right]$

$-\frac{\, _2F_2\left(1,1;\frac{3}{2},2;\frac{1}{2 \sigma ^2}\right)}{\sigma ^2}+\pi \text{erfi}\left(\frac{1}{\sqrt{2} \sigma }\right)+2 \log (\sigma )-\gamma -\log (2)$

The purpose of expr is to completely remove $\mu$ whixh is known to be 0 in this case.

The purpose of the Assuming first expresson is to inform Mathematica that $\sigma$ is positive real.

Perhaps, I missed something?

For the cut-and-pasters (afterwards, right click on the cell bracket and Convert to Standard Form):

expr = FullSimplify[PDF[NormalDistribution[0, \[Sigma]], x]]

1/(E^(x^2/(2[Sigma]^2))(Sqrt[2*Pi]*[Sigma]))

Assuming[Element[[Sigma], Reals] && [Sigma] > 0, Integrate[expr*Log[x^2 + 1], {x, -Infinity, Infinity}]]

-EulerGamma + PiErfi[1/(Sqrt[2][Sigma])] - HypergeometricPFQ[{1, 1}, {3/2, 2}, 1/(2*[Sigma]^2)]/ [Sigma]^2 - Log[2] + 2*Log[[Sigma]]


This also works:

$\text{Assuming}\left[\mu =0,\int_{-\infty }^{\infty } \log \left(x^2+1\right) \text{PDF}[\text{NormalDistribution}[\mu ,\sigma ],x] \, dx\right]$

Assuming[\[Mu] == 0, Integrate[PDF[NormalDistribution[\[Mu], \[Sigma]], x]*  
Log[x^2 + 1], {x, -Infinity, Infinity}]]