ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 30 Jan 2023 12:26:29 +0100Generating the non-fundamental solutions of Pell's equationhttps://ask.sagemath.org/question/66142/generating-the-non-fundamental-solutions-of-pells-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 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](https://en.wikipedia.org/wiki/Pell%27s_equation#Additional_solutions_from_the_fundamental_solution) 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.VibapMon, 30 Jan 2023 12:26:29 +0100https://ask.sagemath.org/question/66142/