Having trouble with RadiRoot in GAP

98 Views Asked by At

I'm having trouble with GAP - Groups, Algorithms, Programming.

I'm trying to use RadiRoot 2.7 to express the roots of a polynomial as matrices.

It works for quadratics, but fails for anything of higher degree - even the example in the manual!

I've got GAP 4.8.8, and am running it through a terminal window on Ubuntu 17.04

Here's an example of the program working for a quadratic:

gap> x := Indeterminate(Rationals,"x");;
gap> f := UnivariatePolynomial(Rationals,[1,0,1]);
x^2 + 1
gap> Display(RootsAsMatrices(f)[1]);
[[0,1],[-1,0]]

I can't seem to get it to work for anything of a higher degree, not even the example in the manual.

gap> x := Indeterminate(Rationals,"x");;
gap> f := UnivariatePolynomial(Rationals,[1,3,4,1]);
x^3+4*x^2+3*x+1
gap> Display(RootsAsMatrices(f)[1]);

Here I just get an error message saying that there are too many arguments:

enter image description here

2

There are 2 best solutions below

0
On BEST ANSWER

The Nice people at GAP Support helped me fix the problem.

I needed to replace the file gap4r8/pkg/Alnuth-3.0.0/gp/polyfactors.gp with

\\ compute factors of poly defined by coeffs over Q_f
f = subst(f,variable(f),'varA);
pol = Pol(vector(#coeffs-1,i,Polrev(coeffs[i],'varA)));
n = poldegree(f);
gettime();
fac = lift(nffactor(f, pol ));
zeit = gettime();

p2v(n,b)=vector(n,j,polcoeff(b,j-1));
f2v(n,v)=vector(#v,i,p2v(n,v[i]));

\\ print result
print("[ ");
{
  for(i=1,#fac[,1],
    for(j=1,fac[i,2],
        print(f2v(n, Vec(fac[i,1]) ),",");
    )
  );
}
print1(zeit);
print("];");

It seems I was experiencing problems between PARI/GP and GAP.

However, as Dima's post points out: I did not run LoadPackage("radiroot"); inside GAP. It's too late for me to try this because I've over-written polyfactors.gp

1
On

It works for me on a GAP 4.8.8 built from source on a x86_64 Linux. (Edit: with Pari/GP version 2.7.1 --- it does not work with 2.9.3)

 ┌───────┐   GAP 4.8.8, 20-Aug-2017, build of 2017-10-15 11:23:26 (BST)
 │  GAP  │   https://www.gap-system.org
 └───────┘   Architecture: x86_64-pc-linux-gnu-gcc-default64
 Libs used:  gmp, readline
 Loading the library and packages ...
 Components: trans 1.0, prim 2.1, small* 1.0, id* 1.0
 Packages:   AClib 1.2, Alnuth 3.0.0, AtlasRep 1.5.1, AutPGrp 1.8,
             CRISP 1.4.4, Cryst 4.1.12, CrystCat 1.1.6, CTblLib 1.2.2,
             FactInt 1.5.4, FGA 1.3.1, GAPDoc 1.6, IRREDSOL 1.4,
             LAGUNA 3.7.0, Polenta 1.3.7, Polycyclic 2.11, RadiRoot 2.7,
             ResClasses 4.6.0, Sophus 1.23, SpinSym 1.5, TomLib 1.2.6,
             Utils 0.46
 Try '??help' for help. See also '?copyright', '?cite' and '?authors'
gap> LoadPackage("radiroot");
true
gap> x := Indeterminate(Rationals,"x");;
gap> f := UnivariatePolynomial(Rationals,[1,3,4,1]);
x^3+4*x^2+3*x+1
gap> Display(RootsAsMatrices(f)[1]);
[ [   0,   1,   0,   0,   0,   0 ],
  [   0,   0,   1,   0,   0,   0 ],
  [  -1,  -3,  -4,   0,   0,   0 ],
  [   0,   0,   0,   0,   1,   0 ],
  [   0,   0,   0,   0,   0,   1 ],
  [   0,   0,   0,  -1,  -3,  -4 ] ]
gap>

How did you install GAP?