Re:Linear Algebra for AI
by umanwizard on Saturday September 16, 2017 @08:39AM
(#15264377)
Matrices are not fundamental or interesting by themselves as just Excel-like grids of numbers. The reason we care about them is because they are a convenient notation for a certain class of functions.
I have to catch a flight so I don't have time to explain this fully, but the key points are:
1/ A "linear function" is a function where each variable in the output is "linear" in all the variables of the input (i.e., a sum of constant multiples of the input variables). e.g. f(x,y) = (x + 3y, y - 2x) is a linear function, but g(x, y) = (x^2, sin(y)) is not.
2/ All linear functions can be represented by a matrix. The `f` I mentioned above corresponds to the matrix:
[ 1 3
-2 1 ]
3/ The rules of matrix multiplication are defined so that multiplying by the matrix of a linear function corresponds to applying that function.
For example, again using the definitions above:
f(7, 8) = (31, -6)
And notice that we get the same thing when we do matrix multiplication:
[ 1 3 * [ 7 = [ 31
-2 1] 8 ] -6 ]
4/ Matrix multiplication also corresponds to function composition. If `f` is as defined above, and `h` is defined by h(x, y) = (-3y, 4x + y), then the matrix for h is
[ 0 -3
4 1 ]
and the function `f ο h` you get by applying `h` and then `f` is (you can check this...)
f ο h(x, y) = (12x, 4x + 7y)
The matrix for this functions happens to be
[ 12 0
4 7 ]
But, lo and behold, this matches matrix multiplication:
[ 1 3 * [ 0 -3 = [ 12 0
-2 1 ] 4 1 ] 4 7 ]
4/ Why do we care about linear functions? Well, linear functions are interesting for a lot of reasons, but one in particular is that (differential) calculus is all about approximating arbitrary differentiable functions by linear ones. So you might have some weird function but, if it's differentiable, you know that "locally" it is approximated by some (constant plus a) linear function
I have to catch a flight so I don't have time to explain this fully, but the key points are:
1/ A "linear function" is a function where each variable in the output is "linear" in all the variables of the input (i.e., a sum of constant multiples of the input variables). e.g. f(x,y) = (x + 3y, y - 2x) is a linear function, but g(x, y) = (x^2, sin(y)) is not.
2/ All linear functions can be represented by a matrix. The `f` I mentioned above corresponds to the matrix:
3/ The rules of matrix multiplication are defined so that multiplying by the matrix of a linear function corresponds to applying that function.For example, again using the definitions above:
And notice that we get the same thing when we do matrix multiplication: 4/ Matrix multiplication also corresponds to function composition. If `f` is as defined above, and `h` is defined by h(x, y) = (-3y, 4x + y), then the matrix for h is and the function `f ο h` you get by applying `h` and then `f` is (you can check this...) The matrix for this functions happens to be But, lo and behold, this matches matrix multiplication: 4/ Why do we care about linear functions? Well, linear functions are interesting for a lot of reasons, but one in particular is that (differential) calculus is all about approximating arbitrary differentiable functions by linear ones. So you might have some weird function but, if it's differentiable, you know that "locally" it is approximated by some (constant plus a) linear function