Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,3 +1,6 @@
|
|||
#Only print to 17 digits due to floating-point imprecision
|
||||
options(digits=17)
|
||||
|
||||
a_sqrt2 <- function(n) ifelse(n==1, 1, 2)
|
||||
b_sqrt2 <- function(n) return(1)
|
||||
|
||||
|
|
@ -9,16 +12,15 @@ b_pi <- function(n) (2*n-1)^2
|
|||
|
||||
continued_fraction <- function(a, b, n){
|
||||
frac <- function(x, d) a(x)+b(x)/d
|
||||
#Only print to 17 digits due to floating-point imprecision
|
||||
print(Reduce(frac, c(1:n,1), right=TRUE), digits=17)
|
||||
Reduce(frac, 1:n, 1, right=TRUE)
|
||||
}
|
||||
|
||||
print(sqrt(2), digits=17)
|
||||
sqrt(2)
|
||||
continued_fraction(a_sqrt2, b_sqrt2, 100)
|
||||
|
||||
print(exp(1), digits=17)
|
||||
exp(1)
|
||||
continued_fraction(a_e, b_e, 100)
|
||||
|
||||
print(pi, digits=17)
|
||||
pi_ests <- sapply(cumprod(c(100, rep(10,3))),
|
||||
function(n) continued_fraction(a_pi, b_pi, n))
|
||||
pi
|
||||
sapply(cumprod(c(100, rep(10,3))),
|
||||
function(n) continued_fraction(a_pi, b_pi, n))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue