Difference between revisions of "CoCoA:HowTo:Plot order ideals"

From ApCoCoAWiki
m (adding reference to quotientbasis, some more background information)
Line 6: Line 6:
  
 
The question was, if there is any software to visualize this order ideals for polynomial rings in two or three indeterminates.  
 
The question was, if there is any software to visualize this order ideals for polynomial rings in two or three indeterminates.  
During the school, first [[User:Bigatti|Anna Bigatti]] and [[User:Dheldt|Daniel Heldt]] developed tools to plot order ideals.
+
During the school, [[User:Bigatti|Anna Bigatti]] and [[User:Dheldt|Daniel Heldt]] developed tools to plot order ideals.
  
 
These tools use [[CoCoA_4|CoCoa 4]] and either [http://povray.com Povray] or Latex.  
 
These tools use [[CoCoA_4|CoCoa 4]] and either [http://povray.com Povray] or Latex.  
Line 13: Line 13:
  
 
The code to plot the order ideals is given in the next sections:
 
The code to plot the order ideals is given in the next sections:
 
  
 
== CoCoA & Latex Code (1. Version) ==
 
== CoCoA & Latex Code (1. Version) ==

Revision as of 08:52, 23 June 2005

About

At the CoCoA Summer School 2005 there was a discussion about the possibility to plot order ideals. An order ideal is simply the complement of an ideal's leading term ideal, otherwise it could be described as a vector space basis of the quotient space P/I consisting of monomials (this is exactly the B in MacCaulys Basis Theorem with respect to the notation of Kreuzer's & Robbiano's book).

The question was, if there is any software to visualize this order ideals for polynomial rings in two or three indeterminates. During the school, Anna Bigatti and Daniel Heldt developed tools to plot order ideals.

These tools use CoCoa 4 and either Povray or Latex. The code uses CoCoA's QuotientBasis command, to get a list of all terms to draw and than draws this terms (or selects which of them should be drawn and which are invisible, in case of the latex pictures).


The code to plot the order ideals is given in the next sections:

CoCoA & Latex Code (1. Version)

Both functions (this and the next one) get as input a zero-dimensional ideal. The output is some text, containing the latex picture enviroment. simply render this to get a picture of your order ideal. You can even change the point of view of the model, by changing V1, V2, V3 and L1, L2, L3. How this exactly works can be figured out quite easily, having a look at a latex documentation for the picture enviroment.

 Define BorderTeX(I)
 String:='\begin{picture}(300,300)';

 // define your coordinate system:
 Offset := Vector(150,150);
 V1 := Vector(-1,-1);
 V2 := Vector(0,1);   
 V3 := Vector(1,0);
 L1 := 14;
 L2 := 20;
 L3 := 20;

 // get the Vectorspace-Basis of P/I:

 B := QuotientBasis(I);

 // check what to paint for what Basis Element:

 // Check for all Elements in Basis what to draw:
 ForEach El_B In B Do
   L := Log(El_B);   
   Start := Offset + L1*L[1]*V1 + L2*L[2]V2 + L3*L[3]*V3;
  
   If Not(Indet(1)*Indet(2)*El_B IsIn B) And L[3] > 0 Then
     Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')
 {\line('+Sprint(-V3[1])+','+Sprint(-V3[2])+'){'+Sprint(L3)+'}}';
     String := String + Line;
   EndIf;   
   If Not(Indet(1)*Indet(3)*El_B IsIn B) And L[2] > 0 Then
     Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')
 {\line('+Sprint(-V2[1])+','+Sprint(-V2[2])+'){'+Sprint(L2)+'}}';
     String := String + Line;
   EndIf;   
   If Not(Indet(2)*Indet(3)*El_B IsIn B) And L[1] > 0 Then
     Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')
 {\line('+Sprint(-V1[1])+','+Sprint(-V1[2])+'){'+Sprint(L1)+'}}';
     String := String + Line;
   EndIf;   
  
 EndForEach;
 
 Return String+'\end{picture}';
 EndDefine;

code by dheldt 08:37, 22 Jun 2005 (CEST)

CoCoA & Latex Code (2. Version)

I created another version, a little bit more sophisticated. It contains coordinate axis and scales the picture enviroment to the right size. The code for this is:

 Define Border(I)
  
  //////////////////////////////////////////////////////////////////////////////
  // define your coordinate system:
  Offset := Vector(150,150);
  V1 := Vector(-1,-1);    L1 := 14;
  V2 := Vector(0,1);   L2 := 20;
  V3 := Vector(1,0);   L3 := 20;
 
  Max1 := 0;
  Max2 := 0;
  Max3 := 0;
    
  //////////////////////////////////////////////////////////////////////////////
  // get the Vectorspace-Basis of P/I:   
  B := QuotientBasis(I);
   
  //////////////////////////////////////////////////////////////////////////////
  // Compute picture's size:
  ForEach El_B In B Do
     L := Log(El_B);   
     If L[1] > Max1 Then Max1 := L[1]; EndIf;
     If L[2] > Max2 Then Max2 := L[2]; EndIf;
     If L[3] > Max3 Then Max3 := L[3]; EndIf;
  EndForEach;
    
  Max1:= Max1 + 1; Max2 := Max2 +1; Max3 := Max3 +1;
 
  Width  := Sum([ Abs(LC((Max1+3)*L1*V1[1])),Abs(LC((Max2+3)*L2*V2[1])),Abs(LC((Max3+3)*L3*V3[1])) ]);
  Height := Sum([ Abs(LC((Max1+3)*L1*V1[2])),Abs(LC((Max2+3)*L2*V2[2])),Abs(LC((Max3+3)*L3*V3[2])) ]);
 
  String:='\begin{picture}('+Sprint(Width)+','+Sprint(Height)+')';
 
  //////////////////////////////////////////////////////////////////////////////
  // Compute Offset / (0,0,0):
  Offset:=Vector(Abs(Min([ LC((Max1+3)*L1*V1[1]),LC((Max2+3)*L2*V2[1]),LC((Max3+3)*L3*V3[1])])),
               Abs(Min([ LC((Max1+3)*L1*V1[2]),LC((Max2+3)*L2*V2[2]),LC((Max3+3)*L3*V3[2])])));
 
  //////////////////////////////////////////////////////////////////////////////
  // Check for all Elements in Basis what to draw:
  ForEach El_B In B Do
     L := Log(El_B);   
     Start := Offset + L1*L[1]*V1 + L2*L[2]V2 + L3*L[3]*V3;
     
     If Not(Indet(1)*Indet(2)*El_B IsIn B) And L[3] > 0 Then
           Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')
                   {\line('+Sprint(-V3[1])+','+Sprint(-V3[2])+'){'+Sprint(L3)+'}}';
           String := String + Line;
     EndIf;   
     If Not(Indet(1)*Indet(3)*El_B IsIn B) And L[2] > 0 Then
           Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')
                   {\line('+Sprint(-V2[1])+','+Sprint(-V2[2])+'){'+Sprint(L2)+'}}';
           String := String + Line;
     EndIf;   
     If Not(Indet(2)*Indet(3)*El_B IsIn B) And L[1] > 0 Then
           Line := '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')
                   {\line('+Sprint(-V1[1])+','+Sprint(-V1[2])+'){'+Sprint(L1)+'}}';
           String := String + Line;
     EndIf;   
  EndForEach;
 
  //////////////////////////////////////////////////////////////////////////////
  // Draw the three axis and the indeterminates names:
 
  Start := Offset + Max1 * V1 * L1;
  String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')
                   {\vector('+Sprint(V1[1])+','+Sprint(V1[2])+'){'+Sprint(2*L1)+'}}';
            
  String := String + '\put('+Sprint(Start[1]+3*L1*V1[1])+','+Sprint(Start[2]+3*L1*V1[2])+')
                   {$\displaystyle ' +Sprint(Indet(1))+'$}';
 
  Start := Offset + Max2 * V2 * L2;
  String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')
                   {\vector('+Sprint(V2[1])+','+Sprint(V2[2])+'){'+Sprint(2*L2)+'}}';
 
  String := String + '\put('+Sprint(Start[1]+3*L2*V2[1])+','+Sprint(Start[2]+3*L2*V2[2])+')
                   {$\displaystyle ' +Sprint(Indet(2))+'$}';
 
  Start := Offset + Max3 * V3 * L3;
  String := String + '\put('+Sprint(Start[1])+','+Sprint(Start[2])+')
                   {\vector('+Sprint(V3[1])+','+Sprint(V3[2])+'){'+Sprint(2*L3)+'}}';
 
  String := String + '\put('+Sprint(Start[1]+3*L3*V3[1])+','+Sprint(Start[2]+3*L3*V3[2])+')
                   {$\displaystyle ' +Sprint(Indet(3))+'$}';
 
  Return String+'\end{picture}';
 EndDefine;

code by dheldt 08:37, 22 Jun 2005 (CEST)

Latex Framework

As a framework where to copy&paste the output to, you can use the following latex code:

 \documentclass[12pt,a4paper]{article}
 
 \usepackage{umlaut,a4wide,amsmath,amssymb,stmaryrd,color,graphicx,fancyhdr,multicol}
 \usepackage[latin1]{inputenc}
 \setlength{\parindent}{0mm}
 
 \begin{document}
 
 % Copy output here!
 
 \end{document}

code by dheldt 08:37, 22 Jun 2005 (CEST)

CoCoA & POV-Ray Code

This function returns some POV-Ray code to plot the quotient ideal of the input ideal (not necessarily zero-dimensional). The output should be saved into a file called "monomials.inc", in order to be included by QuotienBasis.pov:

ehm... I don't know how to add code here....