concept linear transformation in category python

This is an excerpt from Manning's book Math for Programmers: 3D graphics, machine learning, and simulations with Python MEAP V11.
The “well-behaved” vector transformations we’re going to focus on are called linear transformations. Along with vectors, linear transformations are the other main objects of study in linear algebra. Linear transformations are special transformations where vector arithmetic looks the same before and after the transformation. Let’s draw some diagrams to show exactly what that means.
The first mnemonic is that each coordinate of the output vector is a function of all the coordinates of the input vector. For instance, the first coordinate of the 3D output is a function f(x, y, z) = ax + by + cz. Moreover, this is a linear function (in the sense that you used the word in high school algebra); it is a sum of a number times each variable. We originally introduced the term “linear transformation” because linear transformations preserve lines. Another reason to use that term: a linear transformation is a collection of linear functions on the input coordinates that give the respective output coordinates.
How the linear transformation defined by this matrix affects the standard basis vectors.
![]()
Write a function compose_a_b that executes the composition of the linear transformation for A and the linear transformation for B. Then use the infer_matrix function from a previous exercise in this section to show that infer_matrix(3, compose_a_b) is the same as the matrix product AB.
Solution: First, we implement two functions transform_a and transform_b that do the linear transformations defined by the matrices A and B. Then, we combine these using our compose function:
from transforms import compose a = ((1,1,0),(1,0,1),(1,-1,1)) b = ((0,2,1),(0,1,0),(1,0,-1)) def transform_a(v): return multiply_matrix_vector(a,v) def transform_b(v): return multiply_matrix_vector(b,v) compose_a_b = compose(transform_a, transform_b)Now we can use our infer_matrix function to find the matrix corresponding to this composition of linear transformations and compare it to the matrix product AB: