# Finding all integer solutions of binary quadratic form

I found the following page to calculate one solution for a binary quadratic form $ax^2+bxy +cy^2$: Link

Is there an algorithm to find, if possible, all integer solutions?

edit retag close merge delete

Here you might find some functions that might be of interest for you (and, among other things, also encapsulate pari's qfbsolve): BQForms

( 2024-02-20 22:00:39 +0200 )edit

Sort by ยป oldest newest most voted

You can call pari.qfbsolve directly with flag set to 1 or 3. Rephrasing examples from the PARI/GP manual:

sage: pari.qfbsolve(pari.Qfb(1,0,2), 603, 1).sage()       # all primitive solutions
[[5, 17], [-19, -11], [19, -11], [5, -17]]

sage: pari.qfbsolve(pari.Qfb(1,0,2), 603, 3).sage()       # all solutions
[[5, 17], [-19, -11], [19, -11], [5, -17], [-21, 9], [-21, -9]]

more

( 2024-02-22 17:37:09 +0200 )edit

Some years ago, on a blog on the OEIS, I implemented various algorithms with a simple common interface in Sage, written in Python2.

Your question prompted me to update the code to Python3 and make it available on GitHub. It also describes how to experiment with it on the Sage Cell Server.

Specifying the three coefficients (a, b, c) and the desired restriction, one of {all, primitively, prime}, not only returns the representatives but also points to the sequence in the OEIS (if it is registered there).

https://github.com/PeterLuschny/Binar...

more