swh:1:snp:81eadaa089e8253d8469bcef66aa332632c6c669
Tip revision: fdf16693b000f3e309c56091892c61f0ec9fd670 authored by Hans W. Borchers on 21 November 2017, 16:15:00 UTC
version 2.1.1
version 2.1.1
Tip revision: fdf1669
sumalt.R
##
## s u m a l t . R Summing alternating series
##
sumalt <- function(f_alt, n) {
b <- 2^(2*n-1)
c <- b # ; s <- 0
s <- 0.0
for (k in (n-1):0) {
t <- f_alt(k)
s <- s + c*t
b <- b * (2*k+1) * (k+1) / (2 * (n-k) * (n+k))
c <- c + b
}
s <- s / c
return(s)
}