This method returns a random orthogonal matrix of a given size n. The orthogonal matrix is constructed via Cayley’s correspondence, which gives a bijection between skew-symmetric matrices, and orthogonal matrices O which do not have 1 as an eigenvalue (i.e., O - I is invertible). Up to changing signs of rows, any orthogonal matrix can be obtained this way: if G≅(ℤ/2ℤ)n is the group of diagonal matrices with diagonal entries equal to ±1, acting on n×n matrices by left multiplication, then (as one may check) every G-orbit contains a matrix that does not have 1 as an eigenvalue (if the characteristic is not 2).
Note that the matrices which feature in the Cayley correspondence have determinant (-1)n, so this method scales by -1 to return a special orthogonal matrix. Thus the matrices returned by this method do not have -1 as an eigenvalue.
By default a matrix over RR is returned. This method also accepts a ring as an (optional) argument, in which case a special orthogonal matrix over the ring is returned, with entries in the base coefficient ring.
i1 : O1 = randomOrthogonal 5 o1 = | .442386 -.0306554 .751799 -.317548 .370563 | | .133864 .768167 -.0944111 -.513838 -.345046 | | -.60855 -.385718 .234815 -.587034 -.284854 | | -.42001 .39448 .591227 .519553 -.220209 | | -.489525 .323399 -.145593 -.143489 .783576 | 5 5 o1 : Matrix RR <--- RR 53 53 |
i2 : isOrthogonal O1 o2 = true |
i3 : eigenvalues O1 o3 = {.070857+.997486*ii} {.070857-.997486*ii} {.803392+.595451*ii} {.803392-.595451*ii} {1 } o3 : VerticalList |
i4 : det O1 o4 = 1 o4 : RR (of precision 53) |
i5 : R = QQ[x,y] o5 = R o5 : PolynomialRing |
i6 : O2 = randomOrthogonal(5, R) o6 = | -22142569999/27593776175 90555408/788393605 -5532008344/27593776175 | 193172688/788393605 145827307/157678721 24042978/788393605 | 591854008/5518755235 -5780466/157678721 -5151709442/5518755235 | -598559432/27593776175 -200993706/788393605 7495643483/27593776175 | -84039992/157678721 40244400/157678721 18443792/157678721 ------------------------------------------------------------------------ -5025793592/27593776175 2046480376/3941968025 | -216954846/788393605 70436016/788393605 | -1194249041/5518755235 -206975072/788393605 | -25053509506/27593776175 -751964432/3941968025 | 22251808/157678721 -123874657/157678721 | 5 5 o6 : Matrix R <--- R |
i7 : isOrthogonal O2 o7 = true |
i8 : det(O2), det(O2+id_(R^5)) 5225472 o8 = (1, ---------) 157678721 o8 : Sequence |