Message Boards Message Boards

GROUPS:

Unexpected integration result?

Posted 2 months ago
441 Views
|
7 Replies
|
0 Total Likes
|

I am getting a strange integration result: the integral of the absolute value of a non-zero function gives me 0 as an output. There is a MWE in the attached notebook. Can give me a hint about how to solve the issue?

(I am using Mathematica 12.0.)

Screen capture of the code and evaluation result

Attachments:
7 Replies

The result is clearly wrong. However, it is not reasonable to expect Mathematica to solve a trascendental equation with two parameters to find where f=0. It can find a closed form when the parameters are numbers:

With[{\[Mu] = 2, \[Sigma] = 1},
 Integrate[
  Abs[f[x, \[Mu], \[Sigma]]], {x, -\[Infinity], \[Infinity]}]]
Posted 1 month ago

Indeed, the function to integrate is not among the easiest. However, I would have expected Mathematica to realise the problem cannot be solved instead of giving a wrong answer.

Moreover, elevating the function to the power 2 outputs what seems like a reasonable output. To which extent should I trust this result?

Assuming[{m > 0, s > 0}, 
 Integrate[f[x,m,s]^2, {x, -\[Infinity], \[Infinity]}]]

The square of f has a closed-form primitive. You can check against that.

Posted 1 month ago

The output of the primitive of the absolute value of f, namely "0", is also a closed form (even if not the correct one). How can I be sure that the second result is sound if the other one failed?

As for the primitive of Abs[ff[x,m,s]], I get back the input, not 0.

The square of ff is a simple sum of Gaussians, there is no problem in finding a primitive in terms of the error function Erf, and in calculating the limits at infinity.

Posted 1 month ago

Yes, without restriction over the parameters, the integral isn't computed. Adding the assumptions leads to the aforementioned strange result.

Posted 1 month ago

This is an interesting problem. Some remarks:

fm[x_, m_, s_] := Exp[-(x - m)^2/(2 s^2)]/s
fp[x_, m_, s_] := Exp[-(x + m)^2/(2 s^2)]/s
f2[x_, m_, s_] := Exp[-x^2/(2 (m^2 + s^2))]/Sqrt[m^2 + s^2]

Table[Plot[{fm[x, i, j], fp[x, i, j], f2[x, i, j]},
  {x, -10, 10}, PlotRange -> All],
 {i, 1, 3}, {j, 1, 3}]

ff[x_, m_, s_] := fm[x, m, s] + fp[x, m, s] - 2 f2[x, m, s]

Manipulate[
 Plot[{ff[x, i, j], Abs[ff[x, i, j]]},
  {x, -5, 5}, PlotRange -> {-1, 1}],
 {i, 1, 3}, {j, 1, 3}]

Integrate[Abs[ff[x, 1, 1]], {x, -Infinity, Infinity}] // N
NIntegrate[Abs[ff[x, 1, 1]], {x, -100, 100}]
Integrate[Abs[ff[x, 2, 1]], {x, -Infinity, Infinity}] // N
NIntegrate[Abs[ff[x, 2, 1]], {x, -50, 50}]


vtab = Table[
   {i, j, NIntegrate[Abs[ff[x, i, j]], {x, -50, 50}]},
   {i, 1, 3, .1}, {j, 1, 3, .1}];
ListPlot3D[Flatten[vtab, 1]]


tt = Table[{j, NIntegrate[Abs[ff[x, j, 1]], {x, -50, 50}]}, {j, 2, 20}];
ListLinePlot[tt]

It may be that the integral is bounded.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract