-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
GH-1005: Pell's equation #1388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
GH-1005: Pell's equation #1388
Conversation
79f7120 to
a4c3729
Compare
|
Possibly useful: Codeforces - Pythagorean triples and Pell's equations. |
db59072 to
4732ab4
Compare
added in reference section |
123711e to
bd4351c
Compare
adamant-pwn
left a comment
There was a problem hiding this 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?
f88828b to
c72a19c
Compare
added in |
|
Updates? |
|
Updated all suggestions. Have I missed any? |
ab10315 to
5ff3016
Compare
5ff3016 to
32e048b
Compare
|
|
||
| It can also be calculated using only [integer based calculation](https://cp-algorithms.com/algebra/continued-fractions.html) | ||
|
|
||
| ### Finding the solution using Chakravala method |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
271c26a to
3f2791e
Compare
22d960e to
8f4864b
Compare
adamant-pwn
left a comment
There was a problem hiding this 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).
src/others/pells_equation.md
Outdated
|
|
||
| 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$. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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
Additionally, it would be nice to explain why the solution with smallest
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
9cf13e5 to
eea90be
Compare
eea90be to
982d59e
Compare
Proof and how to find using continued fractions.
Chakralava Method
Problems
References