Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

line_integral

Line integral (in the complex plane)


Description

Provides complex line integrals.

Usage

line_integral(fun, waypoints, method = NULL, reltol = 1e-8, ...)

Arguments

fun

integrand, complex (vectorized) function.

method

integration procedure, see below.

waypoints

complex integration: points on the integration curve.

reltol

relative tolerance.

...

additional parameters to be passed to the function.

Details

line_integral realizes complex line integration, in this case straight lines between the waypoints. By passing discrete points densely along the curve, arbitrary line integrals can be approximated.

line_integral will accept the same methods as integral; default is integrate from Base R.

Value

Returns the integral, no error terms given.

See Also

Examples

##  Complex integration examples
points <- c(0, 1+1i, 1-1i, 0)           # direction mathematically negative
f <- function(z) 1 / (2*z -1)
I <- line_integral(f, points)
abs(I - (0-pi*1i))                      # 0 ; residuum 2 pi 1i * 1/2

f <- function(z) 1/z
points <- c(-1i, 1, 1i, -1, -1i)
I <- line_integral(f, points)           # along a rectangle around 0+0i
abs(I - 2*pi*1i)                        #=> 0 ; residuum: 2 pi i * 1

N <- 100
x <- linspace(0, 2*pi, N)
y <- cos(x) + sin(x)*1i
J <- line_integral(f, waypoints = y)    # along a circle around 0+0i
abs(I - J)                              #=> 5.015201e-17; same residuum

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.