이 글은 Linear Algebra and Its Applications 책을 정리한 글입니다.
어떠한 inconsistent system of equation이 solution이 없을때 approximate solution을 구할 필요가있다. 이번 챕터에서는 orthogonality라는 성질을 통해 nearest point를 찾고 approximate solution을 찾을것 이다.
6.1 Inner product, length, and orthogonality
The Inner Product
위와같은 Rn 의 vector u,v가 있을때 우리는 이를 n×1 matrix로 간주할 수 있으며, tranpose인 uT를 1×n matrix이다. 또한 이들의 matrix product인 uTv 는 a single real number로 쓸 수 있는데 이를 Inner product라고 하며 uT⋅v 라고 쓸 수 있으며 이를 dot product라고 한다.
Theorem1
Let u,v,w be vector in Rn, and let c be scalar then,
u⋅v = v⋅u
(u+v)⋅w=u⋅w+v⋅w
(cu)⋅v=c(u+v)
u⋅u≥0 and u⋅u=0 if and only if u=0
The Length of a Vector
Definition
The length (or norm) of v in Rn is nonnegative scalar ∥v∥ defined by
∥cv∥=∥c∥∥v∥
unit vector →∥u∥ = 1
normalizationing →u=∥v∥1v
Distance in Rn
Definition
For u and v in Rn, the distance between u and v, written as dist(u,v), is the length of the vector u−v. That is dist(u,v) = ∥u−v∥
Example
두 vector u=(7,1), v=(3,2) 사이의 distance를 구하라.
아래 그림에서 나타나다시피 u와 v의 distance는 u−v 와 0 사이의 distance와 같다.
Example4
Orthogonal Vectors
위 그림에서 distance from u to v 이 distance from u to −v랑 같다묜 이는 geometrically perpendicular하며 이 둘은 squares of distance가 같다.
두 dist가 같을 조건은 2u⋅v = -2u⋅v 이므로 u⋅v=0
이 되어야한다.
Definition
-Two vectors u and v in Rn are orthogonal if u⋅v=0
추가로 zero vector는 Rn의 모든 vector에 대하여 orthogonal하다 (0T⋅v=0)
Theorem
Pythagoream Theorem
Two vector u,v are orthogonal if and only if ∥u+v∥2=∥u∥2+∥v∥2
Orthogonal Complement
vector z가 Rn의 subspace W에 모든 vector에 orthogonal하다면, z는 W에 orthogonal하다고 말한다. 또한 W에 orthogonal인 set of all vector z를 orthogonal complemnet of W 라고 하며 W⊥으로 표기한다.
위 그림처럼 W가 R3의 원점을 지나는 subspace인 평면이고 L이 W에 perendicular(직각)이며 원점을 지나는 직선이다. vector z가 W of R3의 모든 벡터에 orthogonal한다면 z는 orthogonal to W라고 부른다 (z⋅W = 0).
- ortogonal이 vector관의 관계 뿐 아니라 벡터와 subspace사이에서도 사용됨.
Example
vector y 가 vectors u and v에 orthogonal하다고 가정했을때. y 가 vector u+v에 orthogonal함을 보여라.
y⋅u=0y⋅v=0y⋅(u+v)=y⋅u+y⋅v
Example6~8
Theorem3
Let A be an n×n matrix. The orthogonal complement of the row space of A is the null space of A, and the orthogonal complement of the column space of A is the null space of A⊤ :
(RowA)⊥=NulAand(ColA)⊥=NulA⊤
6.2 Orthogonal Sets
A Set of vectors u1,…,up in Rn is said to be an orthogonal set if each pair of distinct vectors from the set is orthogonal, if ui⋅uj=0 whenever i=j
- 해당 set안의 임이의 두 vector가 orthogonal하아면 그 set은 orthogonal set이다는 소리.
Example
위 세 vector set이 orthogonal set인지 보여라.
각각의 vector들이 orthogonal함을 보였으니 이는 orthogonal set이며 아래 그림과 같다.
Theorem
If S = {u1,…,up} is an orthogonal set of nonzero vectors in Rn, then S is linearly independent and hence is a basis for the subspace spanned by S.
c1u1+⋯+cpup=0
위 식인 linear combination을 만족하는 c1 ~ cp가 0인 경우 linearly independent set임을 보일 수 있다.
위처럼 양변에 u1을 dot product 시키면 c1(u1⋅u1)=0 이 되고, 이때 u1⋅u1는 당연하게도 무조건 0이상이기에 c1=0이 된다.
∴c1=0,…,cp=0
Definition
Orthogonal Basis
An orthogonal basis for a subspace W of Rn is a basis for W that is also an orthogonal set.
Let {u1,…,up} be an orthogonal basis for a subspace W of Rn. For each y in W , the weights in the linear combination y=c1u1+⋯+cpup are given by cj=uj⋅ujy⋅uj.
이 전까지 weights를 찾으려면 augmented matrix를 row operation하여 solution을 찾았는데 orthogonal basis이면 위처럼 명시적으로 주어진다.
위 식에서 orthogonal set이기에 u1 끼리의 dot product빼고는 전부 0이 된다.
∴c1=u1⋅u1y⋅u1
Example
set S = {u1,u2,u3}이 위와 같고, orthogonal basis for R3일때 vector y = (6,1,-8)를 orthogoanl basis로 표현해보자.
간단하게 위 이론에서처럼 계산해보면 위와같다.
Orthogonal Projection
nonzero vector u in Rn이 주어졌고 vector y in Rn 을 두 벡터로 decomposing해보면 아래처럼 나타낼 수 있고,
y=y^+z
some scalar α에 y^=αu 이고 z 가 u에 orthogonal 할때 z=y−αu라면 위 식을 만족한다.
이때 y−y^ 이 u에 orthogonal하다면, 0=(y−αu)⋅u=y⋅u−(αu)⋅u=y⋅u−α(u⋅u) 가 되며 이때, α=u⋅uy⋅u 이고 y^=u⋅uy⋅uu 이 된다.
이때 vector y^ 는 orthogonal projection of y onto u 로 부르며, vector z를 component of y orthogonal to u 라고 하며 vector를 subspace L ( span{u} )로 확장하면 다음과같이 나타낼 수 있다.
* 위 내용은 어떤 vector가 있을 때 어떤 다른 vector 혹은 그 vector의 span에다 orthogonal projection이 어떤식으로 정의되는지를 보여준 것이다.
Example
아래 두 vector가 주어졌을때 orthogonal projection of y onto u를 찾고 y 를 두 orthogonal vector의 합으로 나타내라 (하나는 in Span{y}, 다른 하나는 orthogonal to u)
orthogonal projection of y onto u 인 y^ 를 구하기위해 계산하면 다음과같고,
component of y orthogonal to u (orthogonal to u) 를 구하면 다음과 같다.
y 를 두 벡터로 나타내면 다음과같다.
이를 그림으로 나타내면 다음과 같다.
Orthonomal sets
A Set {u1,…,up} is an orthonormal set if it is an orthogonal set of unit vectors.
- 다시 언급하면 unit vector는 vector의 norm(length)이 1인 vector
Theorem
An m×n matrix U has orthonormal columns if and only if U⊤U=I
U⊤U 를 위와같이 전개하여 보면 diagonal term들이 전부 1이고 나머지 entry가 0이면 U는 orthonomal columns를 갖는단 소리.
Theorme
Let U be an m×n matrix with orthonormal columns, and let x and y be in Rn. Then
a. ∥Ux∥=∥x∥
b. (Ux)⋅(Uy)=x⋅y
c. (Ux)⋅(Uy)=0 if and only if x⋅y=0
6.3 Orthogonal Projection
vector y와 subspace W in Rn 이며 y−y^ 이 W에 orthogonal할때 unique vector y^ 가 있다. 이는 후에 다룰 least-squares solution에서 중요하게 다뤄진다.
vector y 는 vectors u1,…,un 의 linear combination으로 나타내었을 때 y 는 y=z1+z2 처럼 두개의 그룹으로 나타낼 수 있는데 이때 z1 은 linear combination의 일부이며 z2는 linear combination의 나머지이다. 이는 {u1,…,un} 가 orthogoanl basis( W⊥ ) 일때 유용하게 사용된다.
Example
{u1,…,u5} 가 R5 의 orthogonal basis이며 y=c1u1+⋯+c5u5 이고 subspace W = Span{u1,u2} 이라고 하였을때 y 는 vector z1 in W와 vector z2 in W⊥ 로 아래와같이 나타낼 수 있다.
z2 in W⊥ 을 보이기 위해선 z2 가 basis {u1,u2} for W의 vector에 대해 orthogonal함을 보이면 된다.
Theorme
Let W be a subspace of Rn. Then each y in Rn can be written uniquely in the form y=y^+z, where y^ is in W and z is in W⊥. In fact, if {u1,…,up} is any orthogonal basis of W, then y^=u1⋅u1y⋅u1u1+⋯+up⋅upy⋅upup and z=y−y^.
The vector y^ 는 orthogonal projection of y onto W 라고 하며 projwy로 나타내며 아래의 그림과같다.
- 이는 이전에 보았던 orthogonal projection of y onto L 을 subspace로 확장한것.
Example
아래와 같이 vector가 주어졌고 {u1,u2} 가 orthogoanl basis for W = Span{u1,u2} 일때 y 를 W의 vector와 W에 orthogonal한 vector의 합으로 나타내라.
theorme에 따라 y^ 을 구하고 y−y^ 을 구하면 다음과 같고
y를 두 vector의 합으로 decompose시키면 다음과 같다.
A Geometric Interpretation of the Orthogonal Projection
이번엔 이전까지 보았던 R2 space를 확장해 R3 space상에서 시각적으로 살펴본다.
R3 space의 임의의 vector y를 Span{u1,u2} 평면에 orthogonal projection 시켜보자.
위 그림처럼 y^는 u1⋅u1y⋅u1u1+u2⋅u2y⋅u2u2로 정의에서처럼 명시할 수 있고 이때 각각의 component는 y^1, y^2 로 나누어지며 이 y^1, y^2는 결국 orthogonal basis의 각 벡터 (u1,u2) 가 span 하는 Line에 orthogonal projection 시킨 것 이다.
Theorme - The best approximation theorem
Let W be a subspace of Rn, y any vector in Rn, and y^ be the orthogonal projection of y onto W. Then y^ is the colset point W to y, in the sense that ∥y−y^∥<∥y−v∥ for all v in W distinct from y^.
length 측면으로 보았을때 y 와 y^간의 차이가 W에 어떤 vector v와의 차보다 작다는 뜻으로 아래 그림을 보고 이해할 수 있다.
Example
아래와 같이 vector u1,u2,y 가 주어지고 W가 Span{u1,u2} 이고 y가 nearest point to W라고 하였을 때 distance from y to W 를 구해라.
∥y−y^∥ 를 구하기 위해 y^를 구하면 다음과 같고
distance를 구하면 다음과같다.
∴ distance from y to W = 35
Theorme
일단 u1 ~ up 가 orthonomal basis이기에 projWy 에서 각 vector의 coefficient의 분모가 unit vector끼리의 dot product이니 1이되어 위 (4)식으로 나타낼 수 있다.
또한 projWy = UU⊤y 로 쓸 수있는데 이는 (4)번 식을 dot product 정의에 의해 (u1⊤y)u1 로 나타낼 수 있고 이를 matrix로 정리하여 y를 바깥으로 빼내면 UU⊤y로 나타낼 수 있다.
6.4 The Gram-Schmidt Process
이전까진 subspace를 이루는 orthogonal basis가 주어졌을 때 를 가정하였지만 이번 챕터는 gram-schmidt 라는 방법을 통해 orthogonal basis를 구하는 방법을 볼 것이다.
vector {v1,v2}를 subspace W = Span{v1,v2}의 basis라고 가정하자
- Span{v1,v2}의 basis가 orthogonal하다는 말이 없으니 orthogonal set이 아니라 그냥 linearly independent set이다.
이때 subspace W를 이루는 orthogonal basis를 찾아보자.
v1을 u1이라고 하고 v2를 u1에 projection 시켜 v^2 (proju1v2)를 구한 후 u2 를 v2−v^2 로 나타낼 수 있다.
이때 u2=v2−v^2=v2−v1⋅v1v2⋅v1v1 의 linear combination 형태로 나타날수 있으므로 u2는 subspace W에 있다는 것을 알수 있다.
u1, u2가 W에 있음을 보였고 orthogonal하게 만들었으니 u1은 당연히 nonzero이고 u2가 nonzero임을 보여 linearly independent 함을 보여야한다 (u1과 u2가 orthogonal set이기에 nonzero이면 당연히 independent하다) .
만일 u2가 nonzero가 아니라면 v2 와 v^2이 같다는 것인데 이는 v2가 Span{v1} 에 있다는 뜻이므로 둘은 dependent set이되고 이는 처음 정의에 의해 v1과 v2 가 subspace의 basis이니 성립이되지 않아 둘은 linearly independent하다.
∴ W = Span{u1,u2} = Span{v1,v2}
R3 space의 orthogonal basis를 찾는것도 똑같다.
벡터 이름이 바뀌어 햇갈리지만 이번엔 basis를 이루는 또다른 주어진 벡터 x3를 R2 space 에서 구한 평면 W (위 그림에선 W2) 에 projection시켜 v3를 찾으면 된다.
그 다음엔 v3=x3−x^3을 구하면 되는데 x^3는 이 전 챕터에서 한 것 처럼 v1과 v2에 projection시켜주면 된다.
Theorem - The Gram-Schmidt Process
위 내용처럼 Rn space의 subspace W의 basis로 하나씩 projection시켜주며 vp 까지 구하여 W의 orthogonal basis를 찾을 수 있다.
또한 v1 ~ vp까지를 구할때 vk는 v1 ~ vk−1과 xk의 linear combination으로 나타낼수 있었고 이를통해 Span{v1,…,vk} = Span{x1,…,xk} 임을 알 수 있다.
Orthonormal basis
Orthonomal basis는 말 그대로 orthogonal basis에서 각각의 vector들의 norm을 1로 만들어 normalize 시킨 것 이다.
QR Factorization of Matrices
Theorme - The QR Factorization
If A is an m×n matrix with linearly independent columns, then A can be factored as A = QR, where Q is an m×n matrix whose columns form an orthonormal basis for Col A and R is an n×n upper triangular invertible matrix with positive entries on its diagonal.
m×n matrix A가 linearly independent coulmns를 갖고있다 했으니 이는 A = [x1x2…xn]으로 나타낼 수 있고 이때의 Col A 의 basis는 {x1,…,xn}가 되며 이를 Gram-Schmidt를 통해 구한 Col A의 orthonormal basis를 {u1,…,un} 이라고 하자.
이때 Col A의 orthonormal basis를 columns 으로 둔 matrix 를 Q라 하고 다음과같이 나타낼수 있다 Q = [u1u2…un].
이전에 배웠던 것처럼 xk = u1,…,uk으로 나타낸 linear combination 임을 알 수 있고 x가 n까지 나타날수 있으니 아래 식처럼 나타낼 수 있다.
이때 vector rk를 아래와같이 나타낼 수 있으며,
이는 xk = Qrk 식으로 나타낼 수 있고 이를통해 아래와 같이 유도된다.
이때 A의 column들이 linealy independent하니 R은 invertible matrix가 되며 이는 n개의 pivot을 갖는단 소리고 이는 R의 diagonal term들이 nonzero가 되어 아래 그림처럼 upper triangular matrix가 된다.
또한 (−rkk)(−uk) 처럼 unit vector에 방향을 바꿔주어 R의 diagonal term을 nonnegative하게 만들 수 있다.
또한 이전에 보았던 U⊤U=I 이론을 통해 Q⊤A=Q⊤(QR)=R 과 같이 A에 Q⊤를 multiplication해주어 R을 찾을 수 있다.