source: git/Singular/LIB/poly.lib @ 917fb5

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