[R] integrate() and complex values

Robin Hankin r.hankin at soc.soton.ac.uk
Tue Jan 11 12:50:11 CET 2005


[apologies for possible multiple post]


Hi

The manpage for integrate() does not mention imaginary numbers.
I found the following unexpected:

 > integrate(function(x){0*x+1+1i},0,1)
1 with absolute error < 1.1e-14
 >

(I would expect 1+1i here)

One can write a little wrapper, but it's not straightforward.
Would it be hard to accommodate such functions in integrate()?

Some other functions returning complex values cause integrate() to trip 
up:

 > integrate(function(x){exp(1i*x)},0,1)
Error in integrate(function(x) { : maximum number of subdivisions 
reached


--
Robin Hankin
Uncertainty Analyst
Southampton Oceanography Centre
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743




More information about the R-help mailing list