The glossary from the end of Strand: glossary.pdf
Solve for the variables x, y, and z in the system
\begin{aligned} z & =2 \\ x+y+z & =2 \\ 2 x+2 y+4 z & =8 \end{aligned}
Make an augmented matrix:
\left[\begin{array}{llll} 0 & 0 & 1 & 2 \\ 1 & 1 & 1 & 2 \\ 2 & 2 & 4 & 8 \end{array}\right]
\left[\begin{array}{llll} 0 & 0 & 1 & 2 \\ 1 & 1 & 1 & 2 \\ 2 & 2 & 4 & 8 \end{array}\right] \stackrel{E_{12}}{\longrightarrow}\left[\begin{array}{llll} 1 & 1 & 1 & 2 \\ 0 & 0 & 1 & 2 \\ 2 & 2 & 4 & 8 \end{array}\right] \xrightarrow[E_{31}(-2)]{\longrightarrow}\left[\begin{array}{rlll} 1 & 1 & 1 & 2 \\ 0 & 0 & 2 & 4 \\ 0 & 0 & 1 & 2 \end{array}\right]
We keep on going… \begin{aligned} & {\left[\begin{array}{rrrr} 1 & 1 & 1 & 2 \\ 0 & 0 & 2 & 4 \\ 0 & 0 & 1 & 2 \end{array}\right] \xrightarrow[E_{2}(1 / 2)]{\longrightarrow}\left[\begin{array}{rrrr} 1 & 1 & 1 & 2 \\ 0 & 0 & 1 & 2 \\ 0 & 0 & 1 & 2 \end{array}\right]} \\ & \overrightarrow{E_{32}(-1)}\left[\begin{array}{rrrr} 1 & 1 & 1 & 2 \\ 0 & 0 & 1 & 2 \\ 0 & 0 & 0 & 0 \end{array}\right] \xrightarrow[E_{12}(-1)]{\longrightarrow}\left[\begin{array}{rrrr} 1 & 1 & 0 & 0 \\ 0 & 0 & 1 & 2 \\ 0 & 0 & 0 & 0 \end{array}\right] . \end{aligned}
We have ended up with this matrix:
\left[\begin{array}{rrrr} 1 & 1 & 0 & 0 \\ 0 & 0 & 1 & 2 \\ 0 & 0 & 0 & 0 \end{array}\right]
How can we use this to solve for z? What about x?
But there’s no information on y! It can be anything!!
\begin{aligned} & x=-y \\ & z=2 \\ & y \text { is free. } \end{aligned}
We define a free variable as one that isn’t constrained by the equations. We can assign it any value we want, and the system will still have a solution.
A bound variable is one that is constrained by the equations.
Suppose we have another augmented matrix, which after GJ elimination has become:
\left[\begin{array}{rrrrr} x & y & z & w & \mathrm{rhs} \\ 1 & 2 & 0 & -1 & 2 \\ 0 & 0 & 1 & 3 & 0 \\ 0 & 0 & 0 & 0 & 0 \end{array}\right] .
The solutions are: \begin{aligned} x+2 y-w & =2 \\ z+3 w & =0 . \end{aligned}
How can we tell from looking at the matrix which variables are free vs bound?
Columns which contain pivots correspond to bound variables. The others correspond to free variables.
(Columns with pivots are called “basic” columns.)
E_A=\left(\begin{array}{cccccccc}1 & * & 0 & 0 & * & * & 0 & * \\ 0 & 0 & 1 & 0 & * & * & 0 & * \\ 0 & 0 & 0 & 1 & * & * & 0 & * \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & * \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\end{array}\right)
Which are the basic columns (the ones with pivots, corresponding to bound variables)?
Which are the non-basic columns (the ones without pivots, corresponding to free variables)?
E_A=\left(\begin{array}{cccccccc}1 & * & 0 & 0 & 8 & * & 0 & * \\ 0 & 0 & 1 & 0 & 4 & * & 0 & * \\ 0 & 0 & 0 & 1 & 3 & * & 0 & * \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & * \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\end{array}\right)
Notice how the non-basic column 5 here can be formed as a weighted sum of the basic columns to the left (columns 1, 3, and 4).
This is always true! Every non-basic column can be formed as a weighted sum of the basic columns to the left.
(And it turns out that it is true as well before we even find the RREF form of a matrix. If a column will be a basic column in RREF, it must be a linear combination of the basic columns to the left.)
Some systems of equations have no solutions. For example, consider the following system:
\begin{array}{r} x+y=1 \\ 2 x+y=2 \\ 3 x+2 y=5 . \end{array}
\left[\begin{array}{lll} 1 & 1 & 1 \\ 2 & 1 & 2 \\ 3 & 2 & 5 \end{array}\right] \xrightarrow[E_{21}(-2)]{E_{31}(-3)}\left[\begin{array}{lrl} 1 & 1 & 1 \\ 0 & -1 & 0 \\ 0 & -1 & 2 \end{array}\right] \xrightarrow[E_{32}(-1)]{\longrightarrow}\left[\begin{array}{rrr} 1 & 1 & 1 \\ 0 & -1 & 0 \\ 0 & 0 & 2 \end{array}\right]
We have arrived at an impossible equation: 0 = 2.
This means that the system has no solutions.
We say that the system is inconsistent.
For an augmented matrix in RREF, if the only only nonzero entry in a row appears on the right-hand side, that means that the system has no solutions, and is therefore inconsistent.
\text { Row } i \longrightarrow\left( \begin{array}{cccccc|c} * & * & * & * & * & * & * \\ 0 & 0 & 0 & * & * & * & * \\ 0 & 0 & 0 & 0 & * & * & * \\ 0 & 0 & 0 & 0 & 0 & 0 & \alpha \\ \bullet & \bullet & \bullet & \bullet & \bullet & \bullet & \bullet \\ \bullet & \bullet & \bullet & \bullet & \bullet & \bullet & \bullet \end{array} \right) \longleftarrow \alpha \neq 0
Here the i^{\text {th }} equation of this system is
0 x_{1}+0 x_{2}+\cdots+0 x_{n}=\alpha \implies 0 = \alpha .
If \alpha\ne 0, this has no solution!
This is an inconsistent system.
Suppose that instead of \alpha on the right-hand side of row i, there is a 0:
\text { Row } i \longrightarrow\left( \begin{array}{cccccc|c} * & * & * & * & * & * & * \\ 0 & 0 & 0 & * & * & * & * \\ 0 & 0 & 0 & 0 & * & * & * \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \bullet & \bullet & \bullet & \bullet & \bullet & \bullet & \bullet \\ \bullet & \bullet & \bullet & \bullet & \bullet & \bullet & \bullet \end{array} \right) \longleftarrow \alpha \neq 0
This is perfectly fine! It does not mean that the system is inconsistent.
Suppose a matrix A_{m \times n} has a reduced row echelon form E_{m \times n}: E_A=\left(\begin{array}{cccccccc}1 & * & 0 & 0 & * & * & 0 & * \\ 0 & 0 & 1 & 0 & * & * & 0 & * \\ 0 & 0 & 0 & 1 & * & * & 0 & * \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & * \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\end{array}\right)
Suppose a matrix A_{m \times n} has a reduced row echelon form E_{m \times n}: E_A=\left(\begin{array}{cccccccc}1 & * & 0 & 0 & * & * & 0 & * \\ 0 & 0 & 1 & 0 & * & * & 0 & * \\ 0 & 0 & 0 & 1 & * & * & 0 & * \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & * \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\end{array}\right)
rank(A) = # of pivots = # of nonzero rows in E = # bound variables in the system
Suppose a matrix A_{m \times n} has a reduced row echelon form E_{m \times n}: E_A=\left(\begin{array}{cccccccc}1 & * & 0 & 0 & * & * & 0 & * \\ 0 & 0 & 1 & 0 & * & * & 0 & * \\ 0 & 0 & 0 & 1 & * & * & 0 & * \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & * \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\end{array}\right)
nullity(A) = # of non-pivot columns = # free variables in the system
Equivalent ways of saying A is consistent:
. . . \left(\begin{array}{llll|l} 0 & 0 & \cdots & 0 & \alpha \tag{2.3.2} \end{array}\right) \text {, where } \alpha \neq 0 \text {. }
\operatorname{rank}[\mathbf{A} \mid \mathbf{b}]=\operatorname{rank}(\mathbf{A}), in which case either:
\mathbf{b} is a nonbasic column in [\mathbf{A} \mid \mathbf{b}].
\mathbf{b} is a combination of the basic columns in \mathbf{A}.
The general linear system with m \times n coefficient matrix A and right-hand-side vector \mathbf{b} is homogeneous if the entries of \mathbf{b} are all zero.
Otherwise, the system is inhomogeneous.
Homogeneous systems are always consistent!
Can solve by setting all variables to zero. This is the trivial solution
If rank of the matrix = n, there is only the trivial solution
Goal: rank pages in terms of “importance”. Suppose we have four pages:
How can we rank these pages? Which one is most important?
First try: let’s just count the number of backlinks, and make that the page’s rank.
Any potential downsides to this?
This can easily be gamed just by making many links to a page!
Second try: rank pages by how many incoming links they have and how highly ranked they are.
For page i let x_{i} be its score and L_{i} be the set of all indices of pages linking to it. Then \begin{equation*} x_{i}=\sum_{x_{j} \in L_{i}} x_{j} \end{equation*}
Notice: you can’t just look at the graph anymore and know what the rankings will be! The ranking for one page depends on the rankings of all the others.
But it’s still easy to game this system, by setting up a set of interlinked pages and then making a ton of outgoing links to pages we want to promote.
Third try: downweight incoming links from pages that have many outgoing links.
For page j let n_{j} be its total number of outgoing links on that page. Then its score is
\begin{equation*} x_{i}=\sum_{x_{j} \in L_{i}} \frac{x_{j}}{n_{j}} \end{equation*}
:::
\begin{equation*} x_{i}=\sum_{x_{j} \in L_{i}} \frac{x_{j}}{n_{j}} \end{equation*}
Write down the system of equations this gives us. Then make it in an augmented matrix.
We make a matrix using the sym.Matrix function.
We can create symbolic variables, and put them into the matrix if we want…
If we input fractions, they are by default converted to floating point numbers:
\displaystyle \left[\begin{matrix}1 & x_{2} & 0.333333333333333\\2 & 1 & 3\\2 & x_{1} & 1\end{matrix}\right]
It’s nicer to input fractions and keep them as fractions:
We can substitute values in for variables:
We can find reduced row echelon form:
This outputs the RREF and tells us which columns correspond to bound variables.
Lastly, we can do Gauss-Jordan elimination to solve a system of equations with a matrix and a right-hand-side:
(Matrix([
[(17*x1 - 24*x2 - 3)/(7*x1 - 12*x2 - 1)],
[ -4/(7*x1 - 12*x2 - 1)],
[(-9*x1 + 12*x2 + 3)/(7*x1 - 12*x2 - 1)]]),
Matrix(0, 1, []))
That’s messy! It’s exporting several things, but the one we want is the first.
Create a matrix representing the system of equations for the “third try” in the PageRank problem:
\begin{aligned} & x_{1}=\frac{x_{2}}{1}+\frac{x_{3}}{3} \\ & x_{2}=\frac{x_{1}}{2}+\frac{x_{3}}{3} \\ & x_{3}=\frac{x_{1}}{2}+\frac{x_{4}}{1} \\ & x_{4}=\frac{x_{3}}{3} . \end{aligned}
Now find the RREF form of this matrix. What does that tell you about the system?
Next, use the gauss_jordan_solve. What’s surprising (or not) about these results?
Substitute a specific value to get a particular solution…
https://tinyurl.com/stat24320notebook1
Remember this was our ‘second try’: \begin{equation*} x_{i}=\sum_{x_{j} \in L_{i}} x_{j} \end{equation*}
This was the system of equations. \begin{aligned} & x_{1}=x_{2}+x_{3} \\ & x_{2}=x_{1}+x_{3} \\ & x_{3}=x_{1}+x_{4} \\ & x_{4}=x_{3} . \end{aligned}
What happens if we try to solve this? Try it in Python.
Rod with fixed temperatures y_{left} and y_{right} at each end, internal heat source given as f(x), 0 \leq x \leq 1
What’s the temperature at each point along the length?
Equations to balance the flow of heat from each node to its neighbors:
\begin{equation*} -y_{i-1}+2 y_{i}-y_{i+1}=\frac{h^{2}}{K} f\left(x_{i}\right) \end{equation*}
Suppose:
What are the discretized steady-state equations?
\begin{array}{lllllr} 2 y_{1}&-y_{2} & & & & =f(1 / 6) / 36 \\ -y_{1}&+2 y_{2}&-y_{3} & & & =f(2 / 6) / 36 \\ &-y_{2}&+2 y_{3}&-y_{4} & & =f(3 / 6) / 36 \\ &&-y_{3}&+2 y_{4}&-y_{5} & =f(4 / 6) / 36 \\ &&&-y_{4}&+2 y_{5} & =f(5 / 6) / 36 \end{array}
Build the matrix representing the system of equations:
\begin{equation*} -y_{i-1}+2 y_{i}-y_{i+1}=\frac{h^{2}}{K} f\left(x_{i}\right) \end{equation*}
Decide on a function for f. Let’s say \frac{h^{2}}{K} f = x_i^2.
Say that x is running from 0 to 1. Then we can have
https://colab.research.google.com/github/ijmbarr/turing-patterns/blob/master/turing-patterns.ipynb#scrollTo=GsEPBsz33E14