Skip to content

Commit

Permalink
matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
CAIMEOX committed Jun 9, 2024
1 parent 296b5ab commit 2128448
Show file tree
Hide file tree
Showing 11 changed files with 217 additions and 10 deletions.
17 changes: 8 additions & 9 deletions theme/javascript-source/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ function code_render(obj) {
code_render(obj[key]);
}
if (key === "html:code") {
if (obj['html:code'].length === 0) return;
const code = obj['html:code'][0]["#text"];
if (obj["html:code"].length === 0) return;
const code = obj["html:code"][0]["#text"];
const lines = code.split("\n");
let i = 0;
let res = ''
while (code[i] === ' ') {
i++;
}
let res = "";
while (code[i] === " ") i++;
for (let j = 0; j < lines.length; j++) {
res += lines[j].replace(' '.repeat(i), '') + '\n'
res += lines[j].replace(" ".repeat(i), "") + "\n";
}
obj['html:code'][0]['#text'] = res.trim()

obj["html:code"][0]['#text'] = res.trim()
}
}
}
Expand Down Expand Up @@ -52,4 +51,4 @@ async function start() {
}
}

start();
start();
13 changes: 13 additions & 0 deletions trees/def/def-0043.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\title{Transpose}
\taxon{Definition}
\p{
The \strong{transpose} of a matrix #{A}, denoted by #{A^T} is
the matrix obtained by swapping the rows and columns of #{A}.
It satisfies the following properties:
\ul{
\li{#{(A^T)^T = A}}
\li{#{(A + B)^T = A^T + B^T}}
\li{#{(cA)^T = cA^T}}
\li{#{(AB)^T = B^TA^T}}
}
}
11 changes: 11 additions & 0 deletions trees/def/def-0044.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
\title{Determinant}
\taxon{Definition}
\p{
The determinant of a #{n\times n} square matrix #{A} is commonly denoted #{\det A} or #{|A|}.
It satisfies the following properties:
\ul{
\li{#{\det A^T = \det A} }
\li{#{\det AB = \det A \det B}}
\li{#{\det \lambda A = \lambda^n \det A}}
}
}
9 changes: 9 additions & 0 deletions trees/def/def-0045.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
\title{First Minor and Cofactor}
\taxon{Definition}
\p{
If #{A} is a square matrix, then the \strong{minor} of the entry in the i-th row and j-th
column (also called the #{(i, j)} minor, or a first minor) is the \strong{determinant} of
the sub-matrix formed by deleting the i-th row and j-th column.
The #{(i, j)} minor is denoted as #{M_{ij}}.
The \strong{Cofactor} is obtained by multiplying the minor by #{(-1)^{i+j}}.
}
17 changes: 17 additions & 0 deletions trees/def/def-0046.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
\title{Cofactor Matrix}
\taxon{Definition}
\p{
The matrix formed by all of the [cofactors](def-0045) of a square matrix #{A} is called the cofactor matrix,
or \strong{comatrix}:
##{
C = \left[
\begin{array}{cccc}
C_{11} & C_{12} & \cdots & C_{1n} \\
C_{21} & C_{22} & \cdots & C_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
C_{n1} & C_{n2} & \cdots & C_{nn}
\end{array}
\right]
}
The \strong{Adjugate matrix} of #{A} is the transpose of the cofactor matrix.
}
5 changes: 5 additions & 0 deletions trees/def/def-0047.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
\title{Singular Matrix}
\taxon{Definition}
\p{
A square matrix that is not \strong{invertible} is called \strong{singular} or degenerate
}
10 changes: 10 additions & 0 deletions trees/def/def-0048.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
\title{Matrix Polynomial}
\taxon{Definition}
\p{
A \strong{matrix polynomial} is a polynomial with square matrices as variables.
The general form of a matrix polynomial is:
##{
P(A) = \sum_{i=0}^{n} a_i A^i
}
where #{A^0 = I} is the identity matrix.
}
19 changes: 19 additions & 0 deletions trees/def/def-0049.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
\title{Matrix Partitioning}
\taxon{Definition}
\import{macros}
\p{
Let #{A \in \C^{m\times n} }. A \strong{partitioning} of #{A} is a representation of #{A} in the form
##{
A = \begin{bmatrix}
A_{11} & A_{12} & \cdots & A_{1q} \\
A_{21} & A_{22} & \cdots & A_{2q} \\
\vdots & \vdots & \ddots & \vdots \\
A_{p1} & A_{p2} & \cdots & A_{pq}
\end{bmatrix}
}
where #{A_{ij} \in \C^{m_i \times n_j} } for #{1 \leq i \leq p} and #{1 \leq j \leq q} such that
##{
\sum_{i=1}^p m_i = m \quad \text{and} \quad \sum_{j=1}^q n_j = n.
}
The partitioned matrix operations are similar to the operations on the normal matrix.
}
106 changes: 106 additions & 0 deletions trees/math/math-0008.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
\title{Matrix}
\taxon{Linear Algebra}
\import{macros}
\p{
This post shows operations and applications over matrix.
}
\transclude{def-0043}
\p{
If the following condition satisfies:
##{
a_{ij} = a_{ji} \quad \forall i,j
}
Then the matrix is called symmetric.
}
\transclude{def-001N}
\transclude{def-0044}
\p{
To compute the inverse of a matrix, we need \strong{Adjugate matrix}.
}
\transclude{def-0045}
\transclude{def-0046}
\p{
Then the inverse of #{A} is the transpose of the cofactor matrix times the reciprocal of the determinant of #{A}:
##{
A^{-1} = \frac{1}{\det A} \cdot \text{adj} A = \frac{1}{\det A} \cdot C^T
}
}
\transclude{def-0047}
\subtree{
\title{An important property of the inverse of a matrix}
\p{
##{
A \cdot \text{adj} A = \text{adj} A \cdot A = \det A \cdot I
}
}
\proof{
Let #{A \cdot \text{adj} A = (b_{ij})} and we have
##{
b_{ij} = a_{i1}A_{j1} + a_{i2}A_{j2} + \cdots + a_{in}A_{jn} = \delta_{ij} \cdot \det A
}
Hence we have #{A \cdot \text{adj} A = \det A \cdot I}
}
}
\subtree{
\title{Matrix Polynomial and Computation}
\transclude{def-0048}
\p{
If #{A} is a diagonal matrix, then the polynomial of #{A} is the diagonal matrix of the polynomial of the diagonal elements of #{A}.
##{
p(A) = \begin{bmatrix}
p(a_{11}) & 0 & \cdots & 0 \\
0 & p(a_{22}) & \cdots & 0 \\
\vdots & \vdots & \ddots & \vdots \\
0 & 0 & \cdots & p(a_{nn})
\end{bmatrix}
}
}
\p{
If #{A = P\Lambda P^{-1}}, then #{A^k = P \Lambda ^k P^{-1}} and hence
##{
p(A) = a_0 I + a_1 A + a_2 A^2 + \cdots + a_n A^n = P \Lambda P^{-1}
}
}
}
\subtree{
\title{Solving a Linear System}
\transclude{thm-0011}
\p{
Matrix partitioning is the process of dividing a matrix into smaller submatrices.
This is often done to simplify the computation of matrix operations, such as matrix multiplication.
}
\transclude{def-0049}
\p{
If the partitioned matrix is formed as diagonal blocks, then we can compute the determinant of the matrix by the following formula:
##{
\det A = \det A_1 \cdot \det A_2 \cdots \det A_n
}
And the inverse of the matrix is
##{
A^{-1} = \begin{bmatrix}
A_1^{-1} & O & \cdots & O \\
O & A_2^{-1} & \cdots & O \\
\vdots & \vdots & \ddots & \vdots \\
O & O & \cdots & A_n^{-1}
\end{bmatrix}
}
}
\p{
The column partitioning of matrix is useful.
If we have #{m\times s} matrix #{A = (a_{ij})} and #{s\times n} matrix #{B=(b_{ij})},
their product can be written:
##{
AB = \begin{bmatrix} A_1 \\ A_2 \\ \vdots A_m \end{bmatrix}
\begin{bmatrix}
B_1 & B_2 & \cdots & B_n
\end{bmatrix} =
\begin{bmatrix}
A_1B_1 & A_1B_2 & \cdots & A_1B_n \\
A_2B_1 & A_2B_2 & \cdots & A_2B_n \\
\vdots & \vdots & \ddots & \vdots \\
A_mB_1 & A_mB_2 & \cdots & A_mB_n
\end{bmatrix}
}
We can show that #{A=O\iff A^TA=O}.
}
}
3 changes: 2 additions & 1 deletion trees/notes.tree
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
\transclude{cs-0005}
\transclude{cs-0006}
\transclude{cs-0007}
\transclude{math-0007}
\transclude{math-0007}
\transclude{math-0008}
17 changes: 17 additions & 0 deletions trees/thm/thm-0011.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
\title{Cramer's rule}
\taxon{Theorem}
\p{
Consider a system of #{n} linear equations for #{n} unknowns, represented in matrix multiplication form as follows:
##{
A \cdot X = B
}
where #{A} is a square matrix of order #{n}, #{X} is a column matrix of order #{n} and #{B} is a column matrix of order #{n}.
##{
X = \begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n \end{bmatrix}
}
The Cramer's rule states that the solution to the system of equations is given by:
##{
x_i = \frac{\text{det}(A_i)}{\text{det}(A)}
}
where #{A_i} is the matrix obtained by replacing the #{i}th column of #{A} by #{B}.
}

0 comments on commit 2128448

Please sign in to comment.