Skip to content

Conversation

@Bhaskar1312
Copy link

@Bhaskar1312 Bhaskar1312 commented Nov 1, 2024

Proof and how to find using continued fractions.

Chakralava Method
Problems
References

@Bhaskar1312 Bhaskar1312 changed the title Pell's equation GH-1005: Pell's equation Nov 1, 2024
@adamant-pwn
Copy link
Member

@Bhaskar1312
Copy link
Author

Bhaskar1312 commented Nov 17, 2024

Possibly useful: Codeforces - Pythagorean triples and Pell's equations.

added in reference section

@Bhaskar1312 Bhaskar1312 marked this pull request as ready for review November 17, 2024 19:37
Copy link
Member

@adamant-pwn adamant-pwn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, could you please add this article to README.md and mavigation.md into lists of new articles?

@Bhaskar1312
Copy link
Author

Hi, could you please add this article to README.md and mavigation.md into lists of new articles?

added in README.md. have I added incorrectly in navigation.md or in incorrect section?

@Bhaskar1312 Bhaskar1312 requested a review from adamant-pwn March 30, 2025 11:31
@mhayter
Copy link
Contributor

mhayter commented Apr 11, 2025

Updates?

@Bhaskar1312
Copy link
Author

Updated all suggestions. Have I missed any?


It can also be calculated using only [integer based calculation](https://cp-algorithms.com/algebra/continued-fractions.html)

### Finding the solution using Chakravala method
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks complicated. Are there specific reasons to do it over continued fractions variant? I find the exposition very hard to read (largely because of misrenders, though).

Unless it's in some way better than continued fractions method, I'd consider dropping the section altogether.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added link to continued fractions and removed floating point based

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! But I'm still not convinced this section is needed at all. It seems much more complicated than doing it with convergents. I really think we should either have a good reason to include it (e.g. mention why is it better than convergents), or remove it.

@Bhaskar1312 Bhaskar1312 force-pushed the GH-1005/pells-eqn branch 3 times, most recently from 271c26a to 3f2791e Compare April 19, 2025 02:46
@Bhaskar1312 Bhaskar1312 force-pushed the GH-1005/pells-eqn branch 2 times, most recently from 22d960e to 8f4864b Compare October 5, 2025 16:55
Copy link
Member

@adamant-pwn adamant-pwn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for the updates! I think we should still add some changes to it (see the review).


The norm of an expression $u + v \sqrt{d}$ is defined as $N(u + v \sqrt{d}) = (u + v \sqrt{d})(u - v \sqrt{d}) = u^2 - d v^2$. The norm is multiplicative: $N(ab) = N(a)N(b)$. This property is crucial in the descent argument below.

We will prove that all solutions to Pell's equation are given by powers of the smallest positive solution. Let's assume it to be $x_0 + y_0 \sqrt{d}$, where $x_0 > 1$ is the smallest possible value for $x$.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We will prove that all solutions to Pell's equation are given by powers of the smallest positive solution. Let's assume it to be $x_0 + y_0 \sqrt{d}$, where $x_0 > 1$ is the smallest possible value for $x$.
We will prove that all solutions to Pell's equation are given by powers of the smallest non-trivial solution. Let's assume it to be the minimum possible $x_0 + y_0 \sqrt{d} > 1$. For such a solution, it also holds that $y_0 > 0$, and its $x_0 > 1$ is the smallest possible value for $x$.

I think we need to disambiguate between $x_0 \pm y_0 \sqrt{d}$. Also, There is no such thing as smallest positive solution, as $x - y \sqrt d$ solutions can be arbitrarily close to $0$, as real numbers.

Additionally, it would be nice to explain why the solution with smallest $x_0 > 1$ and $y_0 > 0$ also produces the minimum possible values of $x_0 + y_0 \sqrt d$.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is given in equations in method of descent section


The convergents $p_n/q_n$ are the rational approximations to $\sqrt{d}$ obtained by truncating the continued fraction expansion at each stage. These convergents can be computed recursively. For Pell's equation, the convergent $(p_n, q_n)$ at the end of the period solves $p_n^2 - d q_n^2 = \pm 1$.

Check whether the convergent satisfies Pell's equation. If it does, then the convergent is the smallest positive solution.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also write what happens if it doesn't...

Hence, we conclude that all solutions are given by $( x_{0} + \sqrt{d} \cdot y_{0} )^{n}$ for some integer $n$.

## Finding the smallest positive solution
### Expressing the solution in terms of continued fractions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include a proof to this? I have it on Codeforces, but it's a bit technically involved, I suppose...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proof is already in method of descent section

d0 = 1
a0 = int(math.isqrt(n))
period = []
m, d, a = m0, d0, a0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to add some details on what expression you represent with $m$, $d$ and $a$. I'm used to maintaining the complete quotient as $\frac{x+y\sqrt n}{z}$, but evidently this is not what's happening here...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added recurrence relations


It can also be calculated using only [integer based calculation](https://cp-algorithms.com/algebra/continued-fractions.html)

### Finding the solution using Chakravala method
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! But I'm still not convinced this section is needed at all. It seems much more complicated than doing it with convergents. I really think we should either have a good reason to include it (e.g. mention why is it better than convergents), or remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants