[R] Integration in R
David Winsemius
dwinsemius at comcast.net
Tue Jan 8 19:11:11 CET 2013
On Jan 8, 2013, at 9:43 AM, Naser Jamil wrote:
> Hi R-users.
>
> I'm having difficulty with an integration in R via
> the package "cubature". I'm putting it with a simple example here.
> I wish
> to integrate a function like:
> f(x1,x2)=2/3*(x1+x2) in the interval 0<x1<x2<7. To be sure I tried it
> by hand and got 114.33, but the following R code is giving me
> 102.6667.
>
> -------------------------------------------------------------------
> library(cubature)
> f<-function(x) { 2/3 * (x[1] + x[2] ) }
> adaptIntegrate(f, lowerLimit = c(0, 0), upperLimit = c(x[2],7))
>
What is x[2]? On my machine it was 0.0761, so I obviously got a
different answer.
--
David Winsemius, MD
Alameda, CA, USA
More information about the R-help
mailing list