While chatting through an exercise from A Friendly Introduction to Number Theory with Guille, he pointed out a connection between Pell's equation and Newton's method. I thought the perspective was cool, so I wanted to catalog it here. (There's also a connection with square-triangular numbers, which is explored in exercise 3.5.)
Given a nonlinear equation,
Newton's method aims to find a root by starting from an initial guess and then updating this guess with the zero of the line tangent to at , i.e.,
In other words, we linearly approximate at and then find the zero of that approximation.
Pell's equation, in the case is
We wish to find many integer solutions for and . If we have one solution, for example , how can we generate additional solutions?
A slight rearrangement of Pell's equation gives
As and become large, the fraction will provide better and better approximations to .
Inspired by this observation, we'll consider solving the equation with Newton's method. Starting from , Newton's method gives the iteration
If is a rational number, then will be rational as well. Thus, we can write for some integers and . Plugging this in, we get the iteration
Splitting the numerator and denominator, we have the updates
Assume that is a solution to Pell's equation. Plugging in the update shows that is also a solution:
In other words, given an initial solution to Pell's equation, e.g., , we can generate additional solutions via Newton's method applied to the root finding problem. The ratio will also provide a better and better approximation to .
Exercise 3.5 in the book derives this procedure using a more geometric approach. This derivation via Newton's method is likely well-known (my number theory knowledge is lacking), but I thought it was an interesting connection.