Bill Allombert on Wed, 22 Apr 2009 11:42:43 +0200


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

Re: problem turning simple pari code into script


On Tue, Apr 21, 2009 at 11:42:46PM -0400, Rob Denomme wrote:
> Hi all,
> I have a list of commands that I can evaluate one at a time in the GP
> calculator, but I cannot get them to work in a script. In the following I
> have pointed out exactly what fails, but provided some more code that I am
> unsure will work once this problem is fixed. The script that doesn't
> function is given below...

Hello Rob,

The problem you have is due to an incorrect use of braces: your script
should work if you remove the braces.

Normally, GP command are separated by newlines. To write a multiline 
command, we enclose it in braces: inside braces, newlines are ignored.
However, functions are terminated by newline, so a function written inside
braces will not end until the end of the braces. So here, the function f
scope includes 'Norman = Mod(1,q^2);' and everything afterward.

Cheers,
Bill.

> /*
>  * Example of what doesn't work (not important exactly what it does, but if
> interested...)
>  * computes Norm(1-x^q) from the cyclotomic field Q(x), (x^p=1)
>  * to the field fixed by the Sylow-q subgroup of the Galois group
>  */
> {
> p=127;
> q=3;      /* p, q primes */
> n=valuation(p-1,q);
> h= znprimroot(p)^((p-1)/(q^n));
> 
> T=polcyclo(p);
> /* note T=polcyclo(p) works just fine, T is now a polynomial in x */
> 
> f(x) = (1-x^q) % T;
> /* this is the line that screws up in a script,
>  * but works when input to the gp calculator
>  */
> 
> Norman = Mod(1,q^2);
>  for(i=1,q^n,Norman*=Mod(f(x^( lift(h^i) )),T) );
> /* Once the above error is fixed will the above line work like I expect?
>  * i.e. will this think of Norman being in Z[x]/(q^2,T)
>  */
> 
> /* lift(lift(Norman)) will now print the norm of (1-x^q)
>  * where x is a primitive p-th root of unity
>  */
> }