06-1350/Syzygies in Asymptote: Difference between revisions
(Started guide.) |
(More write-up) |
||
Line 1: | Line 1: | ||
WARNING: These instructions are a work in progress and should be considered highly unreliable. |
WARNING: These instructions are a work in progress and should be considered highly unreliable. |
||
To use the syzygy script, first install [http://asymptote.sourceforge.net Asymptote]. Instructions for installing the program on several OSes is given in the documentation at the Asymptote website. The documentation also gives helpful |
To use the syzygy script, first install [http://asymptote.sourceforge.net Asymptote]. Instructions for installing the program on several OSes is given in the documentation at the Asymptote website. The documentation also gives helpful instructions on how to run a script in Asymptote to produce a picture. Once installed, download [http://www.math.utoronto.ca/~andy/syzygy.asy syzygy.asy] and put it in a directory where Asymptote can find it. You should also have (or install) a variant of TeX on your system, such as MiKTeX, so that Asymptote can typeset labels. |
||
Once installed, we can draw a braid in Asymptote: |
Once installed, we can draw a braid in Asymptote: |
||
Line 10: | Line 10: | ||
b.n=3; // The braid has three strands. |
b.n=3; // The braid has three strands. |
||
// The strands are numbered left to right starting at 0. |
// The strands are numbered left to right starting at 0. |
||
b.add(bp, 0); // Add a |
b.add(bp, 0); // Add a overcrossing component starting at strand 0, |
||
// the leftmost strand. |
// the leftmost strand. |
||
b.add( |
b.add(bm, 1); // Add an undercrossing starting at strand 1. |
||
b.add(phi, 0); // Add a trivalent vertex that merges strands 0 and 1. |
b.add(phi, 0); // Add a trivalent vertex that merges strands 0 and 1. |
||
// Strand 2 is now renumbered as strand 1. |
// Strand 2 is now renumbered as strand 1. |
||
b.draw() // Draw the resulting braid. |
b.draw() // Draw the resulting braid. |
||
</pre> |
|||
When saved into an asy file, say <code>mybraid.asy</code> and run with Asymptote, the result is a picture: |
|||
ADD PICTURE |
|||
To define a relation, we first define two braids, and then stick them into a <code>Relation</code> structure. The below script generates an R3 relation. |
|||
<pre> |
|||
import syzygy; // Access the syzygy module. |
|||
Braid l. // Define the left hand side of the relation. |
|||
l.n=3; l.add(bp, 0); l.add(bp, 1); l.add(bp, 0); |
|||
Braid r. // Define the right hand side of the relation. |
|||
r.n=3; r.add(bp, 1); l.add(bp, 0); l.add(bp, 1); |
|||
Relation r3; // Define a relation. |
|||
r.lsym="\rho_3"; // Give the relation a name for when it is written in functional form. |
|||
r.codename="rho3"; // Give the relation a name to used by Mathematica. |
|||
r.lhs=l; r.rhs.r; |
|||
r.draw(); |
|||
</pre> |
|||
When saved into an asy file and run, this draws the two sides of the relation. If TeX is installed, Asymptote will also put a lovely equals sign, typeset by TeX, between the two figures. |
|||
ADD ANOTHER PICTURE |
|||
We can also get useful equations out of the relation. The method <code>r3.toFormula()</code> will produce a string that is the formula for the relation. |
|||
<pre> |
|||
big ugly string |
|||
</pre> |
|||
This string can be written out to the standard output by <code>write(r3.toFormula())</code>. It can be written to a file by <code>file f=output("filename.txt"); write(f, r3.toFormula())</code>. The string is formatted so it can be put into TeX or a wiki page using math mode: |
|||
ADD EQUATION |
|||
The method <code>r3.toLinear()</code> produces the formula in linear form: |
|||
ADD EQUATION |
|||
and <code>r3.toCode()</code> produces a version of the relation that can be used in Mathematica: |
|||
<pre> |
|||
ADD CODE |
|||
</pre> |
</pre> |
Revision as of 15:12, 4 December 2006
WARNING: These instructions are a work in progress and should be considered highly unreliable.
To use the syzygy script, first install Asymptote. Instructions for installing the program on several OSes is given in the documentation at the Asymptote website. The documentation also gives helpful instructions on how to run a script in Asymptote to produce a picture. Once installed, download syzygy.asy and put it in a directory where Asymptote can find it. You should also have (or install) a variant of TeX on your system, such as MiKTeX, so that Asymptote can typeset labels.
Once installed, we can draw a braid in Asymptote:
import syzygy; // Accesses the syzygy module. Braid b; // Start a new braid. b.n=3; // The braid has three strands. // The strands are numbered left to right starting at 0. b.add(bp, 0); // Add a overcrossing component starting at strand 0, // the leftmost strand. b.add(bm, 1); // Add an undercrossing starting at strand 1. b.add(phi, 0); // Add a trivalent vertex that merges strands 0 and 1. // Strand 2 is now renumbered as strand 1. b.draw() // Draw the resulting braid.
When saved into an asy file, say mybraid.asy
and run with Asymptote, the result is a picture:
ADD PICTURE
To define a relation, we first define two braids, and then stick them into a Relation
structure. The below script generates an R3 relation.
import syzygy; // Access the syzygy module. Braid l. // Define the left hand side of the relation. l.n=3; l.add(bp, 0); l.add(bp, 1); l.add(bp, 0); Braid r. // Define the right hand side of the relation. r.n=3; r.add(bp, 1); l.add(bp, 0); l.add(bp, 1); Relation r3; // Define a relation. r.lsym="\rho_3"; // Give the relation a name for when it is written in functional form. r.codename="rho3"; // Give the relation a name to used by Mathematica. r.lhs=l; r.rhs.r; r.draw();
When saved into an asy file and run, this draws the two sides of the relation. If TeX is installed, Asymptote will also put a lovely equals sign, typeset by TeX, between the two figures.
ADD ANOTHER PICTURE
We can also get useful equations out of the relation. The method r3.toFormula()
will produce a string that is the formula for the relation.
big ugly string
This string can be written out to the standard output by write(r3.toFormula())
. It can be written to a file by file f=output("filename.txt"); write(f, r3.toFormula())
. The string is formatted so it can be put into TeX or a wiki page using math mode:
ADD EQUATION
The method r3.toLinear()
produces the formula in linear form:
ADD EQUATION
and r3.toCode()
produces a version of the relation that can be used in Mathematica:
ADD CODE