source: git/Singular/LIB/poly.lib @ 1caa72

spielwiese
Last change on this file since 1caa72 was 1caa72, checked in by Olaf Bachmann <obachman@…>, 25 years ago
1998-04-06 Olaf Bachmann <obachman@mathematik.uni-kl.de> * spSpolyLoop.h: neww calling interface for spGetSpolyLoop * kstd1.cc (kNF): moved strat->ak field initailization out of initBuchMora into single routines * febase.cc (feGetSearchPath): added feGetSearchPath; changed algorithm for searching files: $SINGULARPATH -> relative to executable -> burnt-in locations * added find_exec.c to get absolute pathname of executable git-svn-id: file:///usr/local/Singular/svn/trunk@1341 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 20.2 KB
Line 
1// $Id: poly.lib,v 1.11 1998-04-06 17:59:38 obachman Exp $
2//system("random",787422842);
3//(GMG, last modified 22.06.96)
4//(obachman: 17.12.97 -- added katsura)
5///////////////////////////////////////////////////////////////////////////////
6
7version="$Id: poly.lib,v 1.11 1998-04-06 17:59:38 obachman Exp $";
8info="
9LIBRARY:  poly.lib      PROCEDURES FOR MANIPULATING POLYS, IDEALS, MODULES
10
11 cyclic(int);           ideal of cyclic n-roots
12 katsura([i]);          katsura [i] ideal
13 freerank(poly/...)     rank of coker(input) if coker is free else -1
14 is_homog(poly/...);    int, =1 resp. =0 if input is homogeneous resp. not
15 is_zero(poly/...);     int, =1 resp. =0 if coker(input) is 0 resp. not
16 lcm(ideal);            lcm of given generators of ideal
17 maxcoef(poly/...);     maximal length of coefficient occuring in poly/...
18 maxdeg(poly/...);      int/intmat = degree/s of terms of maximal order
19 maxdeg1(poly/...);     int = [weighted] maximal degree of input
20 mindeg(poly/...);      int/intmat = degree/s of terms of minimal order
21 mindeg1(poly/...);     int = [weighted] minimal degree of input
22 normalize(poly/...);   normalize poly/... such that leading coefficient is 1
23 rad_con(p,I);          check radical containment of poly p in ideal I
24 content(f);            content of polynomial/vector f
25          (parameters in square brackets [] are optional)
26";
27
28LIB "general.lib";
29///////////////////////////////////////////////////////////////////////////////
30
31proc cyclic (int n)
32USAGE:   cyclic(n);  n integer
33RETURN:  ideal of cyclic n-roots from 1-st n variables of basering
34EXAMPLE: example cyclic; shows examples
35{
36//----------------------------- procedure body --------------------------------
37   ideal m = maxideal(1);
38   m = m[1..n],m[1..n];
39   int i,j;
40   ideal s; poly t;
41   for ( j=0; j<=n-2; j=j+1 )
42   {
43      t=0;
44      for( i=1;i<=n;i=i+1 ) { t=t+product(m,i..i+j); }
45      s=s+t;
46   }
47   s=s,product(m,1..n)-1;
48   return (s);
49}
50//-------------------------------- examples -----------------------------------
51example
52{ "EXAMPLE:"; echo = 2;
53   ring r=0,(u,v,w,x,y,z),lp;
54   cyclic(nvars(basering));
55   homog(cyclic(5),z);
56}
57///////////////////////////////////////////////////////////////////////////////
58
59proc katsura
60USAGE:  katsura([n]); n integer
61RETURN: katsura(n) : n-th katsura ideal of newly created and set ring
62                     (32003, x(0..n), dp)
63        katsura()  : katsura ideal of basering
64EXAMPLE: example katsura; shows examples
65{
66  if ( size(#) == 1 && typeof(#[1]) == "int")
67  {
68    ring katsura_ring = 32003, x(0..#[1]), dp;
69    keepring katsura_ring;
70  }
71  ideal s;
72  int i, j;
73  int n = nvars(basering) -1;
74  poly p;
75 
76  p = -1;
77  for (i = -n; i <= n; i++)
78  {
79    p = p + kat_var(i, n);
80  }
81  s[1] = p;
82 
83  for (i = 0; i < n; i++)
84  {
85    p = -1 * kat_var(i,n);
86    for (j = -n; j <= n; j++)
87    {
88      p = p + kat_var(j,n) * kat_var(i-j, n);
89    }
90    s = s,p;
91  }
92  return (s);
93}
94//-------------------------------- examples -----------------------------------
95example
96{
97  "EXAMPLE:"; echo = 2;
98  ring r;
99  katsura();
100  katsura(3);
101}
102
103proc kat_var(int i, int n)
104{
105  poly p;
106  if (i < 0)  { i = -i;}
107  if (i <= n) { p = var(i+1); }
108  return (p);
109}
110///////////////////////////////////////////////////////////////////////////////
111
112proc freerank
113USAGE:   freerank(M[,any]);  M=poly/ideal/vector/module/matrix
114COMPUTE: rank of module presented by M in case it is free. By definition this
115         is vdim(coker(M)/m*coker(M)) if coker(M) is free, where m = maximal
116         ideal of basering and M is considered as matrix (the 0-module is
117         free of rank 0)
118RETURN:  rank of coker(M) if coker(M) is free and -1 else;
119         in case of a second argument return a list:
120                L[1] = rank of coker(M) or -1
121                L[2] = minbase(M)
122NOTE:    freerank(syz(M)); computes the rank of M if M is free (and -1 else)
123         //* Zur Zeit noch ein Bug, da erste Bettizahl falsch berechnet wird:
124         //betti(0) ist -1 statt 0
125EXAMPLE: example freerank; shows examples
126{
127  int rk;
128  def M = simplify(#[1],10);
129  list mre = mres(M,2);
130  intmat B = betti(mre);
131  if ( ncols(B)>1 ) { rk = -1; }
132  else { rk = sum(B[1..nrows(B),1]); }
133  if (size(#) == 2) { list L=rk,mre[1]; return(L);}
134  return(rk);
135}
136example
137{"EXAMPLE";   echo=2;
138  ring r;
139  ideal i=x;
140  module M=[x,0,1],[-x,0,-1];
141  freerank(M);           // should be -1, coker(M) is not free
142                         // [1] should be 1, coker(syz(M))=M is free of rank 1
143  freerank(syz (M),"");  // [2] should be gen(2)+gen(1) (minimal relation of M)
144  freerank(i);
145  freerank(syz(i));      //* bug, should be 1, coker(syz(i))=i is free of rank 1
146}
147///////////////////////////////////////////////////////////////////////////////
148
149proc is_homog (id)
150USAGE:   is_homog(id);  id  poly/ideal/vector/module/matrix
151RETURN:  integer which is 1 if input is homogeneous (resp. weighted homogeneous
152         if the monomial ordering consists of one block of type ws,Ws,wp or Wp,
153         assuming that all weights are positive) and 0 otherwise
154NOTE:    A vector is homogeneous, if the components are homogeneous of same
155         degree, a module/matrix is homogeneous if all column vectors are
156         homogeneous
157         //*** ergaenzen, wenn Matrizen-Spalten Gewichte haben
158EXAMPLE: example is_homog; shows examples
159{
160//----------------------------- procedure body --------------------------------
161   module M = module(matrix(id));
162   M = simplify(M,2);                        // remove 0-columns
163   intvec v = ringweights(basering);
164   int i,j=1,1;
165   for (i=1; i<=ncols(M); i=i+1)
166   {
167      if( M[i]!=jet(M[i],deg(lead(M[i])),v)-jet(M[i],deg(lead(M[i]))-1,v))
168      { return(0); }
169   }
170   return(1);
171}
172//-------------------------------- examples -----------------------------------
173example
174{ "EXAMPLE:"; echo = 2;
175   ring r = 0,(x,y,z),wp(1,2,3);
176   is_homog(x5-yz+y3);
177   ideal i = x6+y3+z2, x9-z3;
178   is_homog(i);
179   ring s = 0,(a,b,c),ds;
180   vector v = [a2,0,ac+bc];
181   vector w = [a3,b3,c4];
182   is_homog(v);
183   is_homog(w);
184}
185///////////////////////////////////////////////////////////////////////////////
186
187proc is_zero
188USAGE:   is_zero(M[,any]); M=poly/ideal/vector/module/matrix
189RETURN:  integer, 1 if coker(M)=0 resp. 0 if coker(M)!=0, where M is considered
190         as matrix
191         if a second argument is given, return a list:
192                L[1] = 1 if coker(M)=0 resp. 0 if coker(M)!=0
193                L[2] = dim(M)
194EXAMPLE: example is_zero; shows examples
195{
196  int d=dim(std(#[1]));
197  int a = ( d==-1 );
198  if( size(#) >1 ) { list L=a,d; return(L); }
199  return(a);
200}
201example
202{ "EXAMPLE:";   echo=2;
203  ring r;
204  module m = [x],[y],[1,z];
205  is_zero(m,1);
206  qring q = std(ideal(x2+y3+z2));
207  ideal j = x2+y3+z2-37;
208  is_zero(j);
209}
210////////////////////////////////////////////////////////////////////////////////
211
212proc maxcoef (f)
213USAGE:   maxcoef(f);  f  poly/ideal/vector/module/matrix
214RETURN:  maximal length of coefficient of f of type int (by counting the
215         length of the string of each coefficient)
216EXAMPLE: example maxcoef; shows examples
217{
218//----------------------------- procedure body --------------------------------
219   int max,s,ii,jj; string t;
220   ideal i = ideal(matrix(f));
221   i = simplify(i,6);            // delete 0's and keep first of equal elements
222   poly m = var(1); matrix C;
223   for (ii=2;ii<=nvars(basering);ii=ii+1) { m = m*var(ii); }
224   for (ii=1; ii<=size(i); ii=ii+1)
225   {
226      C = coef(i[ii],m);
227      for (jj=1; jj<=ncols(C); jj=jj+1)
228      {
229         t = string(C[2,jj]);  s = size(t);
230         if ( t[1] == "-" ) { s = s - 1; }
231         if ( s > max ) { max = s; }
232      }
233   }
234   return(max);
235}
236//-------------------------------- examples -----------------------------------
237example
238{ "EXAMPLE:"; echo = 2;
239   ring r= 0,(x,y,z),ds;
240   poly g = 345x2-1234567890y+7/4z;
241   maxcoef(g);
242   ideal i = g,10/1234567890;
243   maxcoef(i);
244   // since i[2]=1/123456789
245}
246///////////////////////////////////////////////////////////////////////////////
247
248proc maxdeg (id)
249USAGE:   maxdeg(id);  id  poly/ideal/vector/module/matrix
250RETURN:  int/intmat, each component equals maximal degree of monomials in the
251         corresponding component of id, independent of ring ordering
252         (maxdeg of each var is 1)
253         of type int if id is of type poly, of type intmat else
254NOTE:    proc maxdeg1 returns 1 integer, the absolut maximum; moreover, it has
255         an option for computing weighted degrees
256EXAMPLE: example maxdeg; shows examples
257{
258   //-------- subprocedure to find maximal degree of given component ----------
259   proc findmaxdeg
260   {
261      poly c = #[1];
262      if (c==0) { return(-1); }
263   //--- guess upper 'o' and lower 'u' bound, in case of negative weights -----
264      int d = (deg(c)>=0)*deg(c)-(deg(c)<0)*deg(c);
265      int i = d;
266      while ( c-jet(c,i) != 0 ) { i = 2*(i+1); }
267      int o = i-1;
268      int u = (d != i)*((i div  2)-1);
269   //----------------------- "quick search" for maxdeg ------------------------
270      while ( (c-jet(c,i)==0)*(c-jet(c,i-1)!=0) == 0)
271      {
272         i = (o+1+u) div  2;
273         if (c-jet(c,i)!=0) { u = i+1; }
274         else { o = i-1; }
275      }
276      return(i);
277   }
278//------------------------------ main program ---------------------------------
279   matrix M = matrix(id);
280   int r,c = nrows(M), ncols(M); int i,j;
281   intmat m[r][c];
282   for (i=r; i>0; i=i-1)
283   {
284      for (j=c; j>0; j=j-1) { m[i,j] = findmaxdeg(M[i,j]); }
285   }
286   if (typeof(id)=="poly") { return(m[1,1]); }
287   return(m);
288}
289//-------------------------------- examples -----------------------------------
290example
291{ "EXAMPLE:"; echo = 2;
292   ring r = 0,(x,y,z),wp(-1,-2,-3);
293   poly f = x+y2+z3;
294   deg(f);               //deg; returns weighted degree (in case of 1 block)!
295   maxdeg(f);
296   matrix m[2][2]=f+x10,1,0,f^2;
297   maxdeg(m);
298}
299///////////////////////////////////////////////////////////////////////////////
300
301proc maxdeg1 (id,list #)
302USAGE:   maxdeg1(id[,v]);  id=poly/ideal/vector/module/matrix, v=intvec
303RETURN:  integer, maximal [weighted] degree of monomials of id independent of
304         ring ordering, maxdeg1 of i-th variable is v[i] (default: v=1..1).
305NOTE:    This proc returns one integer while maxdeg returns, in general,
306         a matrix of integers. For one polynomial and if no intvec v is given
307         maxdeg is faster
308EXAMPLE: example maxdeg1; shows examples
309{
310   //-------- subprocedure to find maximal degree of given component ----------
311   proc findmaxdeg
312   {
313      poly c = #[1];
314      if (c==0) { return(-1); }
315      intvec v = #[2];
316   //--- guess upper 'o' and lower 'u' bound, in case of negative weights -----
317      int d = (deg(c)>=0)*deg(c)-(deg(c)<0)*deg(c);
318      int i = d;
319      if ( c == jet(c,-1,v))      //case: maxdeg is negative
320      {
321         i = -d;
322         while ( c == jet(c,i,v) ) { i = 2*(i-1); }
323         int o = (d != -i)*((i div  2)+2) - 1;
324         int u = i+1;
325         int e = -1;
326      }
327      else                        //case: maxdeg is nonnegative
328      {
329         while ( c != jet(c,i,v) ) { i = 2*(i+1); }
330         int o = i-1;
331         int u = (d != i)*((i div  2)-1);
332         int e = 1;
333      }
334   //----------------------- "quick search" for maxdeg ------------------------
335      while ( ( c==jet(c,i,v) )*( c!=jet(c,i-1,v) ) == 0 )
336      {
337         i = (o+e+u) div  2;
338         if ( c!=jet(c,i,v) ) { u = i+1; }
339         else { o = i-1; }
340      }
341      return(i);
342   }
343//------------------------------ main program ---------------------------------
344   ideal M = simplify(ideal(matrix(id)),8);   //delete scalar multiples from id
345   int c = ncols(M);
346   int i,n;
347   if( size(#)==0 )
348   {
349      int m = maxdeg(M[c]);
350      for (i=c-1; i>0; i=i-1)
351      {
352          n = maxdeg(M[i]);
353          m = (m>=n)*m + (m<n)*n;             //let m be the maximum of m and n
354      }
355   }
356   else
357   {
358      intvec v=#[1];                          //weight vector for the variables
359      int m = findmaxdeg(M[c],v);
360      for (i=c-1; i>0; i--)
361      {
362         n = findmaxdeg(M[i],v);
363         if( n>m ) { m=n; }
364      }
365   }
366   return(m);
367}
368//-------------------------------- examples -----------------------------------
369example
370{ "EXAMPLE:"; echo = 2;
371   ring r = 0,(x,y,z),wp(-1,-2,-3);
372   poly f = x+y2+z3;
373   deg(f);                  //deg returns weighted degree (in case of 1 block)!
374   maxdeg1(f);
375   intvec v = ringweights(r);
376   maxdeg1(f,v);                             //weighted maximal degree
377   matrix m[2][2]=f+x10,1,0,f^2;
378   maxdeg1(m,v);                             //absolut weighted maximal degree
379}
380///////////////////////////////////////////////////////////////////////////////
381
382proc mindeg (id)
383USAGE:   mindeg(id);  id  poly/ideal/vector/module/matrix
384RETURN:  minimal degree/s of monomials of id, independent of ring ordering
385         (mindeg of each variable is 1) of type int if id of type poly, else
386         of type intmat.
387NOTE:    proc mindeg1 returns one integer, the absolut minimum; moreover it
388         has an option for computing weighted degrees.
389EXAMPLE: example mindeg; shows examples
390{
391   //--------- subprocedure to find minimal degree of given component ---------
392   proc findmindeg
393   {
394      poly c = #[1];
395      if (c==0) { return(-1); }
396   //--- guess upper 'o' and lower 'u' bound, in case of negative weights -----
397      int d = (ord(c)>=0)*ord(c)-(ord(c)<0)*ord(c);
398      int i = d;
399      while ( jet(c,i) == 0 ) { i = 2*(i+1); }
400      int o = i-1;
401      int u = (d != i)*((i div  2)-1);
402   //----------------------- "quick search" for mindeg ------------------------
403      while ( (jet(c,u)==0)*(jet(c,o)!=0) )
404      {
405         i = (o+u) div  2;
406         if (jet(c,i)==0) { u = i+1; }
407         else { o = i-1; }
408      }
409      if (jet(c,u)!=0) { return(u); }
410      else { return(o+1); }
411   }
412//------------------------------ main program ---------------------------------
413   matrix M = matrix(id);
414   int r,c = nrows(M), ncols(M); int i,j;
415   intmat m[r][c];
416   for (i=r; i>0; i=i-1)
417   {
418      for (j=c; j>0; j=j-1) { m[i,j] = findmindeg(M[i,j]); }
419   }
420   if (typeof(id)=="poly") { return(m[1,1]); }
421   return(m);
422}
423//-------------------------------- examples -----------------------------------
424example
425{ "EXAMPLE:"; echo = 2;
426   ring r = 0,(x,y,z),ls;
427   poly f = x5+y2+z3;
428   ord(f);                      // ord returns weighted order of leading term!
429   mindeg(f);                   // computes minimal degree
430   matrix m[2][2]=x10,1,0,f^2;
431   mindeg(m);                   // computes matrix of minimum degrees
432}
433///////////////////////////////////////////////////////////////////////////////
434
435proc mindeg1 (id, list #)
436USAGE:   mindeg1(id[,v]);  id=poly/ideal/vector/module/matrix, v=intvec
437RETURN:  integer, minimal [weighted] degree of monomials of id independent of
438         ring ordering, mindeg1 of i-th variable is v[i] (default v=1..1).
439NOTE:    This proc returns one integer while mindeg returns, in general,
440         a matrix of integers. For one polynomial and if no intvec v is given
441         mindeg is faster.
442EXAMPLE: example mindeg1; shows examples
443{
444   //--------- subprocedure to find minimal degree of given component ---------
445   proc findmindeg
446   {
447      poly c = #[1];
448      intvec v = #[2];
449      if (c==0) { return(-1); }
450   //--- guess upper 'o' and lower 'u' bound, in case of negative weights -----
451      int d = (ord(c)>=0)*ord(c)-(ord(c)<0)*ord(c);
452      int i = d;
453      if ( jet(c,-1,v) !=0 )      //case: mindeg is negative
454      {
455         i = -d;
456         while ( jet(c,i,v) != 0 ) { i = 2*(i-1); }
457         int o = (d != -i)*((i div  2)+2) - 1;
458         int u = i+1;
459         int e = -1; i=u;
460      }
461      else                        //case: inded is nonnegative
462      {
463         while ( jet(c,i,v) == 0 ) { i = 2*(i+1); }
464         int o = i-1;
465         int u = (d != i)*((i div  2)-1);
466         int e = 1; i=u;
467      }
468   //----------------------- "quick search" for mindeg ------------------------
469      while ( (jet(c,i-1,v)==0)*(jet(c,i,v)!=0) == 0 )
470      {
471         i = (o+e+u) div  2;
472         if (jet(c,i,v)==0) { u = i+1; }
473         else { o = i-1; }
474      }
475      return(i);
476   }
477//------------------------------ main program ---------------------------------
478   ideal M = simplify(ideal(matrix(id)),8);   //delete scalar multiples from id
479   int c = ncols(M);
480   int i,n;
481   if( size(#)==0 )
482   {
483      int m = mindeg(M[c]);
484      for (i=c-1; i>0; i=i-1)
485      {
486          n = mindeg(M[i]);
487          m = (m<=n)*m + (m>n)*n;             //let m be the maximum of m and n
488      }
489   }
490   else
491   {
492      intvec v=#[1];                          //weight vector for the variables
493      int m = findmindeg(M[c],v);
494      for (i=c-1; i>0; i=i-1)
495      {
496         n = findmindeg(M[i],v);
497         m = (m<=n)*m + (m>n)*n;              //let m be the maximum of m and n
498      }
499   }
500   return(m);
501}
502//-------------------------------- examples -----------------------------------
503example
504{ "EXAMPLE:"; echo = 2;
505   ring r = 0,(x,y,z),ls;
506   poly f = x5+y2+z3;
507   ord(f);                      // ord returns weighted order of leading term!
508   intvec v = 1,-3,2;
509   mindeg1(f,v);                // computes minimal weighted degree
510   matrix m[2][2]=x10,1,0,f^2;
511   mindeg1(m,1..3);             // computes absolut minimum of weighted degrees
512}
513///////////////////////////////////////////////////////////////////////////////
514
515proc normalize (id)
516USAGE:   normalize(id);  id=poly/vector/ideal/module
517RETURN:  object of same type with leading coefficient equal to 1
518EXAMPLE: example normalize; shows an example
519{
520   return(simplify(id,1));
521}
522//-------------------------------- examples -----------------------------------
523example
524{  "EXAMPLE:"; echo = 2;
525   ring r = 0,(x,y,z),ls;
526   poly f = 2x5+3y2+4z3;
527   normalize(f);
528   module m=[9xy,0,3z3],[4z,6y,2x];
529   normalize(m);
530   ring s = 0,(x,y,z),(c,ls);
531   module m=[9xy,0,3z3],[4z,6y,2x];
532   normalize(m);
533   normalize(matrix(m));             // by automatic type conversion to module!
534}
535///////////////////////////////////////////////////////////////////////////////
536
537////////////////////////////////////////////////////////////////////////////////
538// Input: <ideal>=<f1,f2,...,fm> and <polynomial> g
539// Question: Does g lie in the radical of <ideal>?
540// Solution: Compute a standard basis G for <f1,f2,...,fm,gz-1> where z is a new
541//           variable. Then g is contained in the radical of <ideal> <=> 1 is
542//           generator in G.
543////////////////////////////////////////////////////////////////////////////////
544proc rad_con (poly g,ideal I)
545  USAGE:   rad_con(<poly>,<ideal>);
546  RETURNS: 1 (TRUE) (type <int>) if <poly> is contained in the radical of
547           <ideal>, 0 (FALSE) (type <int>) otherwise
548  EXAMPLE: example rad_con; shows an example
549{ def br=basering;
550  int n=nvars(br);
551  int dB=degBound;
552  degBound=0;
553  string mp=string(minpoly);
554  execute "ring R=("+charstr(br)+"),(x(1..n),z),dp;";
555  execute "minpoly=number("+mp+");";
556  ideal irrel=x(1..n);
557  map f=br,irrel;
558  poly p=f(g);
559  ideal J=f(I)+ideal(p*z-1);
560  J=std(J);
561  degBound=dB;
562  if (J[1]==1)
563  { return(1);
564  }
565  else
566  { return(0);
567  }
568}
569example
570{ "  EXAMPLE: Sturmfels: Algorithms in Invariant Theory 2.3.7.";
571  echo=2;
572           ring R=0,(x,y,z),dp;
573           ideal I=x2+y2,z2;
574           poly f=x4+y4;
575           rad_con(f,I);
576           ideal J=x2+y2,z2,x4+y4;
577           poly g=z;
578           rad_con(g,I);
579}
580
581///////////////////////////////////////////////////////////////////////////////
582
583proc lcm (ideal i)
584USAGE:   lcm(i); i ideal
585RETURN:  poly = lcm(i[1],...,i[size(i)])
586NOTE:   
587EXAMPLE: example lcm; shows an example
588{
589  int k,j;
590   poly p,q;
591  i=simplify(i,10);
592  for(j=1;j<=size(i);j++)
593  {
594    if(deg(i[j])>0)
595    {
596      p=i[j];
597      break;
598    }
599  }
600  if(deg(p)==-1)
601  {
602    return(1);
603  }
604  for (k=j+1;k<=size(i);k++)
605  {
606     if(deg(i[k])!=0)
607     {
608        q=gcd(p,i[k]);
609        if(deg(q)==0)
610        {
611           p=p*i[k];
612        }
613        else
614        {
615           p=p/q;
616           p=p*i[k];
617        }
618     }
619   }
620  return(p);
621}
622example
623{ "EXAMPLE:"; echo = 2;
624   ring  r = 0,(x,y,z),lp;
625   poly  p = (x+y)*(y+z);
626   poly  q = (z4+2)*(y+z);
627   ideal l=p,q;
628   poly  pr= lcm(l);
629   pr;
630   l=1,-1,p,1,-1,q,1;
631   pr=lcm(l);
632   pr;
633}
634
635///////////////////////////////////////////////////////////////////////////////
636
637proc content(f)
638USAGE:   content(f); f polynomial/vector
639RETURN:  number, the content (greatest common factor of coefficients)
640         of the polynomial/vector f
641EXAMPLE: example content; shows an example
642{
643  return(leadcoef(f)/leadcoef(cleardenom(f)));
644
645example
646{ "EXAMPLE:"; echo = 2;
647   ring r=0,(x,y,z),(c,lp);
648   content(3x2+18xy-27xyz);
649   vector v=[3x2+18xy-27xyz,15x2+12y4,3];
650   content(v);
651}
652
Note: See TracBrowser for help on using the repository browser.