%I #42 Nov 03 2024 18:52:50
%S 3,3,5,4,5,4,7,6,5,15,8,5,9,7,12,6,10,12,9,6,11,9,12,21,7,17,9,10,11,
%T 7,13,10,9,9,19,8,20,15,13,24,12,8,15,12,16,27,16,13,9,14,27,17,12
%N Number of pairs of integers (x,y) satisfying the Diophantine equation x^2 - A000037(n)*y^2 = m such that x/y gives a convergent series towards sqrt(A000037(n)).
%C If (x(0),y(0)) and (x(1),y(1)) are solutions of the Diophantine equation x^2 - A000037(n)*y^2 = m, then (x(i),y(i)) with x(i) = A*x(i-1) - x(i-2) and y(i) = A*y(i-1) - y(i-2) are also solutions for i > 1. The sequence represents the number of different integer pair sequences where in all cases A = 2*A033313(A000037(n)). Each contributing sequences has to satisfy the condition that for all x < x(i) and all y < y(i), |x/y - sqrt(A000037(n))| > |x(i)/y(i) - sqrt(A000037(n))|.
%C a(A000037(n)) is not equal to the number of all sequences of pairs (x(i),y(i)) that are solutions of a Diophantine equation x^2 - D*y^2 = m, with -D <= m < D and D = A000037(n). For example for D = 5 we obtain two other sequences from Fibonacci sequence: (first) x(i) = 2*Fib(6i)-Fib(6i-1) and y(i) = Fib(6i-1) satisfy x^2 - D*y^2 = -4 and (second) x(i) = 2*Fib(6i+3) - Fib(6i+2) and y(i) = Fib(6i+2) satisfy x^2 - D*y^2 = 4; but neither of these satisfy the restriction that, for all x < x(i) and all y < y(i), |x/y - sqrt(D)| > |x(i)/y(i) - sqrt(D)|.
%C A good approximation for the order of magnitude of a(n) is given by 2*log(2*A033313(n)).
%C For a lower bound, all values m satisfying either m = -D + k^2 for k^2 < D or m = 1, D = A000037(n), contribute with a sequence to the convergent series of sqrt(D), so a(n) > floor(sqrt(D)) + 1.
%e For A000037(4) = 6, a(4) = 4 we have the following sequences of pairs (x,y):
%e m = 1: x(0) = 1, x(1) = 5, x(i) = 10*x(i-1) - x(i-2) as in A001079(i) and y(0) = 0, y(1) = 2, y(i) = 10*y(i-1) - y(i-2) as in A001078(i);
%e m = -6: x(0) = 0, x(1) = 12, x(i) = 10*x(i-1) - x(i-2) as in A004291(i) (for i > 0) and y(0) = 1, y(1) = 5, y(i) = 10*y(i-1) - y(i-2) as in A001079(i);
%e m = -5: x(0) = 1, x(1) = 17, x(i) = 10*x(i-1) - x(i-2) and y(0) = 1, y(1) = 7, y(i) = 10*y(i-1) - y(i-2);
%e m = -2: x(0) = 2, x(1) = 22, x(i) = 10*x(i-1) - x(i-2) and y(0) = 1, y(1) = 9, y(i) = 10*y(i-1) - y(i-2) as in A072256(i+1).
%e In some cases a combination of A000037(n) and m has more than one integer pair sequence, for example A000037(5) = 7 and m = -3 has two integer pair sequences:
%e x(0) = 2, x(1) = 37, x(i) = 16*x(i-1) - x(i-2) and y(0) = 1, y(1) = 14, y(i) = 16*y(i-1) - y(i-2);
%e x(0) = -2, x(1) = 5, x(i) = 16*x(i-1) - x(i-2) and y(0) = 1, y(1) = 2, y(i) = 16*y(i-1) - y(i-2).
%e For A000037(4) = 6, the sequence observed from x^2 - 6y^2 = 3 is not in the convergent series of sqrt(6) due to for example x1/y1 = 2643/1079 = sqrt(6) + 5.259842e-7 while the smaller x,y pair, x2/y2 = 2158/881 from x^2 - 6y^2 = -2 is a fraction closer to sqrt(5), 2158/881 = sqrt(6) - 5.259841e-7.
%o (Python)
%o from fractions import Fraction
%o def FracSqrt(p):
%o a = Fraction(p/1)
%o b = Fraction(1/1)
%o e = Fraction(10**(-200))
%o while a-b > e:
%o a = (a+b)/2
%o b = p/a
%o return a
%o print("number: ")
%o pp = int(input())
%o p = FracSqrt(pp)
%o n = 0
%o while n >= 0:
%o n = n+1
%o q = p.limit_denominator(n)
%o if (n == 1) or (q != q0):
%o t = q*n
%o m = t*t-pp*n*n
%o print(n,q,m)
%o q0 = q
%Y Cf. A001078, A001079, A004291, A033313, A072256.
%K nonn,more,changed
%O 1,1
%A _A.H.M. Smeets_, Jul 25 2017