Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/Continued-fraction/Maxima/continued-fraction.maxima
Normal file
23
Task/Continued-fraction/Maxima/continued-fraction.maxima
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
cfeval(x) := block([a, b, n, z], a: x[1], b: x[2], n: length(a), z: 0,
|
||||
for i from n step -1 thru 2 do z: b[i]/(a[i] + z), a[1] + z)$
|
||||
|
||||
cf_sqrt2(n) := [cons(1, makelist(2, i, 2, n)), cons(0, makelist(1, i, 2, n))]$
|
||||
|
||||
cf_e(n) := [cons(2, makelist(i, i, 1, n - 1)), append([0, 1], makelist(i, i, 1, n - 2))]$
|
||||
|
||||
cf_pi(n) := [cons(3, makelist(6, i, 2, n)), cons(0, makelist((2*i - 1)^2, i, 1, n - 1))]$
|
||||
|
||||
cfeval(cf_sqrt2(20)), numer; /* 1.414213562373097 */
|
||||
% - sqrt(2), numer; /* 1.3322676295501878*10^-15 */
|
||||
|
||||
cfeval(cf_e(20)), numer; /* 2.718281828459046 */
|
||||
% - %e, numer; /* 4.4408920985006262*10^-16 */
|
||||
|
||||
cfeval(cf_pi(20)), numer; /* 3.141623806667839 */
|
||||
% - %pi, numer; /* 3.115307804568701*10^-5 */
|
||||
|
||||
|
||||
/* convergence is much slower for pi */
|
||||
fpprec: 20$
|
||||
x: cfeval(cf_pi(10000))$
|
||||
bfloat(x - %pi); /* 2.4999999900104930006b-13 */
|
||||
Loading…
Add table
Add a link
Reference in a new issue