'''Pell numbers''' are an infinite sequence of integers that comprise the denominators of the closest rational approximations to the square root of 2 but have many other interesting uses and relationships.

The numerators of each term of rational approximations to the square root of 2 may ''also'' be derived from '''Pell numbers''', or may be found by taking half of each term of the related sequence: '''Pell-Lucas''' or '''Pell-companion numbers'''.


The '''Pell numbers''': '''0, 1, 2, 5, 12, 29, 70, etc.''', are defined by the recurrence relation:

 <span style="font-size:125%;font-weight:bold;">
 P<sub>0</sub> = 0;
 P<sub>1</sub> = 1;
 P<sub>n</sub> = 2 × P<sub>n-1</sub> + P<sub>n-2</sub>;
 </span>

Or, may also be expressed by the closed form formula:

 <span style="font-size:125%;font-weight:bold;">
 P<sub>n</sub> = ((1 + √2)<sup>n</sup> - (1 - √2)<sup>n</sup>) / (2 × √2);
 </span>


'''Pell-Lucas''' or '''Pell-companion numbers''': '''2, 2, 6, 14, 34, 82, etc.''', are defined by a very similar recurrence relation, differing only in the first two terms:

 <span style="font-size:125%;font-weight:bold;">
 Q<sub>0</sub> = 2;
 Q<sub>1</sub> = 2;
 Q<sub>n</sub> = 2 × Q<sub>n-1</sub> + Q<sub>n-2</sub>;
 </span>

Or, may also be expressed by the closed form formula:

 <span style="font-size:125%;font-weight:bold;">
 Q<sub>n</sub> = (1 + √2)<sup>n</sup> + (1 - √2)<sup>n</sup>;
 </span>

or

 <span style="font-size:125%;font-weight:bold;">
 Q<sub>n</sub> = P<sub>2n</sub> / P<sub>n</sub>;
 </span>



The sequence of rational approximations to the square root of 2 begins:

 <span style="font-size:125%;font-weight:bold;">
 1/1, 3/2, 7/5, 17/12, 41/29, ...
 </span>

Starting from '''n = 1''', for each term, the denominator is '''P<sub>n</sub>''' and the numerator is '''Q<sub>n</sub> / 2''' or '''P<sub>n-1</sub> + P<sub>n</sub>'''.




'''Pell primes''' are '''Pell numbers''' that are prime. '''Pell prime indices''' are the indices of the primes in the '''Pell numbers''' sequence. Every '''Pell prime''' index is prime, though not every prime index corresponds to a prime '''Pell number'''.



If you take the sum '''S''' of the first '''4n + 1''' '''Pell numbers''', the sum of the terms '''P<sub>2n</sub>''' and '''P<sub>2n + 1</sub>''' will form the square root of '''S'''.

For instance, the sum of the '''Pell numbers''' up to '''P<sub>5</sub>'''; '''0 + 1 + 2 + 5 + 12 + 29 == 49''', is the square of '''P<sub>2</sub> + P<sub>3</sub> == 2 + 5 == 7'''. The sequence of numbers formed by the sums '''P<sub>2n</sub> + P<sub>2n + 1</sub>''' are known as '''Newman-Shank-Williams numbers''' or '''NSW numbers'''.



'''Pell numbers''' may also be used to find Pythagorean triple '''near isosceles right triangles'''; right triangles whose legs differ by exactly '''1'''. E.G.: '''(3,4,5), (20,21,29), (119,120,169), etc.'''

For '''n > 0''', each right triangle hypotenuse is '''P<sub>2n + 1</sub>'''. The shorter leg length is the sum of the terms ''up to'' '''P<sub>2n + 1</sub>'''. The longer leg length is '''1''' more than that.



;Task
;* Find and show at least the first 10 '''Pell numbers'''.
;* Find and show at least the first 10 '''Pell-Lucas numbers'''.
;* Use the '''Pell''' (and optionally, '''Pell-Lucas''') '''numbers''' sequence to find and show at least the first 10 rational approximations to √2 in both rational and decimal representation.
;* Find and show at least the first 10 '''Pell primes'''.
;* Find and show at least the first 10 indices of '''Pell primes'''.
;* Find and show at least the first 10 '''Newman-Shank-Williams numbers'''
;* Find and show at least the first 10 Pythagorean triples corresponding to '''near isosceles right triangles'''.



;See also
;* [[wp:Pell_number|Wikipedia: Pell number]]
;* [[oeis:A000129|OEIS:A000129 - Pell numbers]]
;* [[oeis:A002203|OEIS:A002203 - Companion Pell numbers]] (Pell-Lucas numbers)
;* [[oeis:A001333|OEIS:A001333 - Numerators of continued fraction convergents to sqrt(2)]] (Companion Pell numbers / 2)
;* [[oeis:A086383|OEIS:A086383 - Prime terms in the sequence of Pell numbers]]
;* [[oeis:A096650|OEIS:A096650 - Indices of prime Pell numbers]]
;* [[oeis:A002315|OEIS:A002315 - NSW numbers]] (Newman-Shank-Williams numbers)
;* [[wp:Pythagorean_triple|Wikipedia: Pythagorean triple]]
;* [[Pythagorean triples]]





