Finding a particular solution
This work by Jephian Lin is licensed under a Creative Commons Attribution 4.0 International License.
$\newcommand{\trans}{^\top} \newcommand{\adj}{^{\rm adj}} \newcommand{\cof}{^{\rm cof}} \newcommand{\inp}[2]{\left\langle#1,#2\right\rangle} \newcommand{\dunion}{\mathbin{\dot\cup}} \newcommand{\bzero}{\mathbf{0}} \newcommand{\bone}{\mathbf{1}} \newcommand{\ba}{\mathbf{a}} \newcommand{\bb}{\mathbf{b}} \newcommand{\bc}{\mathbf{c}} \newcommand{\bd}{\mathbf{d}} \newcommand{\be}{\mathbf{e}} \newcommand{\bh}{\mathbf{h}} \newcommand{\bp}{\mathbf{p}} \newcommand{\bq}{\mathbf{q}} \newcommand{\br}{\mathbf{r}} \newcommand{\bx}{\mathbf{x}} \newcommand{\by}{\mathbf{y}} \newcommand{\bz}{\mathbf{z}} \newcommand{\bu}{\mathbf{u}} \newcommand{\bv}{\mathbf{v}} \newcommand{\bw}{\mathbf{w}} \newcommand{\tr}{\operatorname{tr}} \newcommand{\nul}{\operatorname{null}} \newcommand{\rank}{\operatorname{rank}} %\newcommand{\ker}{\operatorname{ker}} \newcommand{\range}{\operatorname{range}} \newcommand{\Col}{\operatorname{Col}} \newcommand{\Row}{\operatorname{Row}} \newcommand{\spec}{\operatorname{spec}} \newcommand{\vspan}{\operatorname{span}} \newcommand{\Vol}{\operatorname{Vol}} \newcommand{\sgn}{\operatorname{sgn}} \newcommand{\idmap}{\operatorname{id}} \newcommand{\am}{\operatorname{am}} \newcommand{\gm}{\operatorname{gm}} \newcommand{\mult}{\operatorname{mult}} \newcommand{\iner}{\operatorname{iner}}$
from lingeo import random_good_matrix
Let $A$ be an $m\times n$ matrix and $\bb$ a vector in $\mathbb{R}^n$.
Recall that the augmented matrix of $A\bx = \bb$ is the $m\times (n+1)$ matrix $\left[\begin{array}{c|c}A&\bb\end{array}\right]$.
We may perform row operations on $\left[\begin{array}{c|c}A&\bb\end{array}\right]$ to get its reduced echelon form $\left[\begin{array}{c|c}R&\br\end{array}\right]$.
The equation $R\bx = \br$ has a solution if and only if the $i$-th entry of $\br$ is zero whenever the $i$-th row of $R$ is zero.
Let $\bx = (x_1, \ldots, x_n)$.
The variables $x_i$ correponding to a pivot $i$ of $R$ are called leading variables.
The other variables are called free variables.
Suppose the $i$-th entry of $\br$ is zero whenever the $i$-th row of $R$ is zero.
One may set each free variable as an arbitrary number (e.g., all zeros).
Then there is a solution $\bx$ satisfying the setting.
Therefore, the following are equivalent:
On the other hand, if $R$ has no zero row, then $R\bx = \br$ has a solution regardless the choice of $\br$.
Therefore, the following are equivalent:
執行下方程式碼。
矩陣 $\left[\begin{array}{c|c}R&\br\end{array}\right]$ 是 $\left[\begin{array}{c|c}A&\bb\end{array}\right]$ 的最簡階梯形式矩陣。
考慮方程組 $A\bx = \bb$ 且 $\bx = (x_1,\ldots,x_5)$。
### code
set_random_seed(0)
print_ans = False
Ab, R, pivots = random_good_matrix(3,6,3, return_answer=True)
A = Ab[:,:5]
b = vector(Ab[:,5])
Ab = A.augment(b, subdivide=True)
Rr = Ab.rref()
print("[ A | b ] =")
show(Ab)
print("[ R | r ] =")
show(Rr)
if print_ans:
has_sol = False if 5 in pivots else True
leading = [i+1 for i in pivots if i != 5]
free = [i for i in range(1,6) if i not in leading]
print("Has a solution?", has_sol)
print("Leading variables are xi with i =", leading)
print("Free variables are xi with i =", free)
if has_sol:
x = vector([0]*5)
for i in range(3):
x[pivots[i]] = Rr[i,5]
print("By setting free variables as zeros, x =", x)
在 $x_1,\ldots,x_5$ 中,
哪些是領導變數、
哪些是自由變數?
方程式是否有解?
若有解﹐繼續前往下一題。
若無解﹐忽略以下題目。
將所有自由變數設成 $0$ 求解。
Find a solution by setting every free variable as $0$.隨意將自由變數設成任意數字求解。
Find a solution by setting the free variables as any numbers you like.以下類型的問題通稱為反問題,可以加深對數學概念的理解。
The following problems are examples of inverse problems. They help us to understand a mathematical notion better.找一個 $3\times 5$ 的最簡階梯形式矩陣,它的軸落在 $1,3,5$ 的位置。
Find a $3\times 5$ matrix such that it is in the reduced echelon form and its pivots are at $1$, $3$, and $5$.找一個 $3\times 5$ 的矩陣﹐
它的所有項皆不是零﹐
且它的最簡階梯形式的軸落在 $1,3,5$ 的位置。
給定一個矩陣 $A$,
依照以下步驟求出 $\bb\in\Col(A)$ 的等價條件。
執行下以程式碼。
令 $\bb = (b_1,b_2,b_3,b_4)$。
令 $A'$ 為 $A\bx = \bb$ 的增廣矩陣。
把 $\bb$ 的各項當作變數處理,經過列運算把 $A'$ 中的 $A$ 消成階梯形式矩陣。
如果左側有一列零向量,則右側對應到的項必須要是零才有解。
利用這個性質給出 $\bb\in\Col(A)$ 的等價條件。
### code
set_random_seed(0)
A = random_good_matrix(4,3,2)
var('b1 b2 b3 b4')
b = vector([b1, b2, b3, b4])
Ab = A.change_ring(SR).augment(b, subdivide=True)
print("A' =")
show(Ab)
### do something here to get the echelon form on the A side
# Ab.swap_rows(...)
# Ab.rescale_row(...)
# Ab.add_multiple_of_row(...)
print("After reduction:")
show(Ab)
上題找到的條件應該都是一些線性方程,
而每個線性方程式都對應到一個法向量,
找到一些向量 $\{\bu_1,\ldots,\bu_k\}$
(以這題的設定 $k = 2$ 就足夠)
使得以下敘述等價:
執行以下程式碼。
說明 $\Col(A) = \mathbb{R}^3$。
### code
set_random_seed(0)
A = random_good_matrix(3,5,3)
print("A =")
show(A)
若 $f(x) = c_0 + c_1 x + c_2 x^2$。
若 $f(1) = b_1$、
$f(2) = b_2$、
$f(3) = b_3$。
說明不論 $b_1$、$b_2$、$b_3$ 給的是多少﹐$c_0$、$c_1$、$c_2$ 都有解。
若 $f(x) = c_0 + c_1 x + c_2 x^2$。
若 $x_1$、$x_2$、$x_3$ 為三相異實數且
$f(x_1) = b_1$、
$f(x_2) = b_2$、
$f(x_3) = b_3$。
說明不論 $b_1$、$b_2$、$b_3$ 給的是多少﹐$c_0$、$c_1$、$c_2$ 都有解。