Matrix Inverse | %. 2 _ 2 | Matrix Divide |
If y is a non-singular matrix, then %.y is
the inverse of y . For example:mp=: +/ . * NB. Matrix product (%. ; ] ; %. mp ]) i. 2 2 +--------+---+---+ |_1.5 0.5|0 1|1 0| | 1 0|2 3|0 1| +--------+---+---+More generally, %.y is defined in terms of the dyadic case, with the left argument =i.{:$y (an identity matrix) or, equally, by the relation (%.y)mp x ↔ x %. y . The shape of %.y is |.$y . The vector and scalar cases are defined by using the matrix ,.y, but the shape of the result is $y . For a non-zero vector y, the result of %.y is a vector collinear with y whose length is the reciprocal of that of y; it is called the reflection of y in the unit circle (or sphere). Thus: (%. ,: ] % %.) 2 3 4 0.0689655 0.103448 0.137931 29 29 29 |
If y is non-singular, then x%.y
is (%.y) mp x .
More generally, if the columns of y are linearly independent and
if #x and #y agree, then x%.y minimizes
the difference:d=: x - y mp x %. yin the sense that the magnitudes +/d*+d are minimized. Scalar and vector cases of y are treated as the one-column matrix ,.y . Geometrically, y mp x%.y is the projection of the vector x on the column space of y, the point nearest to x in the space spanned by the columns of y . Common uses of %. are in the solution of linear equations and in the approximation of functions by polynomials, as in c=: (f x)%. x ^ / i.4 . |
sin=: 1&o. NB. Function to be approximated x=: 5 %~ i. 6 c=: (sin x) %. x ^/ i.4 NB. Use of matrix divide ,.&.>@(] ; c"_ ; sin ; c&p. ; >./@:|@(sin-c&p.)) x +---+-----------+--------+-----------+-----------+ | 0|_5.30503e_5| 0|_5.30503e_5|0.000167992| |0.2| 1.00384|0.198669| 0.198826| | |0.4| _0.018453|0.389418| 0.389321| | |0.6| _0.143922|0.564642| 0.564523| | |0.8| |0.717356| 0.717524| | | 1| |0.841471| 0.841416| | +---+-----------+--------+-----------+-----------+