Hi PF!(adsbygoogle = window.adsbygoogle || []).push({});

I am trying to integrate functions over an infinite domain. One example is $$\int_0^\infty \frac{e^{-x}}{\sqrt{x}}\,dx$$ I know the substitution ##u = \sqrt{x}## reduces this problem to integrating ##\exp(-x^2)##, but if I want to integrate the function as is, how would I do this?

I've already tried Gauss-Legendre quadrature and Romberg integration. GL reports NaN and Romberg is evidently unable to handle the infinite limits.

Code (Python):

import numpy as np

import scipy

import scipy.linalg# SciPy Linear Algebra Library

from matplotlib import pyplot as plt# plotting

from scipy import integrate

f = lambda x: np.exp(-x)/np.sqrt(x)# function to integrate

a = 0# lower bound

b = np.inf# upper bound

toler = 10e-3# tolerance

exact = 1.772453850# exact value of integral

# Romberg Integration

I = integrate.romberg(f, a, b, rtol=toler, show=True, divmax=25)

# Gauss-Legendre Quadrature Integration

deg = 1# degree of Legendre poly

gauss = 0# initial guess

while abs(exact-gauss) > toler:

x, w = np.polynomial.legendre.leggauss(deg)

# Translate x values from the interval [-1, 1] to [a, b]

t = 0.5*(x + 1)*(b - a) + a

gauss = sum(w * f(t)) * 0.5*(b - a)

deg = deg + 1

print gauss

print deg

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Python Integrating to Infinity Numerically

Have something to add?

Draft saved
Draft deleted

Loading...

Similar Threads for Integrating Infinity Numerically |
---|

If statement for Monte Carlo integration |

Programming succesive trapezoidal integrator |

Python Numerical integration 'quad' error |

Numerical Integration with variable limits MATLAB |

C/++/# How to integrate when one of the limits is a variable? |

**Physics Forums | Science Articles, Homework Help, Discussion**