[R] Numerical Integration in 1D

Max mnevill at exitcheck.net
Fri Mar 7 19:40:42 CET 2008


Dear UseRs,

I'm curious about the derivative of n!.

We know that Gamma(n+1)=n! So when on takes the derivative of 
Gamma(n+1) we get Int(ln(x)*exp(-x)*x^n,x=0..Inf).

I've tried code like

> integrand<-function(x) {log(x)*exp(x)*x^n}
> integrate(integrand,lower=0,upper=Inf)

It seems that R doesn't like to integrate for any n, and I was 
wondering if anyone knew a way around this?

-Max



More information about the R-help mailing list