Ask Your Question
1

Routines for Pell's equations

asked 2017-12-17 17:21:54 +0200

RahulKrishnan gravatar image

Hi,

I am interested in finding solutions to Pell's equations in finite fields. Are there Sagemath routines that I could use or should I create my own routines? I am interested in finding out solutions to the general equation x^2 - Dy^2 = 1 (mod p). Solutions to this form an closed Abelian group and the points form a cyclic subgroup.

Any suggestions/pointers would be deeply appreciated. Thank you, Rahul

edit retag flag offensive close merge delete

Comments

Please give us an explicit example, i.e. values for the prime (power?) $p$ and $D$. Brute force works, computing the points of the rational curve works, associating the subgroup of $SL(2,F)$ with entries $x, y, Dy, x$ works. The solution should but best support the further application.

dan_fulea gravatar imagedan_fulea ( 2017-12-18 12:08:36 +0200 )edit

Let's say D = 2 and p = 11, Is there a routine that outputs all the solutions to the equation x^2 - 2y^2 mod 11? Thanks

RahulKrishnan gravatar imageRahulKrishnan ( 2017-12-20 05:55:01 +0200 )edit

Thank you very much @dan_fulea. It seemed to work for higher prime numbers as well - it just took some time. Btw, is there a routine that exists that gives a scalar multiple of a solution (<x,y>?

RahulKrishnan gravatar imageRahulKrishnan ( 2018-01-06 04:05:14 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-12-20 20:05:46 +0200

dan_fulea gravatar image

The following code provides three solutions in such a simple case with a small value for the prime $p$.

p = 11
F = GF(p)
D = F(2)

# 1.st solution: brute force:
SOL = [ (x,y) for x in F for y in F if x^2 - D*y^2 == 1 ]
print "(1) Brute force solutions:\n", SOL

# 2.nd solution: Algebraic curve and its F-rational points
R.<x,y> = PolynomialRing( F )
C = Curve( x^2 - D*y^2 -1 )
print "(2) Let C be the folowing algebraic curve:\n", C
print "Its rational points are as follows:"
print C.rational_points()

# 3.rd solution: Group of elements of norm one in the field F( sqrt(D) )
S.<W> = PolynomialRing( F )
K.<a> = GF( p**2, modulus = W^2-D )
U = [ x for x in K if x.norm() == 1 ]

print "(3) Let K be the folowing field:\n", K
print "Its points of norm one are as follows:"
print U

Depending on the further use, the one or the other solution is better suited. The above code delivers:

(1) Brute force solutions:
[(0, 4), (0, 7), (1, 0), (3, 2), (3, 9), (5, 1), (5, 10), (6, 1), (6, 10), (8, 2), (8, 9), (10, 0)]

(2) Let C be the folowing algebraic curve:
Affine Plane Curve over Finite Field of size 11 defined by x^2 - 2*y^2 - 1
Its rational points are as follows:
[(0, 4), (0, 7), (1, 0), (3, 2), (3, 9), (5, 1), (5, 10), (6, 1), (6, 10), (8, 2), (8, 9), (10, 0)]

(3) Let K be the folowing field:
Finite Field in a of size 11^2
Its points of norm one are as follows:
[9*a + 3, 10*a + 6, 7*a, 10*a + 5, 9*a + 8, 10, 2*a + 8, a + 5, 4*a, a + 6, 2*a + 3, 1]

(Output was slightly touched.) The last case offers also the multiplication.

Note: To get the components of an element in U, one can lift it to S, then take the coefficients, for instance:

sage: u = 3+2*a
sage: u in U
True
sage: S(u)
2*W + 3
sage: S(u).coefficients( sparse=False )
[3, 2]
sage: S(7*a).coefficients( sparse=False )
[0, 7]
sage: S(7*a).coefficients()
[7]
sage: S(1).coefficients( sparse=False )
[1]

Note that for $\pm1$ there is only one coefficient...

Observation: Working in $K$, we can find a multiplicative generator for the (abstract group $U$ of) $F$-rational point of the algebraic group, for instance:

sage: for u in U:
....:     if u.multiplicative_order() == len(U):
....:         print u

9*a + 3
9*a + 8
2*a + 8
2*a + 3
sage: len(U)
12
sage: euler_phi(len(U))
4
sage: set( [ (3+2*a)^k for k in range(12) ] ) == set(U)
True

So $3+2a=3+2\sqrt[F]D$ generates $U$.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-12-17 17:21:54 +0200

Seen: 1,277 times

Last updated: Dec 20 '17