Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Generating the non-fundamental solutions of Pell's equation

Hi. The topic of Pell's equation seems to be quite minor among coding sites so I've come to ask for help from professionals at here SageMath community.

https://mathsci.kaist.ac.kr/cms/wp-content/uploads/2017/11/NumberTheory_Sage.pdf

def solve_pell (N , numTry = 100):
    cf = continued_fraction ( sqrt ( N ))
    for i in range ( numTry ):
        denom = cf.denominator ( i )
        numer = cf.numerator ( i )
        if numer ^2 - N * denom ^2 == 1:
            return numer , denom
    return None , None


solve_pell (21)

The code attached in the last page of the link above works really fine. It finds the fundamental solutions of Pell's equation and I've never seen any other shorter code than the code in the link.

I usually prefer to use the library codes than my own-made codes for the sake of efficiency. However if there isn't any relevant sources, I would have no other choice but make some new codes.

So my questions,

1. Are there any library functions, the libraries that are supported by Sage, regarding finding the non-fundamental solutions of Pell's equation?

2. If not, could you suggest some idea for the code which do the task we desire?

I've tried to make my own code by referring to the algorithm in a document from Wikipedia

however it seems to be using symbolic computations heavily of which I've never tried before. I would be glad for any kind of advice via commens and answers. Thanks.

Generating the non-fundamental solutions of Pell's equation

Hi. The topic of Pell's equation seems to be quite minor among coding sites so I've come to ask for help from professionals at here SageMath community.

https://mathsci.kaist.ac.kr/cms/wp-content/uploads/2017/11/NumberTheory_Sage.pdf

def solve_pell (N , numTry = 100):
    cf = continued_fraction ( sqrt ( N ))
    for i in range ( numTry ):
        denom = cf.denominator ( i )
        numer = cf.numerator ( i )
        if numer ^2 - N * denom ^2 == 1:
            return numer , denom
    return None , None


solve_pell (21)

The code attached in the last page of the link above works really fine. It finds the fundamental solutions of Pell's equation and I've never seen any other shorter code than the code in the link.

I usually prefer to use the library codes than my own-made codes for the sake of efficiency. However if there isn't aren't any relevant sources, I would have no other choice choices but make some new codes.

So my questions,

1. Are there any library functions, the libraries that are supported by Sage, regarding finding the non-fundamental solutions of Pell's equation?

2. If not, could you suggest some idea for the code which do the task we desire?

I've tried to make my own code by referring to the algorithm in a document from Wikipedia

however it seems to be using symbolic computations heavily of which I've never tried before. I would be glad for any kind of advice via commens and answers. Thanks.

Generating the non-fundamental solutions of Pell's equation

Hi. The topic of Pell's equation seems to be quite minor among coding sites so I've come to ask for help from professionals at here SageMath community.

https://mathsci.kaist.ac.kr/cms/wp-content/uploads/2017/11/NumberTheory_Sage.pdf

def solve_pell (N , numTry = 100):
    cf = continued_fraction ( sqrt ( N ))
    for i in range ( numTry ):
        denom = cf.denominator ( i )
        numer = cf.numerator ( i )
        if numer ^2 - N * denom ^2 == 1:
            return numer , denom
    return None , None


solve_pell (21)

The code attached in the last page of the link above works really fine. It finds the fundamental solutions of Pell's equation and I've never seen any other shorter code than the code in the link.

I usually prefer to use the library codes than my own-made self-made codes for the sake of efficiency. However if there aren't any relevant sources, I would have no other choices but make some new codes.

So my questions,

1. Are there any library functions, the libraries that are supported by Sage, regarding finding the non-fundamental solutions of Pell's equation?

2. If not, could you suggest some idea for the code which do the task we desire?

I've tried to make my own code by referring to the algorithm in a document from Wikipedia

however it seems to be using symbolic computations heavily of which I've never tried before. I would be glad for any kind of advice via commens and answers. Thanks.