cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

User: Giovanni Artico

Giovanni Artico's wiki page.

Giovanni Artico has authored 9 sequences.

A228937 Expansion of (1+2*x+30*x^2+13*x^3-13*x^5-30*x^6-2*x^7-x^8)/(1+2*x^4+x^8).

Original entry on oeis.org

1, 2, 30, 13, -2, -17, -90, -28, 2, 32, 150, 43, -2, -47, -210, -58, 2, 62, 270, 73, -2, -77, -330, -88, 2, 92, 390, 103, -2, -107, -450, -118, 2, 122, 510, 133, -2, -137, -570, -148, 2, 152, 630, 163, -2, -167, -690, -178, 2, 182
Offset: 0

Author

Giovanni Artico, Oct 28 2013

Keywords

Comments

Optimal simple continued fraction (with signed denominators) of exp(2/5)
See A228935.
The convergents are a subset of those of the standard regular continued fraction; the sequence of the signs of the difference between the convergents and exp(2/5) starts with:
-1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1,...
For every couple of successive equal signs in this sequence there is a convergent of the standard expansion not present in this one.
Repeating the expansion for other numbers of type 2/k a common pattern seems to emerge. Examples:
exp(2/7) gives 1, 3, 42, 18, -2, -24, -126, -39, 2, 45, 210, 60, -2,...
exp(2/9) gives 1, 4, 54, 23, -2, -31, -162, -50, 2, 58, 270, 77, -2,...
so it seems that in general the terms for exp(2/k) are generated by the following formulas:
b(0)=1, b(1)=k/2-1/2, b(2)=6*k, b(3)=5*k/2+1/2, b(4)=-2, b(5)=7*k/2+1/2, b(6)=-18*k, b(7)=-11*k/2-1/2, b(8)=2; b(n) = -2*b(n-4) -b(n-8) for n>8, recurrence which corresponds to the g.f. 1/2*(1-x)*(1+x)*(2*(1+x^6)+(k-1)*(x+x^5)+(12*k+2)*(x^2+x^4)+6*k*x^3)/(1+x^4)^2; also:
b(0)=1 , b(4m+1)=(-1)^m*((k-1)/2+3*k*m), b(4m+3)=(-1)^m*((5*k+1)/2+3*k*m), b(4m+2)=(-1)^m*(6*k+12*k*m), b(4m+4)=(-1)^(m+1)*2 for n>=0.
These formulas give this expansion for exp(2/k):
exp(2/k)=1+1/((k-1)/2+1/(6k+1/((5k+1)/2+1/(-2+1/(-(7k-1)/2+1/...)))))
that can be rewritten in this equivalent form:
exp(2/k)=1+1/(k/2-1/2+1/(6k+1/(5k/2+1/2-1/(2+1/(7x/2-1/2+1/...))))).
This general expansion seems to be valid for any real value of k.

Examples

			exp(2/5)=1+1/(2+1/(30+1/(13+1/(-2+1/(-17+1/(-90+1/(-28+1/(2+...)))))))),
or equivalently:
exp(2/5)=1+1/(2+1/(30+1/(13-1/(2+1/(17+1/(90+1/(28-1/(2+...)))))))).
		

Crossrefs

Programs

  • Maple
    SCF := proc (n, q::posint)::list; local L, i, z; Digits := 10000; L := [round(n)]; z := n; for i from 2 to q do if z = op(-1, L) then break end if; z := 1/(z-op(-1, L)); L := [op(L), round(z)] end do; return L end proc
    SCF(exp(2/5), 50)
  • Mathematica
    Join[{1}, LinearRecurrence[{0, 0, 0, -2, 0, 0, 0, -1}, {2, 30, 13, -2, -17, -90, -28, 2}, 50]] (* Bruno Berselli, Nov 06 2013 *)

Formula

G.f.: (1+2*x+30*x^2+13*x^3-13*x^5-30*x^6-2*x^7-x^8)/(1+2*x^4+x^8).
a(0)=1, a(1)=2, a(2)=30, a(3)=13, a(4)=-2, a(5)=-17, a(6)=-90, a(7)=-28, a(8)=2; for n>8, a(n) = -2*a(n-4) -a(n-8).
a(0)=1 , a(4m+1) = (-1)^m*(2+15*m), a(4m+3) = (-1)^m*(13+15*m), a(4m+2) = (-1)^m*(30+60*m), a(4m+4) = 2*(-1)^(m+1) for m>=0.

A228935 a(n) = (3 - 6*n)*(-1)^n.

Original entry on oeis.org

0, 3, -9, 15, -21, 27, -33, 39, -45, 51, -57, 63, -69, 75, -81, 87, -93, 99, -105, 111, -117, 123, -129, 135, -141, 147, -153, 159, -165, 171, -177, 183, -189, 195, -201, 207, -213, 219, -225, 231, -237, 243, -249, 255, -261, 267, -273, 279, -285, 291
Offset: 0

Author

Giovanni Artico, Oct 25 2013

Keywords

Comments

Optimal simple continued fraction (with signed denominators) of tan(1/3).
This expansion is a simple continued fraction a(0) + 1/(a(1) + 1/(a(2) + ...)) with all numerators 1, and the numbers a(n) are signed integers computed with an algorithm that guarantees the fastest convergence for this type of continued fraction.
The algorithm is the same described in A133593. It is as usually based on the Euclidean division algorithm, but instead of taking the floor of the quotients, as it happens for standard continued fractions, the nearest integer is taken, so the remainders can be also negative and the quotients also.
Generally the convergents of this expansion are a subset of the convergents of the standard continued fraction expansion, and they are no more alternatively lesser and greater than the given number: in this special case of tan(1/3) they are all lesser.
The terms of this sequence can be generated by this formula: a(n) = -3*(-1)^n*(2n-1) for n > 0 (the first term is a(0)=0).
Repeating the expansion for other numbers of type 1/k a common pattern seems to emerge. Examples:
tan(1/4) gives 0, 4, -12, 20, -28, 36, -44, 52, -60, 68, -76, 84, ...
tan(1/5) gives 0, 5, -15, 25, -35, 45, -55, 65, -75, 85, -95, 105, ...
so it seems that in general the terms of tan(1/k) are generated by the formula a(n) = (-1)^(n+1)*k*(2n-1) for n > 0. This formula gives this expansion for tan(1/k):
tan(1/k) = 1/(k+1/(-3k+1/(5k-1/(-7k+1/(9k+1/...))))).
This expansion can be rewritten in an equivalent form:
tan(1/k) = 1/(k-1/(3k-1/(5k-1/(7k-1/(9k-1/...))))).
The rule for converting the first form to the second is this: if two consecutive terms have different sign put a minus before the fraction line, otherwise put plus, and take the absolute value of the terms in the denominators.
This general expansion seems to be valid for any real value of k and resembles Lambert's expansion of tan(k).
The unsigned version of this sequence is A016945. - Colin Barker, Oct 26 2013

Examples

			tan(1/3) = 0 + 1/(3 + 1/(-9 + 1/(15 + 1/(-21 + 1/(27 + ...))))) or
tan(1/3) = 0 + 1/(3 - 1/(9 - 1/(15 - 1/(21 - 1/(27 - ...))))).
		

Crossrefs

Programs

  • Maple
    SCF := proc (n, q::posint)::list; local L, i, z; Digits := 10000; L := [round(n)]; z := n; for i from 2 to q do if z = op(-1, L) then break end if; z := 1/(z-op(-1, L)); L := [op(L), round(z)] end do; return L end proc
    SCF(tan(1/3), 50)  # Giovanni Artico, Oct 26 2013
  • Mathematica
    Join[{0},LinearRecurrence[{-2,-1},{3,-9},50]] (* Harvey P. Dale, Mar 10 2015 *)
  • PARI
    Vec(3*x*(1-x)/(x+1)^2+O(x^100)) \\ Colin Barker, Oct 26 2013

Formula

a(n) = A016945(n-1)*(-1)^(n-1).
Formulae for the general case tan(1/k):
a(0)=0; for n > 0, a(n) = (-1)^(n+1)*k*(2n-1).
tan(1/k) = 1/(k + 1/(-3k + 1/(5k - 1/(-7k + 1/(9k + 1/...))))) or equivalently
tan(1/k) = 1/(k - 1/(3k - 1/(5k - 1/(7k - 1/(9k - 1/...))))).
From Colin Barker, Oct 26 2013: (Start)
a(n) = -2*a(n-1) - a(n-2) for n > 2.
G.f.: 3*x*(1-x) / (x+1)^2. (End)

A228936 Expansion of (1 + 3*x - 3*x^3 - x^4)/(1 + 2*x^2 + x^4).

Original entry on oeis.org

1, 3, -2, -9, 2, 15, -2, -21, 2, 27, -2, -33, 2, 39, -2, -45, 2, 51, -2, -57, 2, 63, -2, -69, 2, 75, -2, -81, 2, 87, -2, -93, 2, 99, -2, -105, 2, 111, -2, -117, 2, 123, -2, -129, 2, 135, -2, -141, 2, 147
Offset: 0

Author

Giovanni Artico, Oct 26 2013

Keywords

Comments

Optimal simple continued fraction (with signed denominators) of exp(1/3). See A228935.
The convergents are a subset of those of the standard regular continued fraction; the sequence of the signs of the difference between the convergents and exp(1/3) starts with: -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, ...
For every couple of successive equal signs in this sequence there is a convergent of the standard expansion not present in this one.
Repeating the expansion for other numbers of type 1/k a common pattern seems to emerge. Examples:
exp(1/4) gives 1, 4, -2, -12, 2, 20, -2, -28, 2, 36, -2, -44, 2, 52, ...
exp(1/5) gives 1, 5, -2, -15, 2, 25, -2, -35, 2, 45, -2, -55, 2, 65, ...
so it seems that in general the terms for exp(1/k) are generated by the formulas a(0)=1, a(2n+1) = (-1)^n*k*(2n+1) for n >= 0, a(2n) = (-1)^n*2 for n > 0. These formulas give this expansion for exp(1/k):
exp(1/k) = 1+1/(k+1/(-2+1/(-3k+1/(2+1/(5k+1/(-2+1/(-7k+1/(2+...)))))))).
which can be rewritten in this equivalent form:
exp(1/k) = 1+1/(k-1/(2+1/(3k-1/(2+1/(5k-1/(2+1/(7k-1/(2+...)))))))).
This general expansion seems to be valid for any real value of k.
Closed form for the general case exp(1/k): b(n) = (1+(-1)^n-(1-(-1)^n)*k*n/2)*i^(n*(n+1)) for n>0 and with i=sqrt(-1). [Bruno Berselli, Nov 01 2013]

Examples

			exp(1/3) = 1+1/(3+1/(-2+1/(-9+1/(2+1/(15+1/(-2+1/(-21+1/(2+...)))))))) or
exp(1/3) = 1+1/(3-1/(2+1/(9-1/(2+1/(15-1/(2+1/(21-1/(2+...))))))))
		

Crossrefs

Programs

  • Maple
    SCF := proc (n, q::posint)::list; local L, i, z; Digits := 10000; L := [round(n)]; z := n; for i from 2 to q do if z = op(-1, L) then break end if; z := 1/(z-op(-1, L)); L := [op(L), round(z)] end do; return L end proc
    SCF(exp(1/3), 50)  # Giovanni Artico, Oct 26 2013
  • PARI
    Vec(-(x-1)*(x+1)*(x^2+3*x+1)/(x^2+1)^2+O(x^100)) \\ Colin Barker, Oct 26 2013

Formula

This sequence can be generated by these formulas:
a(0)=1; for n >= 0, a(2n+1) = 3*(-1)^n*(2n+1), a(2n) = 2*(-1)^n for n > 0.
Formulae for the general case exp(1/k):
b(0)=1; for n >= 0, b(2n+1) = (-1)^n*k*(2n+1), b(2n) = 2*(-1)^n.
b(n) = 2*cos(n*Pi/2) + k*n*sin(n*Pi/2) for n > 0.
exp(1/k) = 1+1/(k-1/(2+1/(3k-1/(2+1/(5k-1/(2+1/(7k-1/(2+...)))))))).
G.f.: (1-x)*(1+x)*(1+k*x+x^2)/(1+x^2)^2.
From Colin Barker, Oct 26 2013: (Start)
a(n) = (-i)^n + i^n + (1/2)*(((-i)^n-i^n)*n)*(3*i) for n > 0, where i=sqrt(-1).
a(2n) = 2*(3*n*sin(Pi*n) + cos(Pi*n)) for n > 0.
a(2n+1) = (6*n+3)*cos(Pi*n) - 2*sin(Pi*n) for n >= 0.
a(n) = -2*a(n-2) - a(n-4) for n > 4.
G.f.: -(x-1)*(x+1)*(x^2+3*x+1) / (x^2+1)^2. (End)

A228933 Optimal ascending continued fraction expansion of phi-1=1/phi=(sqrt(5)-1)/2 .

Original entry on oeis.org

2, 4, -18, 322, 103682, 10749957122, 115561578124838522882, 13354478338703157414450712387359637585922, 178342091698891843163466683840822101223162205277179656650156983624835803932590082
Offset: 1

Author

Giovanni Artico, Sep 10 2013

Keywords

Comments

See A228929 for the definition of "optimal ascending continued fraction".
Conjecture: The golden ratio (phi) expansion exhibits from the fourth term the recurrence relation a(n) = a(n-1)^2 - 2 described in A228931.

Examples

			phi = 1+1/2*(1+1/4*(1-1/18*(1+1/322*(1+1/103682*(1+1/10749957122*(1+...))))))
		

Programs

  • Maple
    ArticoExp := proc (n, q::posint)::list; local L, i, z; Digits := 50000; L := []; z := frac(evalf(n)); for i to q+1 do if z = 0 then break end if; L := [op(L), round(1/abs(z))*sign(z)]; z := abs(z)*round(1/abs(z))-1 end do; return L end proc
    # List the first 8 terms of the expansion of 1/phi
    ArticoExp((sqrt(5)-1)/2,8)
  • Mathematica
    Flatten[{2, 4, RecurrenceTable[{a[n] == a[n-1]^2 - 2, a[3] == -18}, a, {n, 3, 10}]}] (* Vaclav Kotesovec, Sep 20 2013 *)

Formula

a(n) = a(n-1)^2 - 2 for n>3.
For n>3, a(n) = (sqrt(5)+2)^(2^(n-2)) + (sqrt(5)-2)^(2^(n-2)). - Vaclav Kotesovec, Sep 20 2013
a(n) = 2*A081459(n-1) for n>3. - Amiram Eldar, Apr 07 2023

A228932 Optimal ascending continued fraction expansion of sqrt(43) - 6.

Original entry on oeis.org

2, 9, 30, 60, 122, -878, 11429, 35241, -177141, 709582, -3123032, -1157723745, 3237738813, -16178936725, 33395053634, -71863018424, -153349368674, -386763022623, -8021033029400, 16314606875900, 52522689388692
Offset: 1

Author

Giovanni Artico, Sep 10 2013

Keywords

Comments

See A228929 for the definition of "optimal ascending continued fraction".
In A228931 it is shown that many numbers of the type sqrt(x) seem to present in their expansion a recurrence relation a(n) = a(n-1)^2 - 2 between the terms, starting from some point onward; 43 is the first natural number whose terms don't respect this relation.
The numbers in range 1 .. 200 that exhibit this behavior are 43, 44, 46, 53, 58, 61, 67, 73, 76, 85, 86, 89, 91, 94, 97, 103, 106, 108, 109, 113, 115, 116, 118, 125, 127, 129, 131, 134, 137, 139, 149, 151, 153, 154, 157, 159, 160, 161, 163, 166, 172, 173, 176, 177, 179, 181, 184, 186, 190, 191, 193, 199.
Nevertheless, the expansions of 3*sqrt(43), 9*sqrt(43), and sqrt(43)/5 satisfy the recurrence relation.

Examples

			sqrt(43) = 6 + 1/2*(1 + 1/9*(1 + 1/30*(1 + 1/60*(1 + 1/122*(1 - 1/878*(1 + ...)))))).
		

References

Crossrefs

Programs

  • Maple
    ArticoExp := proc (n, q::posint)::list; local L, i, z; Digits := 50000; L := []; z := frac(evalf(n)); for i to q+1 do if z = 0 then break end if; L := [op(L), round(1/abs(z))*sign(z)]; z := abs(z)*round(1/abs(z))-1 end do; return L end proc
    # List the first 8 terms of the expansion of sqrt(43)-6
    ArticoExp(sqrt(43),20)
  • Mathematica
    ArticoExp[x_, n_] := Round[1/#] & /@ NestList[Round[1/Abs[#]]*Abs[#] - 1 &, FractionalPart[x], n]; Block[{$MaxExtraPrecision = 50000},
    ArticoExp[Sqrt[43] - 6, 20]] (* G. C. Greubel, Dec 26 2016 *)

A228931 Optimal ascending continued fraction expansion of sqrt(2)-1.

Original entry on oeis.org

2, -6, 34, 1154, 1331714, 1773462177794, 3145168096065837266706434, 9892082352510403757550172975146702122837936996354
Offset: 1

Author

Giovanni Artico, Sep 09 2013

Keywords

Comments

See A228929 for the definition of "optimal ascending continued fraction".
Conjecture: The terms from a(3) are all positive and can be generated by the recurrence relation a(k+1) = a(k)^2 - 2.
This relation was studied by Lucas with reference to Engel expansion.
This recurrence is not peculiar of sqrt(2) but is present in the expansion of the square root of many other numbers, starting from some term onward, but not for all numbers. Here is a list of the numbers in range 1..200 having the recurrence: 2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 45, 47, 48, 50, 51, 52, 54, 55, 56, 57, 59, 60, 62, 63, 65, 66, 68, 69, 70, 71, 72, 74, 75, 77, 78, 79, 80, 82, 83, 84, 87, 88, 90, 92, 93, 95, 96, 98, 99, 101, 102, 104, 105, 107, 110, 111, 112, 114, 117, 119, 120, 122, 123, 124, 126, 128, 130, 132, 133, 135, 136, 138, 140, 141, 142, 143, 145, 146, 147, 148, 150, 152, 155, 156, 158, 162, 164, 165, 167, 168, 170, 171, 174, 175, 178, 180, 182, 183, 185, 187, 188, 189, 192, 194, 195, 197, 198, 200
Essentially the same as A003423. - R. J. Mathar, Sep 21 2013

Examples

			sqrt(2)=1+1/2*(1-1/6*(1+1/34*(1+1/1154*(1+1/1331714*(1+1/1773462177794*(1+.....))))))
		

Crossrefs

Programs

  • Maple
    ArticoExp := proc (n, q::posint)::list; local L, i, z; Digits := 50000; L := []; z := frac(evalf(n)); for i to q+1 do if z = 0 then break end if; L := [op(L), round(1/abs(z))*sign(z)]; z := abs(z)*round(1/abs(z))-1 end do; return L end proc
    # List the first 8 terms of the expansion of sqrt(2)-1
    ArticoExp(sqrt(2),8)
  • Mathematica
    Flatten[{2, RecurrenceTable[{a[n] == a[n-1]^2 - 2, a[2] == -6}, a, {n, 2, 10}]}] (* Vaclav Kotesovec, Sep 20 2013 *)

Formula

a(n) = a(n-1)^2 - 2, for n > 2.
For n>2, a(n) = (sqrt(2)+1)^(2^(n-1)) + (sqrt(2)-1)^(2^(n-1)). - Vaclav Kotesovec, Sep 20 2013

Extensions

Added a pdf file with a proof of the conjecture by Giovanni Artico

A228934 Optimal ascending continued fraction expansion of sqrt(44) - 6.

Original entry on oeis.org

2, 4, 15, -99, -199, -800, -79201, -316808, -12545596801, -50182387208, -314783998186522867201, -1259135992746091468808, -198177931028585663493396958369763763148801, -792711724114342653973587833479055052595208
Offset: 1

Author

Giovanni Artico, Sep 11 2013

Keywords

Comments

See A228929 for the definition of "optimal ascending continued fraction".
This is the first number whose expansion exhibits (in the first 20 terms) a different recurrence relation from that described in A228931.
Conjecture: The terms of the expansion of sqrt(x) are all negative starting from a(4) and satisfy these recurrence relations for n>=3: a(2n) = 4*a(2n-1) - 4 and a(2n+1) = -2*a(2n-1)^2 + 1.
Numbers (in the range 1..1000) that exhibit this recurrence starting from some n are 44, 125, 154, 160, 176, 207, 208, 280, 352, 384, 459, 468, 500, 608, 616, 640, 665, 686, 704, 768, 800, 832, 864, 874, 875, 924.

Examples

			sqrt(44) = 6 + 1/2*(1 + 1/4*(1 + 1/15*(1 - 1/99*(1 - 1/199*(1 - 1/800*(1 - 1/79201*(1 - 1/316808*(1 - 1/12545596801*(1 - ...))))))))).
		

Crossrefs

Programs

  • Maple
    ArticoExp := proc (n, q::posint)::list; local L, i, z; Digits := 50000; L := []; z := frac(evalf(n)); for i to q+1 do if z = 0 then break end if; L := [op(L), round(1/abs(z))*sign(z)]; z := abs(z)*round(1/abs(z))-1 end do; return L end proc
    # List the first 20 terms of the expansion of sqrt(44)-6
    ArticoExp(sqrt(44),20)
  • Mathematica
    ArticoExp[x_, n_] := Round[1/#] & /@ NestList[Round[1/Abs[#]]*Abs[#] - 1 &, FractionalPart[x], n]; Block[{$MaxExtraPrecision = 50000}, ArticoExp[Sqrt[44] - 6, 20]] (* G. C. Greubel, Dec 26 2016 *)

Formula

a(2n) = 4*a(2n-1) - 4 and a(2n+1) = -2*a(2n-1)^2 + 1 for n >= 3.

Extensions

Minor typos corrected by Giovanni Artico, Sep 24 2013

A228929 Optimal ascending continued fraction expansion of Pi - 3.

Original entry on oeis.org

7, -113, 4739, -46804, 134370, -614063, 1669512, -15474114, -86232481, 1080357006, -8574121305, -24144614592, 133884333083, -2239330253016, -6347915250018, 14541933941298, -42301908155404, -298013673554972, 5177473084279656, -46709468571434452, 1201667304102142095, -68508286025632748778, 850084640720511629243, -2458418086834560217354
Offset: 1

Author

Giovanni Artico, Sep 08 2013

Keywords

Comments

Definition of the expansion: for a positive real number x, there is always a unique sequence of signed integers with increasing absolute value |a(i)|>|a(i-1)| such that x =floor(x)+ 1/a(1) + 1/a(1)/a(2) + 1/a(1)/a(2)/a(3) + 1/a(1)/a(2)/a(3)/a(4) ... or equivalently x=floor(x)+1/a(1)*(1+1/a(2)*(1+1/a(3)*(1+1/a(4)*(1+...)))) giving the fastest converging series with this representation. This formula can be represented as a regular ascending continued fraction. The expansion is similar to Engel and Pierce expansions, but the sign of the terms is not predefined and determined by the algorithm for optimizing the convergence.
For x rational number the expansion has a finite number of terms, for x irrational an infinite number. Empirically the sequence doesn't show any evident regularity except in some interesting cases.

Examples

			Pi = 3 + 1/7*(1 - 1/113*(1 + 1/4739*(1 - 1/46804*(1 + 1/134370*(1 - 1/614063*(1 + 1/1669512*(1 + ...))))))).
		

Programs

  • Derive
    ArticoExp(x, n) := VECTOR(ROUND(1, ABS(k))*SIGN(k), k, ITERATES(ROUND(1, ABS(u))*ABS(u) - 1, u, MOD(x), n))
    Precision:=Mixed
    PrecisionDigits:=10000
    ArticoExp(PI,20)
  • Maple
    # Slow procedure valid for every number
    ArticoExp := proc (n, q::posint)::list; local L, i, z; Digits := 50000; L := []; z := n-floor(n); for i to q+1 do if z = 0 then break end if; L := [op(L), round(1/abs(z))*sign(evalf(z))]; z := abs(z)*round(1/abs(z))-1 end do; return L end proc
    # Fast procedure, not suited for rational numbers
    ArticoExp := proc (n, q::posint)::list; local L, i, z; Digits := 50000; L := []; z := frac(evalf(n)); for i to q+1 do if z = 0 then break end if; L := [op(L), round(1/abs(z))*sign(z)]; z := abs(z)*round(1/abs(z))-1 end do; return L end proc
    # List the first 20 terms of the expansion of Pi
    ArticoExp(Pi,20)
  • Mathematica
    ArticoExp[x_, n_] :=  Round[1/#] & /@ NestList[Round[1/Abs[#]]*Abs[#] - 1 &, FractionalPart[x], n]; Block[{$MaxExtraPrecision = 50000}, ArticoExp[Pi, 20]]

Formula

Given a positive real number x, let z(0)=x-floor(x) and z(k+1)=abs(z(k))*round(1/abs(z(k)))-1 ; then a(n)=sign(z(n))*round(1/abs(z(n))) for n>0.

A228930 Optimal ascending continued fraction expansion of e - 2.

Original entry on oeis.org

1, -4, 8, 67, 266, 9757, 47748, -97258, -251115, 671488, -4724169, -28356343, 125269419, -498668029, -5426804695, 15313259790, -40462770156, 105160602326, -4412226092528, -350847041434052, -54342998565206181
Offset: 1

Author

Giovanni Artico, Sep 09 2013

Keywords

Comments

See A228929 for explanation.

Examples

			e = 2 + 1*(1 - 1/4*(1 + 1/8*(1 + 1/67*(1 + 1/266*(1 + 1/9757*(1 + ...)))))).
		

Crossrefs

Cf. A228929.

Programs

  • Maple
    ArticoExp := proc (n, q::posint)::list; local L, i, z; Digits := 50000; L := []; z := frac(evalf(n)); for i to q+1 do if z = 0 then break end if; L := [op(L), round(1/abs(z))*sign(z)]; z := abs(z)*round(1/abs(z))-1 end do; return L end proc
    # List the first 20 terms of the expansion of exp(1)-2
    ArticoExp(exp(1),20)
  • Mathematica
    ArticoExp[x_, n_] := Round[1/#] & /@ NestList[Round[1/Abs[#]]*Abs[#] - 1 &, FractionalPart[x], n]; Block[{$MaxExtraPrecision = 50000}, ArticoExp[Exp[1] - 2, 20]] (* G. C. Greubel, Dec 26 2016 *)

Formula

Given a positive real number x, let z(0) = x - floor(x) and z(k+1) = abs(z(k))*round(1/abs(z(k))) - 1; then a(n) = sign(z(n))*round(1/abs(z(n))) for n>0.