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.

Showing 1-2 of 2 results.

A228488 Period length of trace(sqrt(n)).

Original entry on oeis.org

0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 3, 1, 1, 0, 1, 1, 4, 1, 2, 4, 1, 1, 0, 1, 1, 1, 4, 1, 6, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 6, 1, 4, 8, 1, 1, 0, 1, 1, 4, 4, 4, 1, 1, 2, 4, 4, 1, 7, 1, 1, 0, 1, 1, 8, 1, 6, 4, 6, 1, 5, 3, 1, 8, 4, 1, 1, 1, 0, 1, 1, 1, 4, 6
Offset: 0

Views

Author

Clark Kimberling, Aug 23 2013

Keywords

Comments

It is assumed that trace(sqrt(n)) is purely periodic, as conjectured at A228487 where trace is defined.
If n is a square, then trace(sqrt(n)) is the empty word, denoted by E. Examples:
n ........... trace(sqrt(n))
1 ........... E
2 ........... 000000000...
3 ........... 111111111...
4 ........... E
5 ........... 000000000...
6 ........... 000000000...
7 ........... 111111111...
8 ........... 111111111...
9 ........... E
10 .......... 000000000...
11 .......... 000000000...
12 .......... 000000000...
13 .......... 110(repeated)
19 .......... 0110(repeated)
22 .......... 1001(repeated)
31 .......... 100010(repeated)
46 .......... 11000101(repeated)

Examples

			a(13) = 3 because the trace(sqrt(13)) = 110(repeated) has period length 3.
		

Crossrefs

Programs

  • Mathematica
    $MaxExtraPrecision = Infinity; period[seq_] := (If[Last[#1] == {} || Length[#1] == Length[seq] - 1, 0, Length[#1]] &)[NestWhileList[Rest, Rest[seq], #1 != Take[seq, Length[#1]] &, 1]]; periodicityReport[seq_] := ({Take[seq, Length[seq] - Length[#1]], period[#1], Take[#1, period[#1]]} &)[Take[seq, -Length[NestWhile[Rest[#1] &, seq, period[#1] == 0 &, 1, Length[seq]]]]]
    (*output format: {initial segment, period length, period}*)
    t[{x_, y_, }] := t[{x, y}]; t[{x, y_}] := Prepend[If[# > y - #, {y - #, 1}, {#, 0}], y]&[Mod[x, y]]; userIn2[{x_, y_}] := Most[NestWhileList[t, {x, y}, (#[[2]] > 0) &]];
    z = 160; pr = Table[If[IntegerQ[Sqrt[n]], {0, 0}, p = Convergents[Sqrt[n], z]; pairs = Table[{Numerator[#], Denominator[#]} &[p[[k]]], {k, 1, z}]; periodicityReport[    Most[Last[Map[Map[#[[3]] &, Rest[userIn2[#]]] &, pairs]]]]], {n, 120}]
    m = Map[#[[2]] &, pr]  (* Peter J. C. Moses, Aug 22 2013 *)

A228667 Array: row n shows the accelerated continued fraction of F(n+1)/F(n), where F = A000045 (Fibonacci numbers).

Original entry on oeis.org

1, 2, 1, 2, 1, 1, 2, 2, -2, -2, 2, -3, 3, 2, -3, 2, 2, 2, -3, 3, -3, 2, -3, 3, -2, -2, 2, -3, 3, -3, 3, 2, -3, 3, -3, 2, 2, 2, -3, 3, -3, 3, -3, 2, -3, 3, -3, 3, -2, -2, 2, -3, 3, -3, 3, -3, 3, 2, -3, 3, -3, 3, -3, 2, 2, 2, -3, 3, -3, 3, -3, 3, -3, 2, -3, 3
Offset: 0

Views

Author

Clark Kimberling, Aug 29 2013

Keywords

Comments

The accelerated continued fraction (ACF) of a positive rational number x/y, where GCD(x,y) = 1, is defined by the algorithm below. The number of terms in ACF(x/y) is <= the number of terms in the classical continued fraction CF(x/y).
Step 1. Put w = Mod[x,y]. If w=0, put c(0) = x/y and Stop.
If 0 < w <= y/2, put c(0) = floor(x/y), u->y, v->w, f->1, go to step 2;
if w>y/2, put c(0) = 1 + floor(x/y), u->y, v->y - w, f->-1, go to step 2.
For i>=2, Step i is in 5 cases, as follows:
Case 0.1: f = 1 and w = 0. Put w = Mod[x,y] and c(i) = u/v and Stop.
Case 0.2: f = -1 and w = 0. Put w = Mod[x,y] and c(i) = -u/v and Stop.
Case 1: f = 1 and w <= v/2. Put w = Mod[x,y] and c(i) = floor(u/v), u->v, v->w, f->1, go to step i+1.
Case 2: f = 1 and w > v/2. Put w = Mod[x,y] and c(i) = 1 + floor(u/v), u->y, v->v - w, f->-1, go to step i+1.
Case 3: f = -1 and w <= v/2. Put w = Mod[x,y] and c(i) = -floor(u/v), u->v, v->w, f->-1, go to step i+1.
Case 4: f = -1 and w > v/2. Put w = Mod[x,y] and c(i) = -1 - floor(u/v), u->y, v->v - w, f->-f, go to step i+1.

Examples

			x/y ......... ACF(x/y)
1/1 ......... 1
2/1 ......... 2
3/2 ......... 1,2
5/3 ......... 1,1,2
8/5 ......... 2,-2,-2
13/8 ........ 2,-3,3
21/13 ....... 2,-3,2,2
34/21 ....... 2,-3,3,-3
55/34 ....... 2,-3,3,-2,-2
89/55 ....... 2,-3,3,-3,3
		

Crossrefs

Programs

  • Mathematica
    $MaxExtraPrecision = Infinity; aCF[rational_] := Module[{steps = {}, stop = False, i = 0, x = Numerator[rational], y = Denominator[rational], w, u, v, f, c},(*Step 1*)w = Mod[x, y]; Which[w == 0, c[i] = x/y; stop = True; AppendTo[steps, "A"], 0 < w <= y/2, c[i] = Floor[x/y]; {u, v, f} = {y, w, 1}; AppendTo[steps, "B"], w > y/2, c[i] = 1 + Floor[x/y]; {u, v, f} = {y, y - w, -1}; AppendTo[steps, "C"]];  i++; (*Step 2*)While[stop =!= True, w = Mod[u, v]; Which[f == 1 && w == 0, c[i] = u/v; stop = True; AppendTo[steps, "0.1"], f == -1 && w == 0, c[i] = -u/v; stop = True; AppendTo[steps, "0.2"], f == 1 && w <= v/2, c[i] = Floor[u/v]; {u, v, f} = {v, w, 1}; AppendTo[steps, "1"], f == 1 && w > v/2, c[i] = 1 + Floor[u/v]; {u, v, f} = {v, v - w, -1}; AppendTo[steps, "2"], f == -1 && w <= v/2, c[i] = -Floor[u/v]; {u, v, f} = {v, w, -1}; AppendTo[steps, "3"], f == -1 && w > v/2, c[i] = -1 - Floor[u/v]; {u, v, f} = {v, v - w, -f}; AppendTo[steps, "4"]]; i++];  (*Display results*){FromContinuedFraction[#], {"Steps", steps}, {"ACF", #}, {"CF", ContinuedFraction[x/y]}} &[Map[c, Range[i] - 1]]]
    Table[aCF[Fibonacci[n + 1]/Fibonacci[n]], {n, 1, 20}]
    (* Peter J. C. Moses, Aug 28 2013 *)
Showing 1-2 of 2 results.