View source: R/transcNumFracs.r
phi2cfrac | R Documentation |
This function generates the continued fraction form of the "golden ratio", phi^N
for integer powers N.
phi2cfrac( nterms = 10, exponent = 1, ...)
nterms |
How many denominators to calculate. |
exponent |
An positive integer indicating the power of |
... |
Reserved for future use. |
The 'golden ratio' , equal to (1 + sqrt(5))/2
, is the ratio of two sides x < y of a rectangle such that, by removing a square of side x, the remaining rectangle has the same ratio.
It turns out, in one of those mathematical curiosities, the denominators of the continued fraction form of phi
are all equal to one. Some people use this to state, humorously, that this makes phi
"the most irrational irrational number." It also happens that the continued fraction form for powers of phi
consist of Lucas Numbers (see References).
The continued fraction denominators are provided in denom
. The inputs nterms
and exponent
are echoed back for reference.
Carl Witthoft, carl@witthoft.com
https://en.wikipedia.org/wiki/Lucas_number https://en.wikipedia.org/wiki/Golden_ratio
num2cfrac
phi2cfrac(nterms = 10)
phi2cfrac(exponent = 3)
foop <- phi2cfrac(nterms = 20)
cfrac2num(denom = foop$denom)
# compare with:
library(Rmpfr)
(1 + sqrt(mpfr(5,1000)))/2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.