[GAP Forum] Retrieving coefficients of linear equations

Frank Lübeck Frank.Luebeck at math.rwth-aachen.de
Thu Jan 18 08:37:42 GMT 2007


Dear Dursun, dear Forum,

On Tue, Jan 16, 2007 at 07:32:42PM -0500, Bulutoglu Dursun A Civ AFIT/ENC wrote:
> I was wondering how I can extract the coefficients of a multivariate
> polynomial (in my case it is a linear polynomial) and put them in a
> list.

GAP has an operation 'ExtRepPolynomialRatFun' and a function
'PolynomialByExtRep' which you can use. You find the details in the
GAP online help:

gap> ?The Defining Attributes of Rational Functions
gap> ?ExtRepPolynomialRatFun
gap> ?PolynomialByExtRep

> m:=10;
> N:=20;
> aa:=PolynomialRing(Rationals,[1..20]);
>  mm:=IndeterminatesOfPolynomialRing(aa);
> ccf:=(2*([1..10]-5)-1);
> 
> mm8:=List(ccf, x->x^8)*mm{[1..10]};
> mm6:=List(ccf, x->x^6)*mm{[1..10]};
> mm4:=List(ccf, x->x^4)*mm{[1..10]};
> 
> A4:=(mm4-N^2*(m-1)*(3*(m-1)-2))/(24);
> 
> A6:=(mm6-N^2*(15*(m-1)*(m-2)^2+(m-1))-(360*(m-1)-960)*A4)/720;
> 
> A8:=(mm8-(20160*(m-1)-80640)*A6-(5040*(m-1)^2-30240*(m-1)+48384)*A4
> -N^2*(105*(m-1)^4-420*(m-1)^3+588*(m-1)^2-272*(m-1)))/40320;

In this example you can use:

gap> A8;
121743/896*x_1+26411/384*x_2+114125/2688*x_3+7983/896*x_4+365/2688*x_5+365/268\
8*x_6+7983/896*x_7+114125/2688*x_8+26411/384*x_9+121743/896*x_10-266775/56
gap> cA8 := ExtRepPolynomialRatFun(A8);
[ [  ], -266775/56, [ 10, 1 ], 121743/896, [ 9, 1 ], 26411/384, [ 8, 1 ], 
  114125/2688, [ 7, 1 ], 7983/896, [ 6, 1 ], 365/2688, [ 5, 1 ], 365/2688, 
  [ 4, 1 ], 7983/896, [ 3, 1 ], 114125/2688, [ 2, 1 ], 26411/384, [ 1, 1 ], 
  121743/896 ]
gap> fam := RationalFunctionsFamily(FamilyObj(1));;
gap> check := PolynomialByExtRep(fam, cA8);
121743/896*x_1+26411/384*x_2+114125/2688*x_3+7983/896*x_4+365/2688*x_5+365/268\
8*x_6+7983/896*x_7+114125/2688*x_8+26411/384*x_9+121743/896*x_10-266775/56
gap> check = A8;
true


With best regards,

   Frank

-- 
///  Dr. Frank Lübeck, Lehrstuhl D für Mathematik, Templergraben 64,  ///
\\\                    52062 Aachen, Germany                          \\\
///  E-mail: Frank.Luebeck at Math.RWTH-Aachen.De                        ///
\\\  WWW:    http://www.math.rwth-aachen.de/~Frank.Luebeck/           \\\





More information about the Forum mailing list