Essays/Minors

From J Wiki
Jump to: navigation, search

A minor of size one less than the size of a matrix obtains by removing row i and column j ; the array of such minors can be computed using the outfix (\.):

   ] m=: i.3 4
0 1  2  3
4 5  6  7
8 9 10 11

   minors=: 1&(|:\.)"2^:2

   $ minors m
3 4 2 3
   <"_2 minors m
┌───────┬───────┬──────┬──────┐
│5  6  7│4  6  7│4 5  7│4 5  6│
│9 10 11│8 10 11│8 9 11│8 9 10│
├───────┼───────┼──────┼──────┤
│1  2  3│0  2  3│0 1  3│0 1  2│
│9 10 11│8 10 11│8 9 11│8 9 10│
├───────┼───────┼──────┼──────┤
│1 2 3  │0 2 3  │0 1 3 │0 1 2 │
│5 6 7  │4 6 7  │4 5 7 │4 5 6 │
└───────┴───────┴──────┴──────┘

Complementary indexing also lends itself to the computation of minors:

   ] i=: <&.>&.> {i.&.>$m
┌─────────┬─────────┬─────────┬─────────┐
│┌───┬───┐│┌───┬───┐│┌───┬───┐│┌───┬───┐│
││┌─┐│┌─┐│││┌─┐│┌─┐│││┌─┐│┌─┐│││┌─┐│┌─┐││
│││0│││0│││││0│││1│││││0│││2│││││0│││3│││
││└─┘│└─┘│││└─┘│└─┘│││└─┘│└─┘│││└─┘│└─┘││
│└───┴───┘│└───┴───┘│└───┴───┘│└───┴───┘│
├─────────┼─────────┼─────────┼─────────┤
│┌───┬───┐│┌───┬───┐│┌───┬───┐│┌───┬───┐│
││┌─┐│┌─┐│││┌─┐│┌─┐│││┌─┐│┌─┐│││┌─┐│┌─┐││
│││1│││0│││││1│││1│││││1│││2│││││1│││3│││
││└─┘│└─┘│││└─┘│└─┘│││└─┘│└─┘│││└─┘│└─┘││
│└───┴───┘│└───┴───┘│└───┴───┘│└───┴───┘│
├─────────┼─────────┼─────────┼─────────┤
│┌───┬───┐│┌───┬───┐│┌───┬───┐│┌───┬───┐│
││┌─┐│┌─┐│││┌─┐│┌─┐│││┌─┐│┌─┐│││┌─┐│┌─┐││
│││2│││0│││││2│││1│││││2│││2│││││2│││3│││
││└─┘│└─┘│││└─┘│└─┘│││└─┘│└─┘│││└─┘│└─┘││
│└───┴───┘│└───┴───┘│└───┴───┘│└───┴───┘│
└─────────┴─────────┴─────────┴─────────┘
   $ i{m
3 4 2 3
   <"2 i{m
┌───────┬───────┬──────┬──────┐
│5  6  7│4  6  7│4 5  7│4 5  6│
│9 10 11│8 10 11│8 9 11│8 9 10│
├───────┼───────┼──────┼──────┤
│1  2  3│0  2  3│0 1  3│0 1  2│
│9 10 11│8 10 11│8 9 11│8 9 10│
├───────┼───────┼──────┼──────┤
│1 2 3  │0 2 3  │0 1 3 │0 1 2 │
│5 6 7  │4 6 7  │4 5 7 │4 5 6 │
└───────┴───────┴──────┴──────┘

   minors1=: <&.>&.>@{@(i.&.>"_)@$ { ]

   (minors -: minors1) m
1

Laplace expansion of the determinant of a square matrix:

   det=: -/ .*

   ] m=: _8 + 5 5 ?@$ 20
 2 _1 10  1 _6
 4  7 _3  7  5
10  2 _8 _3  1
_2  6 _8 _2 _4
 1  0  7  9 _4

   ] cofactors=: (_1^+/&>{i.&.>$m) * det minors m
_2560 _8740 _7780  6540   460
 _640 _8510 _3870   810 _5110
_5760  3490  3010  _630  2410
 2240 _4425  2215   355  5235
 _640  7770  5370 _9310  5890

   det m
_70400

   i=: ?#m
   +/ (i{m) * i{cofactors
_70400

   j=: ?{:$m
   +/ (j{"1 m) * j{"1 cofactors
_70400

   +/ m * cofactors
_70400 _70400 _70400 _70400 _70400

   +/"1 m * cofactors
_70400 _70400 _70400 _70400 _70400



See also


Contributed by Roger Hui. The two phrases for minors appear in the Special Matrices section of J Phrases; the first phrase can be found on the green J mug.