Bill Allombert on Thu, 02 Mar 2017 11:26:46 +0100


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

Re: Mathematica "Reduce" function


On Thu, Mar 02, 2017 at 10:00:48AM +0100, Pedro Fortuny Ayuso wrote:
> Thanks to all.
> 
> My specific problem is trying to solve equations like
> 
> 6x^2 + 12y^2 +20z^2 = 0
> 
> over Z/(2^k)Z. That is, finding the points of that surface
> over that ring.

Solutions of homogenous degree-2 equation in three variables can be
parametrized as soon as one solution is known using qfparam:
For example [0,1,1] is a (primitive) solution mod 2^5 so set

? M=qfparam(matdiagonal([6,12,20]),[0,1,1])
%9 = [0,-20,0;3,0,10;3,0,-10]
? v = y^2 * M*[1,x/y,(x/y)^2]~
%10 = [-20*y*x,10*x^2+3*y^2,-10*x^2+3*y^2]~

so for all x,y, (-20*y*x,10*x^2+3*y^2,-10*x^2+3*y^2) is a solution mod
2^5:

? content(6*(-20*y*x)^2+12*(10*x^2+3*y^2)^2+20*(-10*x^2+3*y^2)^2)
%12 = 32

> Bill's reply of counting
> 
> length([[x,y,z]|x<-[0..2^k-1];y<-[0..2^k-1];z<-[0..2^k-1],6*x^2+12*y^2+20*z^2==0])

You are missing a reduction mod 2^k at the end.

> is the fastest but it ***looks like*** a lot slower than
> Mathematica (but please notice I am working on a system
> with pari/gp and my colleague on a different one with Mathematica,
> so that it may have nothing to do with pari/Mathematica).

This is quite possible, I do not know what Mathematica is doing.
what you can do is to check whether (6*x^2+12*y^2)/-20 is a square
instead of iterating over z:

[[x,y,z]|x<-2*[0..2^(k-1)-1];y<-[0..2^k-1],issquare((6*x^2+12*y^2)/-20*Mod(1,2^k),&z)]

Cheers,
Bill.