| 1 |
### R code from vignette source 'residuetheorem.Rnw' |
| 2 |
|
| 3 |
################################################### |
| 4 |
### code chunk number 1: requirepackage |
| 5 |
################################################### |
| 6 |
require(elliptic,quietly=TRUE) |
| 7 |
|
| 8 |
|
| 9 |
################################################### |
| 10 |
### code chunk number 2: residuetheorem.Rnw:159-160 |
| 11 |
################################################### |
| 12 |
integrate.segments(exp, c(0, 1, 1+1i, 1i), close=TRUE) |
| 13 |
|
| 14 |
|
| 15 |
################################################### |
| 16 |
### code chunk number 3: residuetheorem.Rnw:173-176 |
| 17 |
################################################### |
| 18 |
analytic <- exp(1)*(exp(1i)-1) |
| 19 |
numeric <- integrate.segments(exp, c(1, 1+1i), close=FALSE) |
| 20 |
c(analytic=analytic, numeric=numeric, difference=analytic-numeric) |
| 21 |
|
| 22 |
|
| 23 |
################################################### |
| 24 |
### code chunk number 4: residuetheorem.Rnw:202-208 |
| 25 |
################################################### |
| 26 |
u <- function(x){exp(pi*2i*x)} |
| 27 |
udash <- function(x){pi*2i * exp(pi*2i*x)} |
| 28 |
|
| 29 |
analytic <- pi*2i |
| 30 |
numeric <- integrate.contour(function(z){1/z}, u, udash) |
| 31 |
c(analytic=analytic, numeric=numeric, difference=analytic-numeric) |
| 32 |
|
| 33 |
|
| 34 |
################################################### |
| 35 |
### code chunk number 5: showhypergeofail |
| 36 |
################################################### |
| 37 |
library("hypergeo") |
| 38 |
z0 <- 1/2 + sqrt(3)/2i |
| 39 |
f <- function(z){hypergeo_powerseries(1/2, 1/3, 1/5, z)} |
| 40 |
f(z0) |
| 41 |
|
| 42 |
|
| 43 |
################################################### |
| 44 |
### code chunk number 6: residuetheorem.Rnw:272-276 |
| 45 |
################################################### |
| 46 |
r <- 0.1 # radius of contour |
| 47 |
u <- function(x){z0 + r*exp(pi * 2i * x)} |
| 48 |
udash <- function(x){r * pi * (0+2i) * exp(pi * 2i * x)} |
| 49 |
(val_residue <- integrate.contour(function(z){f(z) / (z-z0)}, u, udash) / (pi*2i)) |
| 50 |
|
| 51 |
|
| 52 |
################################################### |
| 53 |
### code chunk number 7: residuetheorem.Rnw:283-285 |
| 54 |
################################################### |
| 55 |
(val_gosper <- hypergeo_gosper(1/2, 1/3, 1/5, z0)) |
| 56 |
abs(val_gosper - val_residue) |
| 57 |
|
| 58 |
|