\\initialize mu and tau {InitTau(c) = a2 = c; mu = (-1)^(1-a2); tau = mu*1/2 + sqrt(-7)/2; } \\returns the complex number whose tau-adic representation is V {EvalTau(V)= subst(Pol(V),x,tau) } \\Addition in Z[tau] v1 = [a,b] = a + b*tau, v2 = [c,d] = c + d*tau, {AddTau(v1, v2)= local(a, b, c, d); a = v1[1]; b = v1[2]; c = v2[1]; d = v2[2]; return([a+c,b+d]); } \\multiplication in Z[tau] v1 = [a,b] = a + b*tau, v2 = [c,d] = c + d*tau, {MulTau(v1, v2) = local(a, b, c, d); a = v1[1]; b = v1[2]; c = v2[1]; d = v2[2]; return([a*c-2*b*d, a*d+c*b+mu*b*d]); } \\return the tau-adic representation of v = [a, b] = a + b*tau {TauAdic(v) = local(nb, devt); devt = []; tmp = v; nb = 0; while( tmp != [0, 0], nb++; r = tmp[1]%2; \\print(r," ",tmp); devt = concat(r, devt); tmp = [tmp[2]%2,0] + MulTau([tmp[1]\2,tmp[2]\2],[mu,-1]); ); return(devt); } \\return the tau-adic NAF representation of v = [a, b] = a + b*tau {TauAdicNAF(v)= local(a, b, t, u, devt); a = v[1]; b = v[2]; devt = []; while( (abs(a) + abs(b)) != 0, if( a%2, u = 2 - (a - 2*b)%4; a = a - u, u = 0); devt = concat([u], devt); t = a; a = b + mu*a/2; b = -t/2; ); return(devt) }