Re: [R] How to double integrate a function in R

2013-07-26 Thread Hans W Borchers
Tiago V. Pereira mbe.bio.br> writes: > I am trying to double integrate the following expression: > > # expression > (1/(2*pi))*exp(-y2/2)*sqrt((y1/(y2-y1))) > > for y2>y1>0. > > I am trying the following approach > > # first attempt > > library(cubature) > fun <- function(x) { (1/(2*

Re: [R] How to double integrate a function in R

2013-07-26 Thread David Winsemius
On Jul 26, 2013, at 9:33 AM, David Winsemius wrote: > fun2 <- function(x,y) { (x0)* (1/(2*pi))*exp(-y/2)* sqrt((x/(y-x)))} > persp(outer(0:5, 0:6, fun2) ) There does seem to be some potential pathology at the edges of the range, Restricting it to x >= 0.03 removes most of that concern. fun2

Re: [R] How to double integrate a function in R

2013-07-26 Thread David Winsemius
On Jul 26, 2013, at 8:44 AM, Tiago V. Pereira wrote: > I am trying to double integrate the following expression: > > # expression > (1/(2*pi))*exp(-y2/2)*sqrt((y1/(y2-y1))) > > for y2>y1>0. > > I am trying the following approach > > # first attempt > > library(cubature) >fun <- function