(12C) Pell's Equation
|
07-07-2018, 05:16 AM
(This post was last modified: 07-07-2018 05:21 AM by Gamo.)
Post: #1
|
|||
|
|||
(12C) Pell's Equation
Pell's equation (also called the Pell–Fermat equation) is the equation of the form of
X^2 - nY^2 = 1 Where n is a given positive none square integer and integer solutions are sought for X and Y. More information about this topic: https://en.wikipedia.org/wiki/Pell%27s_equation I personally make a note on this subject found on this MoHPC old forum and don't remember who posted this in the forum. I found this very interesting and would like to share his clever program to solve this special equation. Example: X^2 - (3)Y^2 = 1 3 R/S --> 2 X<>Y 1 Answer: X=2, Y=1 Remark: The list of the possible n is shown in the Wikipedia link. Program: Pell's Equation Code:
Gamo |
|||
07-07-2018, 09:29 AM
Post: #2
|
|||
|
|||
RE: (12C) Pell's Equation
(07-07-2018 05:16 AM)Gamo Wrote: I personally make a note on this subject found on this MoHPC old forum and don't remember who posted this in the forum. Cf. Re: x^2 - N*y^2 = 1 (12C) and 12-digit cut-off Other threads related to that topic are: |
|||
07-07-2018, 11:24 AM
(This post was last modified: 07-07-2018 11:35 AM by Dieter.)
Post: #3
|
|||
|
|||
RE: (12C) Pell's Equation
(07-07-2018 05:16 AM)Gamo Wrote: I personally make a note on this subject found on this MoHPC old forum and don't remember who posted this in the forum. The program you posted was written by Gerson W. Barbosa, it can be found in the old forum as linked in Thomas' post. The limitations of a 10-digit calculator have already been mentioned. This means that results with 6 digits or more may and will produce roundoff errors when x² or y² is calculated. And checking whether Pell's equation evaluates to 1 or not will fail. Which doesn't mean there is no way – consider the posts by Egan Ford in the mentioned old forum thread. Having said that, here's my attempt. A bit shorter and with less registers. ;-) Code: 01 STO 0 This returns the first solution of the equation (at least if the trivial solution x=1 and y=0 is ingored). Example: n=92 Code: f PRGM But there are infinitely many more solutions. These can be obtained with the recurrence formula as shown in the Wikipedia article. Replace the last three steps in the program above with this: Code: ... Example: n=7 Code: f PRGM Please note that there is no solution if n is the square of an integer. In this case the program will throw an error: 25 [R/S] => Error 0. Dieter |
|||
07-08-2018, 10:51 AM
Post: #4
|
|||
|
|||
RE: (12C) Pell's Equation
Ah...that from Gerson W. Barbosa
So my post is credit to Gerson who make this clever program....Thanks Gerson Gamo |
|||
07-11-2018, 02:49 PM
Post: #5
|
|||
|
|||
RE: (12C) Pell's Equation
For those with an interest
[attachment=6114] an excellent read (IMHO) BEST! SlideRule |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)