login
Solution to a Pellian equation: least x such that x^2 - n*y^2 = +- 1.
(Formerly M0120)
10

%I M0120 #53 Dec 22 2021 00:05:17

%S 1,1,2,1,2,5,8,3,1,3,10,7,18,15,4,1,4,17,170,9,55,197,24,5,1,5,26,127,

%T 70,11,1520,17,23,35,6,1,6,37,25,19,32,13,3482,199,161,24335,48,7,1,7,

%U 50,649,182,485,89,15,151,99,530,31,29718,63,8,1,8,65,48842

%N Solution to a Pellian equation: least x such that x^2 - n*y^2 = +- 1.

%C When n is a square, the trivial solution x=1, y=0 is taken; otherwise we take the least x that satisfies either the +1 or -1 equation. - _T. D. Noe_, May 19 2007

%C Apparently the generating function of the sequence of the denominators of continued fraction convergents to sqrt(n) is always rational and of form p(x)/[1 - C*x^m + (-1)^m * x^(2m)], or equivalently, the denominators satisfy the linear recurrence b(n+2m) = C*b(n+m) - (-1)^m * b(n). If so, then it seems that a(n) is half the value of C for each nonsquare n, or 1. See A003285 for the conjecture regarding m. The same conjectures apply to the sequences of the numerators of continued fraction convergents to sqrt(n). - _Ralf Stephan_, Dec 12 2013

%C The conjecture is true, cf. link. - _Jan Ritsema van Eck_, Mar 08 2021

%D A. Cayley, Report of a committee appointed for the purpose of carrying on the tables connected with the Pellian equation ..., Collected Mathematical Papers. Vols. 1-13, Cambridge Univ. Press, London, 1889-1897, Vol. 13, pp. 430-443.

%D C. F. Degen, Canon Pellianus. Hafniae, Copenhagen, 1817.

%D D. H. Lehmer, Guide to Tables in the Theory of Numbers. Bulletin No. 105, National Research Council, Washington, DC, 1941, p. 55.

%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

%H T. D. Noe, <a href="/A006702/b006702.txt">Table of n, a(n) for n = 1..10000</a>

%H A. Cayley, <a href="/A002349/a002349.pdf">Report of a committee appointed for the purpose of carrying on the tables connected with the Pellian equation ...</a>, Collected Mathematical Papers. Vols. 1-13, Cambridge Univ. Press, London, 1889-1897, Vol. 13, pp. 430-443. (Annotated scanned copy)

%H Jan Ritsema van Eck, <a href="/A006702/a006702_1.pdf">Proof of conjecture in A006702</a>, Mar 08 2021

%H M. Zuker, <a href="https://web.archive.org/web/20081204030729/http://www.bioinfo.rpi.edu/~zukerm/cgi-bin/dq.html">Fundamental solution to Pell's Equation x^2 - d*y^2 = +-1</a>

%t r[x_, n_] := Reduce[y > 0 && (x^2 - n*y^2 == -1 || x^2 - n*y^2 == 1 ), y, Integers];

%t a[n_ /; IntegerQ[ Sqrt[n]]] = 1;

%t a[n_] := a[n] = (k = 1; While[ r[k, n] === False, k++]; k);

%t Table[ Print[ a[n] ]; a[n], {n, 1, 67}] (* _Jean-François Alcover_, Jan 30 2012 *)

%t nmax = 500;

%t nconv = 200; (* The number of convergents 'nconv' should be increased if the linear recurrence is not found for some terms. *)

%t a[n_] := a[n] = Module[{lr}, If[IntegerQ[Sqrt[n]], 1, lr = FindLinearRecurrence[Numerator[Convergents[Sqrt[n], nconv]]]; SelectFirst[lr, #>1&]/2]];

%t Table[Print[n, " ", a[n] ]; a[n], {n, 1, nmax}] (* _Jean-François Alcover_, Feb 22 2021 *)

%Y Cf. A006703, A077232.

%K nonn,nice,easy

%O 1,3

%A _N. J. A. Sloane_

%E Corrected and extended by _T. D. Noe_, May 19 2007