0

I am asked to normalize a probability distribution P=A(x^2)(e^-x) within 0 to infinity by finding the value for A. I know the algorithms to calculate the Numerical value of Integration, but how do I deal with one of the limits being Infinity.

  • 1
    Your question is not clear. is it C or Fortran ? Also it is too vague. What did you implement and test ? Are you talking about floating point or integer implementation ? – Guillaume Petitjean Jan 22 '21 at 07:48
  • 1
    Why not calculating this integral by hand? (Hint: integration by parts) – Damien Jan 22 '21 at 07:54
  • Or just let [some algebra system compute it](https://www.wolframalpha.com/input/?i=Integrate+A*x%5E2*e%5E%28-x%29+from+0+to+infinity) – Vladimir F Героям слава Jan 22 '21 at 08:24
  • e^{-37} is practically zero, so the integral over [0,50] is the same as to infinity in floating point accuracy. Also check your library functions, some allow to give infinity as boundary. You might have to indicate regions/points-of-interest so that the integrator refines the subdivision where there are interesting segments. – Lutz Lehmann Jan 23 '21 at 19:32
  • I am asked to compute the integral without using library functions. Taking a very large value as the upper limit helps somewhat though. – HypnoticZebra Jan 23 '21 at 20:39

1 Answers1

0

The only way I have been able to solve this problem with some accuracy (I got full accuracy, indeed) is by doing some math first, in order to obtain the taylor series that represents the integral of the first.

I have been looking here for my sample code, but I don't find it. I'll edit my post if I get a working solution.

The basic idea is to calculate all the derivatives of the function exp(-(x*x)) and use the coeficients to derive the integral form (by dividing those coeficients by one more than the exponent of x of the above function) to get the taylor series of the integral (I recommend you to use the unnormalized version described above to get the simple number coeficients, then adjust the result by multiplying by the proper constants) you'll get a taylor series with good convergence, giving you precise values for full precision (The integral requires a lot of subdivision, and you cannot divide an unbounded interval into a finite number of intervals, all finite)

I'll edit this question if I get on the code I wrote (so stay online, and dont' change the channel :) )

Luis Colorado
  • 10,974
  • 1
  • 16
  • 31