Pell's equation

198 views
Skip to first unread message

Michael Beeson

unread,
Oct 31, 2014, 12:14:02 PM10/31/14
to sage-s...@googlegroups.com
Here I attempt to solve Pell's equation with d = 1621 following the method on page 93 of Stein's book.
But the solution produced is instead a solution of the negative Pell equation x^2-y^2 = -1  (instead of 1).
Actually, the example on page 93 (after correcting the typo "v" to "u") has the same problem:  it claims 
that [-2,1]  solves Pell's equation with d=5,  whereas, it really solves the negative Pell equation.

sage: K.<a> = QuadraticField(1621)
sage: G = K.unit_group()
sage: u = G.1
sage: L = [list(u^i) for i in [0..3]]
sage: L
[[1, 0], [4823622127875/2, 119806883557/2], [23267330432525342852015627/2, 577903134597288688851375/2], [56116404965454319198851772383057215250, 1393793173905903098261469193463230841]]
sage: x = L[2][0];
sage: y = L[2][1];
sage: x
23267330432525342852015627/2
sage: x = L[3][0];
sage: y = L[3][1];
sage: x
56116404965454319198851772383057215250
sage: y
1393793173905903098261469193463230841
sage: x^2-1621*y^2
-1


Vincent Delecroix

unread,
Nov 1, 2014, 5:40:08 PM11/1/14
to sage-s...@googlegroups.com
Hello,

First of all, I was not able to run your code. It fails on the line

sage: L = [list(u^i) for i in [0..3]]

Hopefully, with list(K(u^i)) instead of list(u^i) it works fine.

I did not check the reference but the units of a quadratic number
fields are the solution of Pell equation with either 1 or -1 (which
are the invertible elements in Z). And actually, the subgroup of
solutions which corresponds to 1 always form a subgroup (which is
either the whole group or a subgroup of index 2). As you can see with
the same example, taking the square of a solution with -1 you get 1
because the norm is multiplicative

sage: x,y = K(u)
sage: x^2-1621*y^2
-1
sage: K(u).norm()
-1

sage: x,y = K(u)**2
sage: x^2-1621*y^2
1
sage: K(u**2).norm()
1

I am not sure it solves the issue from the reference.

Vincent

2014-10-31 10:14 UTC−06:00, Michael Beeson <profb...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support...@googlegroups.com.
> To post to this group, send email to sage-s...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.
>

John Cremona

unread,
Nov 2, 2014, 12:55:07 PM11/2/14
to SAGE support
I was not sure whether your question was mathematical or
computational. Usually "Pell equation" means the +1 equation and ones
says "negative Pell equation" for the -1 version. (I once wrote a
paper "On the negative Pell equation"!). As Vincent says if you have
a solution x+y*sqrt(d) to the negative equation, square it to get a
solution to the positive equation.

But perhaps you just meant that the instructions were confusing?

John Cremona

Michael Beeson

unread,
Nov 2, 2014, 1:38:48 PM11/2/14
to sage-s...@googlegroups.com
This question was simply a result of my misreading the example on page 93, where it says

"We first solve Pell's equation x2 􀀀 5y2 = 1 with d = 5 by nding the units of

the ring of integers of Q(sqrt(5) using Sage."  Of course I should have realized

that just finding those units will give me the solutions of x^2 - 5 y^2 = plus or minus 1, not just 1.

I'm sorry for taking your time to point that out.

Reply all
Reply to author
Forward
0 new messages