Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/notebooks/Chapter 6 - Linear Combination.ipynb
Views: 449
Visualization of Linear Combination in
Consider two vectors and in , they are independent of each other, i.e. not pointing to the same or opposite direction. Therefore any vector in the can be represented by a linear combination of and .
For instance, this is a linear combination and essentially a linear system.
Solve the system in SymPy:
The solution is , which means the addition of times and times equals .
Besides plotting the vector addition, we would like to plot the coordinates of the basis spanned by and . We will explain this further in a later chapter.
Calculate the slope of the vectors, i.e., :
The basis can be constructed as: where and will be set as constants with regular intervals, such as .
The coordinates of the basis are represented as pink web-style grids, where each line segment is a unit (like in the Cartesian coordinate system) in the 'new' coordinates.
Linear Combination Visualization in 3D
We can also show that any vectors in can be a linear combination of a standard basis in Cartesian coordinate system.
Here is the function for plotting 3D linear combination from standard basis, we just feed the scalar multiplier.
Linear Combination of Inconsistent System
An inconsistent system means no unique solution exists. It might seem strange to treat a solution of an inconsistent system as a linear combination, but it essentially represents a trace of a line.
One Free Variable Case
We have seen how inconsistent systems can be solved in the earlier lectures. Now we will investigate what solution means from the perspective of linear combination.
Consider a system
Solve in SymPy:
The solution is not unique due to a free variable:
Let , the system can be parameterized:
The solution is a line of infinite length, to visualize it, we set the range of , the solution looks like:
Two Free Variables Case
Now consider the linear system: $$ \left[ \right] \left[ \right]
\left[ \right] \left[ \right] $$ Rewrite the solution
The solution is a plain spanned by two vectors and . Let's draw the plane and spanning vectors. We also plot another vector which is not a linear combination of and . As you pan around the view angle (in JupyterLab use %matplotlib widge
), it is apparent that is not in the same plane of basis vectors.
Linear Combination of Polynomial
In a more general sense, a function or a polynomial can also be a linear combination of other functions or polynomials.
Now consider a polynomial , determine if it is a linear combination of three polynomials below:
which means that we need to figure out if the equation below holds
Rearrange and collect terms
Equate the coefficients and extract the augmented matrix
Before solving, we notice that the system has 4 equations, but 3 unknowns, this case is called over-determined.
We get the answer , plug in back to equation Indeed we have just established a linear combination between these polynomials.