Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tutorial:polynomials_tutorial [2017/02/20 13:43] – [Basic Usage of Polynomials in Perl] wagner | user_guide:tutorials:polynomials_tutorial [2019/02/04 22:55] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Basic Usage of Polynomials in Perl ===== | + | {{page>.:latest:@FILEID@}} |
- | + | ||
- | A polynomial always carries a reference to a polynomial ring. Polynomial in different rings cannot be added, multiplied, or whatever. | + | |
- | + | ||
- | <code> | + | |
- | polytope> | + | |
- | </ | + | |
- | + | ||
- | It may be convenient to use special variable names for the indeterminates. | + | |
- | + | ||
- | < | + | |
- | polytope> | + | |
- | </ | + | |
- | + | ||
- | Notice that the variable names are chosen to match the print names; but this is " | + | |
- | + | ||
- | < | + | |
- | polytope > $p=1+($x^2)+$y; | + | |
- | polytope > $q=1+$x+2*($y^3)+$x*$y; | + | |
- | polytope > print($p*$q); | + | |
- | x^3*y + x^3 + 2*x^2*y^3 + x^2 + x*y^2 + 2*x*y + x + 2*y^4 + 2*y^3 + y + 1 | + | |
- | </ | + | |
- | + | ||
- | Standard arithmetic function " | + | |
- | + | ||
- | Here is one way to produce polytopes from polynomials (as the convex hull of the exponent vectors of all terms). | + | |
- | + | ||
- | < | + | |
- | polytope> | + | |
- | polytope> | + | |
- | 1 0 0 | + | |
- | 1 2 3 | + | |
- | 1 0 4 | + | |
- | 1 3 0 | + | |
- | 1 3 1 | + | |
- | polytope> | + | |
- | 1 | + | |
- | </ | + | |
- | + | ||
- | The final " | + | |
- | + | ||
- | ===== Example: Toric Degeneration ===== | + | |
- | + | ||
- | The following describes how to construct the polynomial which describes the toric deformation with respect to a point configuration and a height function. | + | |
- | + | ||
- | < | + | |
- | polytope > $points = new Matrix< | + | |
- | polytope > $height = new Vector< | + | |
- | polytope > $coefficients = new Vector< | + | |
- | </ | + | |
- | + | ||
- | The following is generic (assuming that the dimensions of the objects above match). | + | |
- | + | ||
- | < | + | |
- | polytope > @vars = ( " | + | |
- | polytope > $R = new Ring(@vars); | + | |
- | polytope > $p = new Polynomial($height|$points, | + | |
- | </ | + | |
- | + | ||
- | Notice that the points are given in Euclidean coordinates; | + | |
- | + | ||
- | < | + | |
- | polytope > print $p; | + | |
- | -1/2*s^2*x1 + 1/ | + | |
- | </ | + | |