Denis Simon on Thu, 27 Nov 2008 11:21:08 +0100

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Pell's equations and beyond

Dear Max,

In order to find a rational solution for the equation a*x^2+b*y^2+c*z^2=0, 
or more general quadratic equations, you can use my GP script:

- step 1: download it from
- step 2: start GP
- step 3: type the command 
  (eventually with the full path to this file)
- step 4: build the Gram matrix Q of the quadratic form. In your situation 
just type :
      Q = matdiagonal([a,b,c]);
- step 5: Solve the equation :
      sol = Qfsolve(Q)
-step 6: the answer is either a rational solution or a prime number 
such that the equation has no local solution at that prime.

Now, have fun with it !
Denis SIMON.

On Tue, 25 Nov 2008, Max Alekseyev wrote:

> On Fri, Nov 21, 2008 at 6:45 AM, Bill Allombert
> <> wrote:
> >> One of important reasons I like Dario Alpern's java applet - it simply
> >> does "the job" for generic input by taking care of all possible
> >> branchings and degenerate cases. I would very welcome similar
> >> functionality for PARI/GP...
> >>
> >> As PARI/GP provides only basic functionality, I wonder if there is
> >
> > You are slightly unfair with PARI: PARI includes efficient algorithms to solve
> > this task in (at worse) subexponential time, and so it can be used to deal with
> > much larger coefficients than the above applet, and that is the hard
> > part of the work.
> I did not mean to diminish PARI/GP abilities. I just wanted to check
> if there is an extension that will make its functionality more "user
> friendly" w.r.t. solving quadratic diophantine equations.
> The aforementioned applet is user friendly but far from optimal and
> has certain limitations (e.g., on the size of coefficients/solutions).
> That's why I wondered if PARI/GP can provide similar "interface" to
> the user.
> On the other hand, I don't feel myself experienced enough neither with
> PARI functionality nor with the theory of quadratic forms to write an
> efficient GP script. That's was the reason to request it here.
> Anyway, thank you for the script, even though it does not handle all the cases.
> P.S. btw, I have a somewhat related question - what is the most
> efficient way to solve in PARI/GP equations of the form a*x^2 + b*y^2
> + c*z^2 = 0 w.r.t. integer x,y,z, where a,b,c are given integer
> coefficients?
> Regards,
> Max