[R] double integral

Thomas Lumley tlumley at u.washington.edu
Fri May 5 16:27:05 CEST 2006


On Fri, 5 May 2006, Dominique Katshunga wrote:

> Dear r-users,
> Is there any command in R allowing to evaluate a double integral? for
> instance let say I want to evaluate the following integral:
> integrate[lo=(0,1),up=(2,3)] f(x,y)=x^2+y^2
> where lo is the vector of lower bounds and up that of upper bounds.
> I thaught the function "adapt" would work but it did not.

Works for me:

> library(adapt)
> help(adapt)
> adapt(2,c(0,2),c(1,3),functn=function(xy) xy[1]^2+xy[2]^2)
        value       relerr       minpts       lenwrk        ifail
     6.666667 7.315578e-08          165           73            0


 	-thomas




More information about the R-help mailing list