login
Delayed continued fraction of sqrt(2).
6

%I #17 Sep 08 2022 08:46:05

%S 2,-1,-2,1,2,-1,-2,1,2,-1,-2,1,2,-1,-2,1,2,-1,-2,1,2,-1,-2,1,2,-1,-2,

%T 1,2,-1,-2,1,2,-1,-2,1,2,-1,-2,1,2,-1,-2,1,2,-1,-2,1,2,-1,-2,1,2,-1,

%U -2,1,2,-1,-2,1,2,-1,-2,1,2,-1,-2,1,2,-1,-2,1,2,-1

%N Delayed continued fraction of sqrt(2).

%C See A228825 for a definition of delayed continued fraction (DCF).

%C DCF(r) is periodic if and only if CF(r) is periodic; DCF(sqrt(n)) is shown here for selected values of n,using Mathematica notation for periodic continued fractions.

%C n ........ DCF(sqrt(n))

%C 2 ........ {2, {-1,-2,1,2}}

%C 3 ........ {{1,2,-1,-1,-2,1}}

%C 5 ........ {3, {-2,2,-1,-2,2,-2,1,2}}

%C 6 ........ {3, {-1,-2,2,-2,1,2}}

%C 7 ........ {2, {1,1,2,-2,2,-1,-1,-1,-1,-2,2,-2,1,1}}

%C 8 ........ {2, {2,-2,2,-1,-1,-2,2,-2,1,1}}

%C 10........ {4, {-2,2,-2,2,-1,-2,2,-2,2,-2,1,2}}

%H G. C. Greubel, <a href="/A228826/b228826.txt">Table of n, a(n) for n = 0..1000</a>

%H <a href="/index/Rec#order_02">Index entries for linear recurrences with constant coefficients</a>, signature (0,-1).

%F From _Colin Barker_, Sep 13 2013: (Start)

%F a(n) = ((2-i)*(-i)^n + (2+i)*i^n)/2 where i=sqrt(-1).

%F a(n) = -a(n-2).

%F G.f.: (2-x)/(x^2+1). (End)

%e convergents: 2, 1, 4/3, 3/2, 10/7, 7/5, 24/17, 17/12, 58/41, 41/29, 140/99, ...

%t $MaxExtraPrecision = Infinity; x[0] = Sqrt[2]; s[x_] := s[x] = If[FractionalPart[x] < 1/2, Ceiling[x], Floor[x]]; a[n_] := a[n] = s[Abs[x[n]]]*Sign[x[n]]; x[n_] := 1/(x[n - 1] - a[n - 1]); t = Table[a[n], {n, 0, 100}]

%t LinearRecurrence[{0,-1}, {2,-1}, 50] (* _G. C. Greubel_, Aug 19 2018 *)

%o (PARI) Vec(-(x-2)/(x^2+1) + O(x^100)) \\ _Colin Barker_, Sep 13 2013

%o (Magma) I:=[2,-1]; [n le 2 select I[n] else - Self(n-2): n in [1..30]]; // _G. C. Greubel_, Aug 19 2018

%Y Cf. A133570, A228825

%K cofr,sign,easy

%O 0,1

%A _Clark Kimberling_, Sep 04 2013