Clojure Linear Algebra Refresher, Part 4: Linear Transformations
One meta comment.<p>You&#x27;ve taken the usual approach of explaining matrix operations as an unmotivated &quot;this is what we do&quot; and then tried to layer linear transformations as a weird abstract thing which somehow relates.  Most people do this, and it makes sense for people who don&#x27;t want to actually understand.<p>If you want people to actually understand, the relationship goes the other way.  Linear transformations are the thing we really care about, and matrices happen to be the most convenient way to write them.<p>More specifically if T is a linear transformation from V to W, with bases (v_1, ..., v_n) and (w_1, ..., w_n), then then we can write down M = (T(v_1) T(v_2) ... T(v_n)).  So far that&#x27;s just a rectangular array of numbers, uniquely defined for the linear transformation.  Now if we have a vector v = a_1 v_1 + a_2 v_2 + ... + a_n v_n then just tracing through linearity, we get that T(v) is Mv with the regular matrix multiplication.  Furthermore we can now prove that any rectangular matrix defines a unique linear function with that rule.<p>The result?  When you have 2 vector spaces with a basis for each, each linear function gives a unique matrix, and each matrix gives a unique linear function.  Matrices are just convenient ways of writing down linear transformations.<p>OK, now if S is a linear transformation from W to U, and we have a basis for U, then what about the function S o T defined by S o T(v) = S(T(v))?  If you work it out, it is a linear function, and its matrix is the usual matrix multiplication.  So matrix multiplication is the same as function composition for linear functions.<p>Here is something fun.  You know the associative law?  That magically just works after a ton of calculations for matrices?  Well, here is why it works.  For any three linear transformations R, S, and T which can be composed, and any vector v, by definition:<p>((R o S) o T)(v) = (R o S)(T(v)) = R(S(T(v)))
(R o (S o T))(v) = R((S o T)(v)) = R(S(T(v)))<p>Which means that functions under composition are associative.  Since matrix multiplication is just a way of writing function composition, it must also be associative.  QED!<p>As you move through things like change of basis matrices, it is all a lot easier to understand starting from the point of view of linear functions as being fundamental, and matrices just being a way to represent it with a given pair of bases.