<strong>Sage</strong> <strong>Reference</strong> <strong>Manual</strong>: <strong>Matrices</strong> <strong>and</strong> <strong>Spaces</strong> <strong>of</strong> <strong>Matrices</strong>, Release 6.1.1 sage: a.r<strong>and</strong>omize(0.5) sage: a [ 1/2*x^2 - x - 12 1/2*x^2 - 1/95*x - 1/2 0] [-5/2*x^2 + 2/3*x - 1/4 0 0] [ -x^2 + 2/3*x 0 0] Now we r<strong>and</strong>omize all the entries <strong>of</strong> the resulting matrix: sage: a.r<strong>and</strong>omize() sage: a [ 1/3*x^2 - x + 1 -x^2 + 1 x^2 - x] [ -1/14*x^2 - x - 1/4 -4*x - 1/5 -1/4*x^2 - 1/2*x + 4] [ 1/9*x^2 + 5/2*x - 3 -x^2 + 3/2*x + 1 -2/7*x^2 - x - 1/2] We create the zero matrix over the integers: sage: a = matrix(ZZ, 2); a [0 0] [0 0] Then we r<strong>and</strong>omize it; the x <strong>and</strong> y parameters, which determine the size <strong>of</strong> the r<strong>and</strong>om elements, are passed onto the ZZ r<strong>and</strong>om_element method. sage: a.r<strong>and</strong>omize(x=-2^64, y=2^64) sage: a [-12401200298100116246 1709403521783430739] [ -4417091203680573707 17094769731745295000] rational_form(format=’right’, subdivide=True) Returns the rational canonical form, also known as Frobenius form. INPUT: •self - a square matrix with entries from an exact field. •format - default: ‘right’ - one <strong>of</strong> ‘right’, ‘bottom’, ‘left’, ‘top’ or ‘invariants’. The first four will cause a matrix to be returned with companion matrices dictated by the keyword. The value ‘invariants’ will cause a list <strong>of</strong> lists to be returned, where each list contains coefficients <strong>of</strong> a polynomial associated with a companion matrix. •subdivide - default: ‘True’ - if ‘True’ <strong>and</strong> a matrix is returned, then it contains subdivisions delineating the companion matrices along the diagonal. OUTPUT: The rational form <strong>of</strong> a matrix is a similar matrix composed <strong>of</strong> submatrices (“blocks”) placed on the main diagonal. Each block is a companion matrix. Associated with each companion matrix is a polynomial. In rational form, the polynomial <strong>of</strong> one block will divide the polynomial <strong>of</strong> the next block (<strong>and</strong> thus, the polynomials <strong>of</strong> all subsequent blocks). Rational form, also known as Frobenius form, is a canonical form. In other words, two matrices are similar if <strong>and</strong> only if their rational canonical forms are equal. The algorithm used does not provide the similarity transformation matrix (also known as the change-<strong>of</strong>-basis matrix). Companion matrices may be written in one <strong>of</strong> four styles, <strong>and</strong> any such style may be selected with the format keyword. See the companion matrix constructor, sage.matrix.constructor.companion_matrix(), for more information about companion matrices. If the ‘invariants’ value is used for the format keyword, then the return value is a list <strong>of</strong> lists, where each list is the coefficients <strong>of</strong> the polynomial associated with one <strong>of</strong> the companion matrices on the diagonal. 224 Chapter 7. Base class for matrices, part 2
<strong>Sage</strong> <strong>Reference</strong> <strong>Manual</strong>: <strong>Matrices</strong> <strong>and</strong> <strong>Spaces</strong> <strong>of</strong> <strong>Matrices</strong>, Release 6.1.1 These coefficients include the leading one <strong>of</strong> the monic polynomial <strong>and</strong> are ready to be coerced into any polynomial ring over the same field (see examples <strong>of</strong> this below). This return value is intended to be the most compact representation <strong>and</strong> the easiest to use for testing equality <strong>of</strong> rational forms. Because the minimal <strong>and</strong> characteristic polynomials <strong>of</strong> a companion matrix are the associated polynomial, it is easy to see that the product <strong>of</strong> the polynomials <strong>of</strong> the blocks will be the characteristic polynomial <strong>and</strong> the final polynomial will be the minimal polynomial <strong>of</strong> the entire matrix. ALGORITHM: We begin with ZigZag form, which is due to Arne Storjohann <strong>and</strong> is documented at zigzag_form(). Then we eliminate ‘’corner” entries enroute to rational form via an additional algorithm <strong>of</strong> Storjohann’s [STORJOHANN-EMAIL]. EXAMPLES: The lists <strong>of</strong> coefficients returned with the invariants keyword are designed to easily convert to the polynomials associated with the companion matrices. This is illustrated by the construction below <strong>of</strong> the polys list. Then we can test the divisibility condition on the list <strong>of</strong> polynomials. Also the minimal <strong>and</strong> characteristic polynomials are easy to determine from this list. sage: A = matrix(QQ, [[ 11, 14, -15, -4, -38, -29, 1, 23, 14, -63, 17, 24, 36, 32], ... [ 18, 6, -17, -11, -31, -43, 12, 26, 0, -69, 11, 13, 17, 24], ... [ 11, 16, -22, -8, -48, -34, 0, 31, 16, -82, 26, 31, 39, 37], ... [ -8, -18, 22, 10, 46, 33, 3, -27, -12, 70, -19, -20, -42, -31], ... [-13, -21, 16, 10, 52, 43, 4, -28, -25, 89, -37, -20, -53, -62], ... [ -2, -6, 0, 0, 6, 10, 1, 1, -7, 14, -11, -3, -10, -18], ... [ -9, -19, -3, 4, 23, 30, 8, -3, -27, 55, -40, -5, -40, -69], ... [ 4, -8, -1, -1, 5, -4, 9, 5, -11, 4, -14, -2, -13, -17], ... [ 1, -2, 16, -1, 19, -2, -1, -17, 2, 19, 5, -25, -7, 14], ... [ 7, 7, -13, -4, -26, -21, 3, 18, 5, -40, 7, 15, 20, 14], ... [ -6, -7, -12, 4, -1, 18, 3, 8, -11, 15, -18, 17, -15, -41], ... [ 5, 11, -11, -3, -26, -19, -1, 14, 10, -42, 14, 17, 25, 23], ... [-16, -15, 3, 10, 29, 45, -1, -13, -19, 71, -35, -2, -35, -65], ... [ 4, 2, 3, -2, -2, -10, 1, 0, 3, -11, 6, -4, 6, 17]] sage: A.rational_form() [ 0 -4| 0 0 0 0| 0 0 0 0 0 0 0 0] [ 1 4| 0 0 0 0| 0 0 0 0 0 0 0 0] [---------+-------------------+---------------------------------------] [ 0 0| 0 0 0 12| 0 0 0 0 0 0 0 0] [ 0 0| 1 0 0 -4| 0 0 0 0 0 0 0 0] [ 0 0| 0 1 0 -9| 0 0 0 0 0 0 0 0] [ 0 0| 0 0 1 6| 0 0 0 0 0 0 0 0] [---------+-------------------+---------------------------------------] [ 0 0| 0 0 0 0| 0 0 0 0 0 0 0 -216] [ 0 0| 0 0 0 0| 1 0 0 0 0 0 0 108] [ 0 0| 0 0 0 0| 0 1 0 0 0 0 0 306] [ 0 0| 0 0 0 0| 0 0 1 0 0 0 0 -271] [ 0 0| 0 0 0 0| 0 0 0 1 0 0 0 -41] [ 0 0| 0 0 0 0| 0 0 0 0 1 0 0 134] [ 0 0| 0 0 0 0| 0 0 0 0 0 1 0 -64] [ 0 0| 0 0 0 0| 0 0 0 0 0 0 1 13] sage: R = PolynomialRing(QQ, ’x’) sage: invariants = A.rational_form(format=’invariants’) sage: invariants [[4, -4, 1], [-12, 4, 9, -6, 1], [216, -108, -306, 271, 41, -134, 64, -13, 1]] sage: polys = [R(p) for p in invariants] sage: [p.factor() for p in polys] [(x - 2)^2, (x - 3) * (x + 1) * (x - 2)^2, (x + 1)^2 * (x - 3)^3 * (x - 2)^3] 225
- Page 1:
Sage Reference Manual: Matrices and
- Page 4 and 5:
22 Dense matrices over multivariate
- Page 6 and 7:
Sage Reference Manual: Matrices and
- Page 8 and 9:
Sage Reference Manual: Matrices and
- Page 10 and 11:
Sage Reference Manual: Matrices and
- Page 12 and 13:
Sage Reference Manual: Matrices and
- Page 14 and 15:
Sage Reference Manual: Matrices and
- Page 16 and 17:
Sage Reference Manual: Matrices and
- Page 18 and 19:
Sage Reference Manual: Matrices and
- Page 20 and 21:
Sage Reference Manual: Matrices and
- Page 22 and 23:
Sage Reference Manual: Matrices and
- Page 24 and 25:
Sage Reference Manual: Matrices and
- Page 26 and 27:
Sage Reference Manual: Matrices and
- Page 28 and 29:
Sage Reference Manual: Matrices and
- Page 30 and 31:
Sage Reference Manual: Matrices and
- Page 32 and 33:
Sage Reference Manual: Matrices and
- Page 34 and 35:
Sage Reference Manual: Matrices and
- Page 36 and 37:
Sage Reference Manual: Matrices and
- Page 38 and 39:
Sage Reference Manual: Matrices and
- Page 40 and 41:
Sage Reference Manual: Matrices and
- Page 42 and 43:
Sage Reference Manual: Matrices and
- Page 44 and 45:
Sage Reference Manual: Matrices and
- Page 46 and 47:
Sage Reference Manual: Matrices and
- Page 48 and 49:
Sage Reference Manual: Matrices and
- Page 50 and 51:
Sage Reference Manual: Matrices and
- Page 52 and 53:
Sage Reference Manual: Matrices and
- Page 54 and 55:
Sage Reference Manual: Matrices and
- Page 56 and 57:
Sage Reference Manual: Matrices and
- Page 58 and 59:
Sage Reference Manual: Matrices and
- Page 60 and 61:
Sage Reference Manual: Matrices and
- Page 62 and 63:
Sage Reference Manual: Matrices and
- Page 64 and 65:
Sage Reference Manual: Matrices and
- Page 66 and 67:
Sage Reference Manual: Matrices and
- Page 68 and 69:
Sage Reference Manual: Matrices and
- Page 70 and 71:
Sage Reference Manual: Matrices and
- Page 72 and 73:
Sage Reference Manual: Matrices and
- Page 74 and 75:
Sage Reference Manual: Matrices and
- Page 76 and 77:
Sage Reference Manual: Matrices and
- Page 78 and 79:
Sage Reference Manual: Matrices and
- Page 80 and 81:
Sage Reference Manual: Matrices and
- Page 82 and 83:
Sage Reference Manual: Matrices and
- Page 84 and 85:
Sage Reference Manual: Matrices and
- Page 86 and 87:
Sage Reference Manual: Matrices and
- Page 88 and 89:
Sage Reference Manual: Matrices and
- Page 90 and 91:
Sage Reference Manual: Matrices and
- Page 92 and 93:
Sage Reference Manual: Matrices and
- Page 94 and 95:
Sage Reference Manual: Matrices and
- Page 96 and 97:
Sage Reference Manual: Matrices and
- Page 98 and 99:
Sage Reference Manual: Matrices and
- Page 100 and 101:
Sage Reference Manual: Matrices and
- Page 102 and 103:
Sage Reference Manual: Matrices and
- Page 104 and 105:
Sage Reference Manual: Matrices and
- Page 106 and 107:
Sage Reference Manual: Matrices and
- Page 108 and 109:
Sage Reference Manual: Matrices and
- Page 110 and 111:
Sage Reference Manual: Matrices and
- Page 112 and 113:
Sage Reference Manual: Matrices and
- Page 114 and 115:
Sage Reference Manual: Matrices and
- Page 116 and 117:
Sage Reference Manual: Matrices and
- Page 118 and 119:
Sage Reference Manual: Matrices and
- Page 120 and 121:
Sage Reference Manual: Matrices and
- Page 122 and 123:
Sage Reference Manual: Matrices and
- Page 124 and 125:
Sage Reference Manual: Matrices and
- Page 126 and 127:
Sage Reference Manual: Matrices and
- Page 128 and 129:
Sage Reference Manual: Matrices and
- Page 130 and 131:
Sage Reference Manual: Matrices and
- Page 132 and 133:
Sage Reference Manual: Matrices and
- Page 134 and 135:
Sage Reference Manual: Matrices and
- Page 136 and 137:
Sage Reference Manual: Matrices and
- Page 138 and 139:
Sage Reference Manual: Matrices and
- Page 140 and 141:
Sage Reference Manual: Matrices and
- Page 142 and 143:
Sage Reference Manual: Matrices and
- Page 144 and 145:
Sage Reference Manual: Matrices and
- Page 146 and 147:
Sage Reference Manual: Matrices and
- Page 148 and 149:
Sage Reference Manual: Matrices and
- Page 150 and 151:
Sage Reference Manual: Matrices and
- Page 152 and 153:
Sage Reference Manual: Matrices and
- Page 154 and 155:
Sage Reference Manual: Matrices and
- Page 156 and 157:
Sage Reference Manual: Matrices and
- Page 158 and 159:
Sage Reference Manual: Matrices and
- Page 160 and 161:
Sage Reference Manual: Matrices and
- Page 162 and 163:
Sage Reference Manual: Matrices and
- Page 164 and 165:
Sage Reference Manual: Matrices and
- Page 166 and 167:
Sage Reference Manual: Matrices and
- Page 168 and 169:
Sage Reference Manual: Matrices and
- Page 170 and 171:
Sage Reference Manual: Matrices and
- Page 172 and 173:
Sage Reference Manual: Matrices and
- Page 174 and 175:
Sage Reference Manual: Matrices and
- Page 176 and 177:
Sage Reference Manual: Matrices and
- Page 178 and 179: Sage Reference Manual: Matrices and
- Page 180 and 181: Sage Reference Manual: Matrices and
- Page 182 and 183: Sage Reference Manual: Matrices and
- Page 184 and 185: Sage Reference Manual: Matrices and
- Page 186 and 187: Sage Reference Manual: Matrices and
- Page 188 and 189: Sage Reference Manual: Matrices and
- Page 190 and 191: Sage Reference Manual: Matrices and
- Page 192 and 193: Sage Reference Manual: Matrices and
- Page 194 and 195: Sage Reference Manual: Matrices and
- Page 196 and 197: Sage Reference Manual: Matrices and
- Page 198 and 199: Sage Reference Manual: Matrices and
- Page 200 and 201: Sage Reference Manual: Matrices and
- Page 202 and 203: Sage Reference Manual: Matrices and
- Page 204 and 205: Sage Reference Manual: Matrices and
- Page 206 and 207: Sage Reference Manual: Matrices and
- Page 208 and 209: Sage Reference Manual: Matrices and
- Page 210 and 211: Sage Reference Manual: Matrices and
- Page 212 and 213: Sage Reference Manual: Matrices and
- Page 214 and 215: Sage Reference Manual: Matrices and
- Page 216 and 217: Sage Reference Manual: Matrices and
- Page 218 and 219: Sage Reference Manual: Matrices and
- Page 220 and 221: Sage Reference Manual: Matrices and
- Page 222 and 223: Sage Reference Manual: Matrices and
- Page 224 and 225: Sage Reference Manual: Matrices and
- Page 226 and 227: Sage Reference Manual: Matrices and
- Page 230 and 231: Sage Reference Manual: Matrices and
- Page 232 and 233: Sage Reference Manual: Matrices and
- Page 234 and 235: Sage Reference Manual: Matrices and
- Page 236 and 237: Sage Reference Manual: Matrices and
- Page 238 and 239: Sage Reference Manual: Matrices and
- Page 240 and 241: Sage Reference Manual: Matrices and
- Page 242 and 243: Sage Reference Manual: Matrices and
- Page 244 and 245: Sage Reference Manual: Matrices and
- Page 246 and 247: Sage Reference Manual: Matrices and
- Page 248 and 249: Sage Reference Manual: Matrices and
- Page 250 and 251: Sage Reference Manual: Matrices and
- Page 252 and 253: Sage Reference Manual: Matrices and
- Page 254 and 255: Sage Reference Manual: Matrices and
- Page 256 and 257: Sage Reference Manual: Matrices and
- Page 258 and 259: Sage Reference Manual: Matrices and
- Page 260 and 261: Sage Reference Manual: Matrices and
- Page 262 and 263: Sage Reference Manual: Matrices and
- Page 264 and 265: Sage Reference Manual: Matrices and
- Page 266 and 267: Sage Reference Manual: Matrices and
- Page 268 and 269: Sage Reference Manual: Matrices and
- Page 270 and 271: Sage Reference Manual: Matrices and
- Page 272 and 273: Sage Reference Manual: Matrices and
- Page 274 and 275: Sage Reference Manual: Matrices and
- Page 276 and 277: Sage Reference Manual: Matrices and
- Page 278 and 279:
Sage Reference Manual: Matrices and
- Page 280 and 281:
Sage Reference Manual: Matrices and
- Page 282 and 283:
Sage Reference Manual: Matrices and
- Page 284 and 285:
Sage Reference Manual: Matrices and
- Page 286 and 287:
Sage Reference Manual: Matrices and
- Page 288 and 289:
Sage Reference Manual: Matrices and
- Page 290 and 291:
Sage Reference Manual: Matrices and
- Page 292 and 293:
Sage Reference Manual: Matrices and
- Page 294 and 295:
Sage Reference Manual: Matrices and
- Page 296 and 297:
Sage Reference Manual: Matrices and
- Page 298 and 299:
Sage Reference Manual: Matrices and
- Page 300 and 301:
Sage Reference Manual: Matrices and
- Page 302 and 303:
Sage Reference Manual: Matrices and
- Page 304 and 305:
Sage Reference Manual: Matrices and
- Page 306 and 307:
Sage Reference Manual: Matrices and
- Page 308 and 309:
Sage Reference Manual: Matrices and
- Page 310 and 311:
Sage Reference Manual: Matrices and
- Page 312 and 313:
Sage Reference Manual: Matrices and
- Page 314 and 315:
Sage Reference Manual: Matrices and
- Page 316 and 317:
Sage Reference Manual: Matrices and
- Page 318 and 319:
Sage Reference Manual: Matrices and
- Page 320 and 321:
Sage Reference Manual: Matrices and
- Page 322 and 323:
Sage Reference Manual: Matrices and
- Page 324 and 325:
Sage Reference Manual: Matrices and
- Page 326 and 327:
Sage Reference Manual: Matrices and
- Page 328 and 329:
Sage Reference Manual: Matrices and
- Page 330 and 331:
Sage Reference Manual: Matrices and
- Page 332 and 333:
Sage Reference Manual: Matrices and
- Page 334 and 335:
Sage Reference Manual: Matrices and
- Page 336 and 337:
Sage Reference Manual: Matrices and
- Page 338 and 339:
Sage Reference Manual: Matrices and
- Page 340 and 341:
Sage Reference Manual: Matrices and
- Page 342 and 343:
Sage Reference Manual: Matrices and
- Page 344 and 345:
Sage Reference Manual: Matrices and
- Page 346 and 347:
Sage Reference Manual: Matrices and
- Page 348 and 349:
Sage Reference Manual: Matrices and
- Page 350 and 351:
Sage Reference Manual: Matrices and
- Page 352 and 353:
Sage Reference Manual: Matrices and
- Page 354 and 355:
Sage Reference Manual: Matrices and
- Page 356 and 357:
Sage Reference Manual: Matrices and
- Page 358 and 359:
Sage Reference Manual: Matrices and
- Page 360 and 361:
Sage Reference Manual: Matrices and
- Page 362 and 363:
Sage Reference Manual: Matrices and
- Page 364 and 365:
Sage Reference Manual: Matrices and
- Page 366 and 367:
Sage Reference Manual: Matrices and
- Page 368 and 369:
Sage Reference Manual: Matrices and
- Page 370 and 371:
Sage Reference Manual: Matrices and
- Page 372 and 373:
Sage Reference Manual: Matrices and
- Page 374 and 375:
Sage Reference Manual: Matrices and
- Page 376 and 377:
Sage Reference Manual: Matrices and
- Page 378 and 379:
Sage Reference Manual: Matrices and
- Page 380 and 381:
Sage Reference Manual: Matrices and
- Page 382 and 383:
Sage Reference Manual: Matrices and
- Page 384 and 385:
Sage Reference Manual: Matrices and
- Page 386 and 387:
Sage Reference Manual: Matrices and
- Page 388 and 389:
Sage Reference Manual: Matrices and
- Page 390 and 391:
Sage Reference Manual: Matrices and
- Page 392 and 393:
Sage Reference Manual: Matrices and
- Page 394 and 395:
Sage Reference Manual: Matrices and
- Page 396 and 397:
Sage Reference Manual: Matrices and
- Page 398 and 399:
Sage Reference Manual: Matrices and
- Page 400 and 401:
Sage Reference Manual: Matrices and
- Page 402 and 403:
Sage Reference Manual: Matrices and
- Page 404 and 405:
Sage Reference Manual: Matrices and
- Page 406 and 407:
Sage Reference Manual: Matrices and
- Page 408 and 409:
Sage Reference Manual: Matrices and
- Page 410 and 411:
Sage Reference Manual: Matrices and
- Page 412 and 413:
Sage Reference Manual: Matrices and
- Page 414 and 415:
Sage Reference Manual: Matrices and
- Page 416 and 417:
Sage Reference Manual: Matrices and
- Page 418 and 419:
Sage Reference Manual: Matrices and
- Page 420 and 421:
Sage Reference Manual: Matrices and
- Page 422 and 423:
Sage Reference Manual: Matrices and
- Page 424 and 425:
Sage Reference Manual: Matrices and
- Page 426 and 427:
Sage Reference Manual: Matrices and
- Page 428 and 429:
Sage Reference Manual: Matrices and
- Page 430 and 431:
Sage Reference Manual: Matrices and
- Page 432 and 433:
Sage Reference Manual: Matrices and
- Page 434 and 435:
Sage Reference Manual: Matrices and
- Page 436 and 437:
Sage Reference Manual: Matrices and
- Page 438 and 439:
Sage Reference Manual: Matrices and
- Page 440 and 441:
Sage Reference Manual: Matrices and
- Page 442 and 443:
Sage Reference Manual: Matrices and