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

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