[687609] | 1 | // File: tropical.tst |
---|
| 2 | // Tests for tropical lib |
---|
| 3 | LIB "tst.lib"; |
---|
| 4 | tst_init(); |
---|
| 5 | LIB "tropical.lib"; |
---|
| 6 | /////////////////////////////////////////////////////////////////////////// |
---|
| 7 | // A) Test for tropicalLifting and displayTropicalLifting |
---|
| 8 | /////////////////////////////////////////////////////////////////////////// |
---|
| 9 | ring r0=0,(t,x),dp; |
---|
| 10 | poly f=t7-6t4+3t3x+8t3-12t2x+6tx2-x3+t2; |
---|
| 11 | f; |
---|
| 12 | // The point -2/3 is in the tropical variety. |
---|
| 13 | list L=tropicalLifting(f,intvec(3,-2),4); |
---|
| 14 | L; |
---|
| 15 | displayTropicalLifting(L,"subst"); |
---|
| 16 | // -------------------------------------------------------- |
---|
| 17 | // Example 2 - a field extension is necessary |
---|
| 18 | // -------------------------------------------------------- |
---|
| 19 | poly g=(1+t2)*x2+t5x+t2; |
---|
| 20 | g; |
---|
| 21 | // The poin -1 is in the tropical variety. |
---|
| 22 | displayTropicalLifting(tropicalLifting(g,intvec(1,-1),4),"subst"); |
---|
| 23 | // -------------------------------------------------------- |
---|
| 24 | // Example 3 - the ideal is not zero dimensional |
---|
| 25 | // -------------------------------------------------------- |
---|
| 26 | ring r1=0,(t,x,y),dp; |
---|
| 27 | poly f=(9t27-12t26-5t25+21t24+35t23-51t22-40t21+87t20+56t19-94t18-62t17+92t16+56t15-70t14-42t13+38t12+28t11+18t10-50t9-48t8+40t7+36t6-16t5-12t4+4t2)*x2+(-9t24+12t23-4t22-42t20+28t19+30t18-20t17-54t16+16t15+48t14-16t12+8t11-18t10-26t9+30t8+20t7-24t6+4t5+28t4-8t3-16t2+4)*xy+(6t16-10t15-2t14+16t13+4t12-18t11-10t10+24t9+6t8-20t7+8t6+8t5-20t4-4t3+12t2+4t-4)*y2+(-9t28+3t27+8t26-4t25-45t24-6t23+42t22+30t21-94t20-40t19+68t18+82t17-38t16-60t15+26t14+36t13-22t12-20t11+4t10+4t9+12t8+8t7-8t6-8t5+4t4)*x+(9t27-21t26+16t25+14t24+12t23-61t22+27t21+80t20-19t19-100t18+26t17+96t16-24t15-84t14+44t12-2t11-18t10+2t9+40t8+4t7-32t6-12t5+4t3+12t2-4)*y+(9t27-12t26+4t25+36t23-18t22-28t21-2t20+54t19+14t18-52t17-44t16+24t15+40t14-4t13-12t12+4t11-4t10-4t9+4t8); |
---|
| 28 | f; |
---|
| 29 | displayTropicalLifting(tropicalLifting(f,intvec(1,-1,-4),3),"subst"); |
---|
| 30 | // -------------------------------------------------------- |
---|
| 31 | // Example 4 - the ideal has even more equations |
---|
| 32 | // -------------------------------------------------------- |
---|
| 33 | ring r2=0,(t,x,y,z),dp; |
---|
| 34 | ideal i=t-x3+3yz,t2xy-2x2z; |
---|
| 35 | i; |
---|
| 36 | displayTropicalLifting(tropicalLifting(i,intvec(1,1,3,0),2),"subst"); |
---|
| 37 | // -------------------------------------------------------- |
---|
| 38 | // Example 5-7 - testing some options |
---|
| 39 | // -------------------------------------------------------- |
---|
| 40 | setring r0; |
---|
| 41 | poly f1=(x2-t3)*(x3-t5)*(x5-t7)*(x7-t11)*(x11-t13); |
---|
| 42 | f1; |
---|
| 43 | displayTropicalLifting(tropicalLifting(f1,intvec(7,-11),4,"noAbs"),"subst"); |
---|
| 44 | poly f2=(1+t2)*x2+t5x+t2; |
---|
| 45 | f2; |
---|
| 46 | displayTropicalLifting(tropicalLifting(f2,intvec(1,-1),4,"isZeroDimensional","findAll"),"subst"); |
---|
| 47 | poly f3=t7-6t4+3t3x+8t3-12t2x+6tx2-x3+t2; |
---|
| 48 | f3; |
---|
| 49 | displayTropicalLifting(tropicalLifting(f3,intvec(3,-2),4,"isInTrop","findAll"),"subst"); |
---|
| 50 | /////////////////////////////////////////////////////////////////////////// |
---|
| 51 | // B) Test for tropicalCurve, drawTropicalCurve and drawNewtonSubdivision |
---|
| 52 | /////////////////////////////////////////////////////////////////////////// |
---|
| 53 | ring r=(0,t),(x,y),dp; |
---|
| 54 | poly f=t*(x7+y7+1)+1/t*(x4+y4+x2+y2+x3y+xy3)+1/t7*x2y2; |
---|
| 55 | list graph=tropicalCurve(f); |
---|
| 56 | graph; |
---|
| 57 | size(graph)-1; |
---|
| 58 | drawTropicalCurve(graph,"onlytexfile"); |
---|
| 59 | poly g=t3*(x7+y7+1)+1/t3*(x4+y4+x2+y2+x3y+xy3)+1/t21*x2y2; |
---|
| 60 | list tropical_g=tropicalise(g); |
---|
| 61 | tropical_g; |
---|
| 62 | drawTropicalCurve(tropical_g,"onlytexfile"); |
---|
| 63 | /////////////////////////////////////////////////////////////////////////// |
---|
| 64 | // C) Test for tropicalJInvariant, jInvariant, weierstrassForm |
---|
| 65 | /////////////////////////////////////////////////////////////////////////// |
---|
| 66 | // tropcial_j_invariant computes the tropical j-invariant of the elliptic curve f |
---|
| 67 | tropicalJInvariant(t*(x3+y3+1)+1/t*(x2+y2+x+y+x2y+xy2)+1/t2*xy); |
---|
| 68 | // the Newton polygone need not be the standard simplex |
---|
| 69 | tropicalJInvariant(x+y+x2y+xy2+1/t*xy); |
---|
| 70 | // the curve can have arbitrary degree |
---|
| 71 | tropicalJInvariant(t*(x7+y7+1)+1/t*(x4+y4+x2+y2+x3y+xy3)+1/t7*x2y2); |
---|
| 72 | // the procedure does not realise, if the embedded graph of the tropical curve has |
---|
| 73 | // a loop that can be resolved |
---|
| 74 | tropicalJInvariant(1+x+y+xy+tx2y+txy2); |
---|
| 75 | // but it does realise, if the curve has no loop at all ... |
---|
| 76 | tropicalJInvariant(x+y+1); |
---|
| 77 | // or if the embedded graph has more than one loop - even if only one cannot be resolved |
---|
| 78 | tropicalJInvariant(1+x+y+xy+tx2y+txy2+t3x5+t3y5+tx2y2+t2xy4+t2yx4); |
---|
| 79 | // f is already in Weierstrass form |
---|
| 80 | weierstrassForm(y2+yx+3y-x3-2x2-4x-6); |
---|
| 81 | // g is not, but wg is |
---|
| 82 | g=x+y+x2y+xy2+1/t*xy; |
---|
| 83 | poly wg=weierstrassForm(g); |
---|
| 84 | wg; |
---|
| 85 | // ... but it is not yet a simple, since it still has an xy-term, unlike swg |
---|
| 86 | poly swg=weierstrassForm(g,1); |
---|
| 87 | swg; |
---|
| 88 | // the j-invariants of all three polynomials coincide ... |
---|
| 89 | jInvariant(g); |
---|
| 90 | jInvariant(wg); |
---|
| 91 | jInvariant(swg); |
---|
| 92 | // the following curve is elliptic as well |
---|
| 93 | poly h=x22y11+x19y10+x17y9+x16y9+x12y7+x9y6+x7y5+x2y3; |
---|
| 94 | // its Weierstrass form is |
---|
| 95 | weierstrassForm(h); |
---|
| 96 | jInvariant(x+y+x2y+y3+1/t*xy,"ord"); |
---|
| 97 | /////////////////////////////////////////////////////////////////////////// |
---|
| 98 | // D) Test for tropicalise, tropicaliseSet, tInitialForm, |
---|
| 99 | // tInitialIdeal, initialForm, initialIdeal |
---|
| 100 | /////////////////////////////////////////////////////////////////////////// |
---|
| 101 | tropicalise(2t3x2-1/t*xy+2t3y2+(3t3-t)*x+ty+(t6+1)); |
---|
| 102 | ideal i=txy-y2+1,2t3x2+1/t*y-t6; |
---|
| 103 | tropicaliseSet(i); |
---|
| 104 | setring r1; |
---|
| 105 | poly ff=t4x2+y2-t2xy+t4x-t9; |
---|
| 106 | intvec w=-1,-2,-3; |
---|
| 107 | tInitialForm(ff,w); |
---|
| 108 | ideal ii=t2x-y+t3,t2x-y-2t3x; |
---|
| 109 | w=-1,2,0; |
---|
| 110 | // the t-initial forms of the generators are |
---|
| 111 | tInitialForm(ii[1],w),tInitialForm(i[2],w); |
---|
| 112 | // and they do not generate the t-initial ideal of i |
---|
| 113 | tInitialIdeal(ii,w); |
---|
| 114 | ring r5=0,(x,y),dp; |
---|
| 115 | poly f=x3+y2-xy+x-1; |
---|
| 116 | w=2,3; |
---|
| 117 | initialForm(f,w); |
---|
| 118 | initialIdeal(f,w); |
---|
| 119 | /////////////////////////////////////////////////////////////////////////// |
---|
| 120 | // E) Test for texNumber, texPolynomial, texMatrix, texDrawBasic, |
---|
| 121 | // texDrawTropical, texDrawNewtonSubdivision, texDrawTriangulation |
---|
| 122 | /////////////////////////////////////////////////////////////////////////// |
---|
| 123 | ring r6=(0,t),x,dp; |
---|
| 124 | texNumber((3t2-1)/t3); |
---|
| 125 | texPolynomial(1/t*x2-t2x+1/t); |
---|
| 126 | matrix M[2][2]=3/2,1/t*x2-t2x+1/t,5,-2x; |
---|
| 127 | texMatrix(M); |
---|
| 128 | setring r; |
---|
| 129 | string texf=texDrawTropical(tropicalCurve(x+y+1),list("",1)); |
---|
| 130 | texDrawBasic(texf); |
---|
| 131 | graph=tropicalCurve(x+y+x2y+xy2+1/t*xy); |
---|
| 132 | // compute the texdraw code of the tropical curve defined by f |
---|
| 133 | texDrawTropical(graph); |
---|
| 134 | // compute the texdraw code again, but set the scalefactor to 1 |
---|
| 135 | texDrawTropical(graph,"",1); |
---|
| 136 | texDrawNewtonSubdivision(graph); |
---|
| 137 | list polygon=intvec(1,1),intvec(3,0),intvec(2,0),intvec(1,0),intvec(0,0),intvec(2,1),intvec(0,1),intvec(1,2),intvec(0,2),intvec(0,3); |
---|
| 138 | list triang=intvec(1,2,5),intvec(1,5,10),intvec(1,2,10); |
---|
| 139 | texDrawTriangulation(triang,polygon); |
---|
| 140 | /////////////////////////////////////////////////////////////////////////// |
---|
| 141 | // F) Test for Auxilary Procedures |
---|
| 142 | /////////////////////////////////////////////////////////////////////////// |
---|
| 143 | ring r7=0,(x,y),dp; |
---|
| 144 | ideal i=(x+1)*y2; |
---|
| 145 | // y is NOT in the radical of i |
---|
| 146 | radicalMemberShip(y,i); |
---|
| 147 | ring r8=0,(x,y),ds; |
---|
| 148 | ideal i=(x+1)*y2; |
---|
| 149 | // since this time the ordering is local, y is in the radical of i |
---|
| 150 | radicalMemberShip(y,i); |
---|
| 151 | ring r9=(0,t),(x,y),dp; |
---|
| 152 | poly f=t4x2+y2-t2xy+t4x-t9; |
---|
| 153 | w=2,3; |
---|
| 154 | tInitialFormPar(f,w); |
---|
| 155 | f=t4x2+y2-t2xy+t4x-1/t6; |
---|
| 156 | w=2,3; |
---|
| 157 | tInitialFormParMax(f,w); |
---|
| 158 | ideal i=t2x2+y2,x-t2; |
---|
| 159 | solveTInitialFormPar(i); |
---|
| 160 | detropicalise(3x+4y-1); |
---|
| 161 | ring r10=0,(x,y),dp; |
---|
| 162 | poly conic=2x2+1/2y2-1; |
---|
| 163 | dualConic(conic); |
---|
| 164 | setring r; |
---|
| 165 | f=t2xy+1/t*y+t3; |
---|
| 166 | parameterSubstitute(f,3); |
---|
| 167 | parameterSubstitute(f,-1); |
---|
| 168 | f=t2x+1/t*y-1; |
---|
| 169 | tropicalSubst(f,2,x,x+t,y,tx+y+t2); |
---|
| 170 | randomPoly(3,-2,5); |
---|
| 171 | randomPoly(3,-2,5,1); |
---|
| 172 | ////////////////////////////// |
---|
| 173 | tst_status(1);$ |
---|