Baran did you know that the formula \(\varphi = 1 + 1/ \varphi\) can be expanded recursively to obtain a continued fraction approximation for \(1.62\). The convergents of these continued fractions are ratios of successive Fibonacci numbers (1/1, 1/2, 2/3, 3/5, 5/8, 8/13…).

Continued fraction approximation of 1.62

Continued fraction approximation of 1.62

onesixtytwo.continued.fraction.f <- function(f,n,init){
  expr<-paste(
    paste(rep("f(",n), collapse="",sep=""),
    init,
    paste(rep(")",n), collapse="",sep=""),
    sep=""
  )
  print(expr) # = f(f(f(f(init))))
  eval(parse(text=expr))
}

init <- 1
n <- 15
f0 <- function(init) 1 + 1 / init
onesixtytwo.continued.fraction.f(f0, n, init)
> [1] "f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(1)))))))))))))))"
> [1] 1.62