myintegrate {elliptic} | R Documentation |
Integration of complex valued functions along the real axis
(myintegrate()
), along arbitrary paths
(integrate.contour()
), and following arbitrary straight line
segments (integrate.segments()
).
myintegrate(f, lower,upper, ...) integrate.contour(f,u,udash, ...) integrate.segments(f,points, close=TRUE, ...)
f |
function, possibly complex valued |
lower |
Lower limit of integration in myintegrate() ; a
real number |
upper |
Upper limit of integration in myintegrate() ; a
real number (for complex values, use integrate.contour() or integrate.segments() ) |
... |
Extra arguments passed to integrate() |
u |
Function mapping [0,1] to the contour. For a closed contour, require that u(0)=u(1). |
udash |
Derivative of u . |
points |
In function integrate.segments() , a vector of complex
numbers. Integration will be taken over straight segments joining
consecutive elements of points . |
close |
In function integrate.segments() , a Boolean
variable with default TRUE meaning to integrate along the segment
from points[n] to points[1] in addition to the internal
segments. |
Robin K. S. Hankin
# To integrate round the unit circle, we need the contour and its # derivative: u <- function(x){exp(pi*2i*x)} udash <- function(x){pi*2i*exp(pi*2i*x)} # First, some elementary functions, for practice: integrate.contour(function(z){1/z},u,udash) # should be 2*pi*i integrate.contour(function(z){log(z)},u,udash) # should be -2*pi*i integrate.contour(function(z){sin(z)+1/z^2},u,udash) # should be zero # Now, some elliptic functions: g <- c(3,2+4i) Zeta <- function(z){zeta(z,g)} Sigma <- function(z){sigma(z,g)} WeierstrassP <- function(z){P(z,g)} jj <- integrate.contour(Zeta,u,udash) abs(jj-2*pi*1i) # should be zero abs(integrate.contour(Sigma,u,udash)) # should be zero abs(integrate.contour(WeierstrassP,u,udash)) # should be zero # Now integrate over a semicircle. Observe how it's better to split the # path into two separate pieces. R <- 400 u1 <- function(x){R*exp(pi*1i*x)} u1dash <- function(x){R*pi*1i*exp(pi*1i*x)} u2 <- function(x){R*(2*x-1)} u2dash <- function(x){R*2} f <- function(z){exp(1i*z)/(1+z^2)} answer.approximate <- integrate.contour(f,u1,u1dash) + integrate.contour(f,u2,u2dash) answer.exact <- pi/exp(1) abs(answer.approximate - answer.exact) # Now try integrating over a triangle, with base on the real axis: abs(integrate.segments(f,c(-R,R,1i*R))- answer.exact)