I want to approximate $\Gamma(a)$ by using the trapezoidal rule and Simpson's rule. The concrete exercise I am doing suggests rewriting the integral to avoid $f(\infty)$. The rewriting goes like this:
$ \Gamma(a)= \int_{{0}}^{\infty} x^{\alpha-1}e^{-x} \,dx\ = \int_{{0}}^{1} x^{\alpha-1}e^{-x} \,dx\ + \int_{0}^{1} x^{-1-\alpha}e^{-1/x} \,dx\ $
Let's first use the trapezoidal rule. I know that the general form is:
$ \int_{{a}}^{b} f(x) \,dx\ \approx \frac{f(a)+f(b)}{2}(b-a)\ $
So I was thinking of applying the trapezoidal rule to the first integral and then to the second integral, and then I could add up the two approximations as the final approximation. Let's apply this method to the first integral:
$ \int_{{0}}^{1} x^{\alpha-1}e^{-x} \,dx\ \approx \frac{f(0)+f(1)}{2}(1-0)\ = \frac{e^{-1}}{2} $
No problem. But if I wan't to do the same thing to the next integral, then $f(a)=f(0)$ involves division by zero. So what am I doing wrong here?
Considering that $f(x)=x^{-1-a} e^{-1/x}$ is right-continuous (and even has right-derivatives of any order) at $x=0$, you can simply set $f(0)=0$. In practice this just means that you can disregard the first node in both the trapezoidal and Simpson's methods.