login
In continued fraction convergents of sqrt(d), where d=A005117(n) (squarefree numbers), the position of a/b where abs(a^2 - d*b^2) = 1 or 4.
0

%I #32 Feb 04 2024 15:39:22

%S 2,4,1,2,1,4,2,1,6,2,6,4,1,1,2,8,4,4,2,1,2,2,3,2,10,12,4,2,1,4,6,7,6,

%T 3,4,1,2,10,2,6,8,7,5,2,4,4,1,2,1,10,2,5,8,4,16,4,11,1,2,12,2,9,6,5,2,

%U 6,9,6,10,10,4,1,2,12,10,3,6,4,14,9,4,18,4,4,2,1,2,3,20,10,4,5,8,10,10,18,2,22

%N In continued fraction convergents of sqrt(d), where d=A005117(n) (squarefree numbers), the position of a/b where abs(a^2 - d*b^2) = 1 or 4.

%C The golden ratio is the fundamental unit for sqrt(5), but 1/1 isn't a convergent, so this sequence starts with squarefree number A005117(5)=6.

%e A005117(13)=19. 170^2 - 19*39^2 = 1. The 6th convergent of sqrt(19) is 170/39.

%e A005117(14)=21. 5^2 - 21*1^2 = 4. The 2nd convergent of sqrt(21) is 5/1.

%e A005117(15)=22. 197^2 - 22*42^2 = 1. The 6th convergent of sqrt(22) is 197/42.

%e A005117(16)=23. 24^2 - 23*5^2 = 1. The 4th convergent of sqrt(23) is 24/5.

%e Corresponding fundamental units are 170+39*sqrt(19), 5+sqrt(21), 197+42*sqrt(22) and 24+5*sqrt(23).

%p f:= proc(x) local CF, k,v,w;

%p uses NumberTheory;

%p CF:= ContinuedFraction(sqrt(x));

%p for k from 0 do

%p v:= Convergent(CF,k);

%p w:= abs(numer(v)^2 - x*denom(v)^2);

%p if w = 1 or w = 4 then return k+1 fi;

%p od

%p end proc:

%p count:= 0: R:= NULL:

%p for i from 6 while count < 100 do if NumberTheory:-IsSquareFree(i) then R:= R, f(i); count:= count+1 fi

%p od:

%p R; # _Robert Israel_, Mar 12 2023

%t (* store A005117 and A107997 first *) Flatten[Table[sqr = Sqrt[A005117[[n]]];

%t fun = RootReduce[NumberFieldFundamentalUnits[Sqrt[A005117[[n]]]]][[1]];

%t forcon = If[MemberQ[A107997, A005117[[n]]], RootReduce[2 fun], fun];

%t converge = Convergents[ContinuedFraction[N[sqr, 140]]];

%t Flatten[Position[converge, Abs[forcon[[1]]/(forcon[[2]]/ sqr)]]], {n, 4, 101}]]

%Y Cf. A005117, A107997.

%K nonn

%O 5,1

%A _Ed Pegg Jr_, Mar 09 2023