David Loeffler on Wed, 03 Dec 2008 13:06:52 +0100

 nfsnf problems

```Dear PARI/GP people,

I'm having some trouble with the "nfsnf" function.

Firstly, in quite a lot of cases -- particularly where the matrix is
close to being in Smith form already -- I get the error message "bug2 in
nfsmith". This happens in both 2.3.3 and 2.4.2alpha. Secondly, when I do
get an answer I'm not convinced it's the right one.

Here's an example:

E = nfinit(x^2 - x + 2);
M = [1, 0, x; 0, x, 0; 0,0,2+x];
MM = nfalgtobasis(E, M);
N = [[1, 0; 0, 1], [1, 0; 0, 1], [1, 0; 0, 1]];
nfsnf(E, [MM, N, N])

If I've understood everything correctly, that should calculate the SNF
of the matrix [1,0,w; 0,w,0; 0,0,2+w] where w^2 - w + 2 = 0. But it returns

[[8, 3; 0, 1], [1, 0; 0, 1], [1, 0; 0, 1]]

Converting these back to polmods, that's saying that the matrix has
elementary factors 1, 1, and the ideal generated by 8 and w + 2 (since
E.zk[1] = 1, E.zk[2] = x-1.) But it's clear just by looking at the
matrix that its elementary factors are 1, w and 2 + w.

If I change the [1,3] entry of M to 0 instead of x, it gives me the bug2
in nfsmith error message.

Any suggestions what's going on here?

Yours,

David Loeffler

```