source: git/Singular/LIB/poly.lib @ de9f10

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