Teaching Kids Programming: Videos on Data Structures and Algorithms
Given the following two equations:
We can work on the X or Y in one equation and then substitue it in another equation. For example: from Equation 1, we know and we can plug in x into the second equation.
Linear Algebra: Using Matrix to Solve Equations of X and Y
Let’s put the coefficients of the above equations into the following matrix:
And then we can transform the above equations of x and y into the following matrix multiplication equation:
How to Multiply Two Matrix?
Remember the multiplication rule for Matrix A times B: dot product of the rows of A with the columns of B. Thus, if the Matrix dimension for A is rows1, cols1, and the Matrix B has dimension rows2, cols2, then cols1 = rows2.
For example:
In general for Matrix Multiplication.
Identity Matrix
Identity Matrix (IM) is the Matrix with all ones in the diagonals and zeros elsewhere. For example, the following is a 2×2 Identity Matrix:
With the above matrix multiplication rules, we know that: for Matrix A, where I is the identity matrix.
How to Get Inverse of Matrix?
The inverse of a Matrix A is denoted as such that: where I is the identity matrix.
We want to find out the x in matrix equation thus we can multiply the Inverse of Matrix in both sides:
which becomes and then
For a 2×2 Matrix:
The inverse for Matrix A is:
where is called the determinant for 2×2 Matrix.
Let’s practice above to solve the original equations:
Thus, for the original equations: the solutions are and
–EOF (The Ultimate Computing & Technology Blog) —
loading...
Last Post: Teaching Kids Programming - Pseudo-Palindromic Paths in a Binary Tree (Breadth First Search Algorithm, Iterative Preorder/Reversed Preorder)
Next Post: Teaching Kids Programming - Largest Substring Between Two Equal Characters (Hash Map)