lambdaway
::
fractions
7
|
list
|
login
|
load
|
|
{center [[rationals]] | [[rationals2]] | fractions | [[fractions2]] | [[habiter]]} _img https://wikimedia.org/api/rest_v1/media/math/render/svg/247535cef4b9b94eabeb16908cf72436cd01d0c9 _h1 continued fractions {pre F = [a{sub 0};a{sub 1},a{sub 2},...,a{sub n}] = a{sub 0} + 1 {{bt}a{sub 1} + 1} {{bt}a{sub 2} + 1} {{bt} ... 1} {{bt}a{sub n}} } _h2 algorithm {pre a = [a{sub 0}, a{sub 1}, ..., a{sub n-1}] u(0) = a[0] u(n) = 1 / (a[n] + u(n-1)) } _h2 code {pre '{def frac {def frac.r {lambda {:a :u :i} {if {= :i 0} then {+ {A.get :i :a} :u} else {frac.r :a {/ 1 {+ {A.get :i :a} :u}} {- :i 1}} }}} {lambda {:s} {frac.r {A.new :s} 1 {- {S.length :s} 1}} }} -> {def frac {def frac.r {lambda {:k :u :i} {if {= :i 0} then {+ {A.get :i :k} :u} else {frac.r :k {/ 1 {+ {A.get :i :k} :u}} {- :i 1}} }}} {lambda {:k} {frac.r {A.new :k} 1 {- {S.length :k} 1}}}} } _h2 computing φ, √2, √3, e, π, ... {pre φ = [1;1,1,1,1,...] = 1 + 1 {{bt}1 + 1} {{bt}1 + 1} {{bt}1 + 1} {{bt}1 + ...} '{frac 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1} -> {frac 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1} {/ {+ 1 {sqrt 5}} 2} // φ √2 = [1;2,2,2,2,...] = 1 + 1 {{bt}2 + 1} {{bt}2 + 1} {{bt}2 + 1} {{bt}2 + ...} '{frac 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2} -> {frac 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2} {sqrt 2} // √2 √3 = [1;1,2,1,2,1,2...] // repeat 1 2 = 1 + 1 {{bt}1 + 1} {{bt}2 + 1} {{bt}1 + 1} {{bt}2 + ...} '{frac 1 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2} -> {frac 1 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2} {sqrt 3} // √3 e = [2;1,2,1,1,4,1,1,6,1,1,8...] // repeat 1 1 2n = = 2 + 1 {{bt}1 + 1} {{bt}2 + 1} {{bt}1 + 1} {{bt}1 + 1} {{bt}4 + 1} {{bt}1 + ...} '{frac 2 1 2 1 1 4 1 1 6 1 1 8 1 1 10 1 1 12 1 1 14 1 1 16} -> {frac 2 1 2 1 1 4 1 1 6 1 1 8 1 1 10 1 1 12 1 1 14 1 1 16} {E} // e π = [3;7,15,1,292,1,1,1,...] = 3 + 1 {{bt}7 + 1} {{bt}15 + 1} {{bt}1 + 1} {{bt}292 + ...} '{frac 3 7 15 1 292 1 1 1 2 1 3 1 14 2 1 1 2 2 2 2} -> {frac 3 7 15 1 292 1 1 1 2 1 3 1 14 2 1 1 2 2 2 2} {PI} // π } _h2 generalized continuous fractions _p From [[https://en.wikipedia.org/wiki/Continued_fraction|https://en.wikipedia.org/wiki/Continued_fraction]] " The sequence of partial denominators of the simple continued fraction of π does not show any obvious pattern. However, several generalized continued fractions for π have a perfectly regular structure, such as: {pre π = 4 {{bt}1 + 1{sup 2}} {{bt}2 + 3{sup 2}} {{bt}2 + 5{sup 2}} {{bt}2 + 7{sup 2}} {{bt}2 + 9{sup 2}} {{bt}2 + ...} } _p See [[rationals2]]. _p {i alain marty | 2002/04/17} _h2 refs _ul [[https://en.wikipedia.org/wiki/Continued_fraction|https://en.wikipedia.org/wiki/Continued_fraction]] _ul [[villemin frac cont|http://villemin.gerard.free.fr/Wwwgvmm/Nombre/FracCont.htm]] _ul [[villemin frac cont constants|http://villemin.gerard.free.fr/Wwwgvmm/Nombre/FCvaleur.htm#top]] _ul [[t-richez|http://t-richez.pagesperso-orange.fr/ressources/recherche/memoire_fractions_continues.pdf]] _ul [[michel.waldschmidt|https://webusers.imj-prg.fr/~michel.waldschmidt/articles/pdf/FractionsContinuesVI.pdf]] ;; _img http://villemin.gerard.free.fr/Wwwgvmm/Nombre/FCvaleur_fichiers/image011.jpg ;; _img http://villemin.gerard.free.fr/Wwwgvmm/Nombre/FCvaleur_fichiers/image013.jpg {{hide} {def bt span {@ style="border-top:1px solid;"}} }
lambdaway v.20211111