zoukankan      html  css  js  c++  java
  • A.Kaw矩阵代数初步学习笔记 3. Binary Matrix Operations

    “矩阵代数初步”(Introduction to MATRIX ALGEBRA)课程由Prof. A.K.Kaw(University of South Florida)设计并讲授。
    PDF格式学习笔记下载(Academia.edu)
    第3章课程讲义下载(PDF)

    Summary

    • Addition of matrices
      Two matrices $[A]$ and $[B]$ can be added only if they are the same size. The addition is then shown as $$[C]=[A]+[B]$$ where $$c_{ij}=a_{ij} + b_{ij}$$ For example $$egin{bmatrix}5& 2& 3\ 1& 2& 7end{bmatrix} + egin{bmatrix}6& 7& -2\ 3& 5& 19end{bmatrix}$$ $$= egin{bmatrix}5 + 6& 2 + 7& 3 - 2\ 1 + 3& 2 + 5& 7 + 19end{bmatrix} = egin{bmatrix}11& 9& 1\ 4& 7& 26end{bmatrix}$$
    • Subtraction of matrices Two matrices $[A]$ and $[B]$ can be subtracted only if they are the same size. The subtraction is then given by $$[D] = [A]-[B]$$ where $$d_{ij}=a_{ij} - b_{ij}$$ For example $$egin{bmatrix}5& 2& 3\ 1& 2& 7end{bmatrix} - egin{bmatrix}6& 7& -2\ 3& 5& 19end{bmatrix}$$ $$= egin{bmatrix}5 - 6& 2 - 7& 3 -(-2)\ 1 - 3& 2 - 5& 7 - 19end{bmatrix} = egin{bmatrix}-1& -5& 5\ -2& -3& -12end{bmatrix}$$
    • Multiplication of matrices
      Two matrices $[A]$ and $[B]$ can be multiplied only if the number of columns of $[A]$ is equal to the number of rows of $[B]$ to give $$[C]_{m imes n}=[A]_{m imes p}cdot[B]_{p imes n}$$ where $$c_{ij}=a_{i1}b_{1j}+a_{i2}b_{2j}+cdots+a_{ip}b_{pj}= sum_{k=1}^{p}a_{ik}b_{kj}$$ for each $i=1, cdots, m$ and $j=1, cdots, n$. That is, the $i$-th row and the $j$-th column of $[C]$ is calculated by multiplying the $i$-th row of $[A]$ by the $j$-th column of $[B]$: $$c_{ij}=egin{bmatrix}a_{i1} & a_{i2}& cdots & a_{ip}end{bmatrix}cdot egin{bmatrix}b_{1j}\ b_{2j}\ vdots\ b_{pj}end{bmatrix}$$ For example, $$A=egin{bmatrix}5& 2& 3\ 1& 2& 7end{bmatrix}, B=egin{bmatrix}3& -2\ 5& -8\ 9& -10end{bmatrix}, C=Acdot B$$ we have $$c_{11}=egin{bmatrix}5& 2& 3end{bmatrix}cdot egin{bmatrix}3\ 5\ 9end{bmatrix}=15+10+27=52, c_{12}=egin{bmatrix}5& 2& 3end{bmatrix}cdot egin{bmatrix}-2\ -8\ -10end{bmatrix}=-10 -16 -30 = -56,$$ $$c_{21}=egin{bmatrix}1& 2& 7end{bmatrix}cdot egin{bmatrix}3\ 5\ 9end{bmatrix}=3+10+63=76, c_{22}=egin{bmatrix}1& 2& 7end{bmatrix}cdot egin{bmatrix}-2\ -8\ -10end{bmatrix}=-2-16-70=-88,$$ $$Rightarrow C=egin{bmatrix}52& -56\ 76& -88end{bmatrix}.$$
    • Scalar product of matrices
      If $[A]$ is a $m imes n$ matrix and $k$ is a real number, then the multiplication $[A]$ by a scalar $k$ is another $m imes n$ matrix $[B]$, where $b_{ij}=ka_{ij}$ for all $i$, $j$. For example, $$2cdotegin{bmatrix}5& 2& 3\ 1& 2& 7end{bmatrix} = egin{bmatrix}10& 4& 6\ 2& 4& 14end{bmatrix}$$
    • Linear combination of matrices
      If $[A_1]$, $[A_2]$, $cdots$, $[A_{p}]$ are matrices of the same size and $k_1$, $k_2$, $cdots$, $k_p$ are scalars, then $$k_1A_1 + k_2A_2 + cdots + k_pA_p$$ is called a linear combination of $[A_1]$, $[A_2]$, $cdots$, $[A_{p}]$.
    • Rules of binary matrix operation
      • Commutative law of addition
        If $[A]$ and $[B]$ are $m imes n$ matrices, then $$[A]+[B] = [B] + [A]$$
      • Associative law of addition
        If $[A]$, $[B]$, and $[C]$ are all $m imes n$ matrices, then $$[A]+([B] + [C]) = ([A] + [B]) + [C]$$
      • Associate law of multiplication
        If $[A]$, $[B]$, and $[C]$ are $m imes n$, $n imes p$, and $p imes r$ size matrices. respectively. Then $$[A]cdot([B]cdot[C]) = ([A]cdot[B])cdot[C]$$ and the resulting matrix size on both sides of the equation is $m imes r$.
      • Distributive law
        If $[A]$ and $[B]$ are $m imes n$ size matrices, and $[C]$ and $[D]$ are $n imes p$ size matrices, then $$[A]cdot([C] + [D]) = [A]cdot[C] + [A]cdot[D]$$ $$([A] + [B])cdot[C] = [A]cdot[C] + [B]cdot[C]$$ and the resulting matrix size on both sides of the equation is $m imes p$.

    Selected Problems

    1. For the following matrices $$A=egin{bmatrix}3& 0\ -1& 2\ 1& 1end{bmatrix}, B=egin{bmatrix}4& -1\ 0& 2end{bmatrix}, C=egin{bmatrix}5& 2\ 3& 5\ 6& 7end{bmatrix}.$$ Find where possible $4[A] + 5[C]$, $[A]cdot[B]$, $[A]-2[C]$.
    Solution:
    $$4[A] + 5[C] = egin{bmatrix}12& 0\ -4& 8\ 4& 4end{bmatrix} + egin{bmatrix}25& 10\ 15& 25\ 30& 35end{bmatrix} = egin{bmatrix}37& 10\ 11& 33\ 34& 39end{bmatrix}$$ $$[A] cdot [B] = egin{bmatrix}12& -3\ -4& 5\ 4& 1end{bmatrix}$$ $$[A]-2[C] = egin{bmatrix}3& 0\ -1& 2\ 1& 1end{bmatrix} - egin{bmatrix}10& 4\ 6& 10\ 12& 14end{bmatrix} = egin{bmatrix}-7& -4\ -7& -8\ -11& -13end{bmatrix}$$

    2. Food orders are taken from two engineering departments for a takeout. The order is tabulated in Table 1.

    However they have a choice of buying this food from three different restaurants. Their prices for the three food items are tabulated in Table 2.

    Show how much each department will pay for their order at each restaurant. Which restaurant would be more economical to order from for each department?
    Solution:
    Denote the food order and price matrices as $$[A]=egin{bmatrix}25& 35& 25\ 21& 20& 21end{bmatrix}, [B]=egin{bmatrix}2.42 & 2.38 & 2.46\ 0.93 & 0.90 & 0.89\ 0.95 & 1.03 & 1.13 end{bmatrix}$$ The total fees matrix $[C]$ is the product of $[A]$ and $[B]$: $$[C]=[A]cdot [B] = egin{bmatrix}116.8 & 116.75 & 120.9\ 89.37 & 89.61 & 93.19end{bmatrix}$$ Covert it using tabular is shown in Table 3.

    Thus, Burcholestrol is the cheapest for the Mechanocal department, which is 116.75. And MacFat is the cheapest for the Civil department, which is 89.37.

    3. Given $$[A] = egin{bmatrix}2& 3& 5\ 6& 7& 9\ 2& 1& 3end{bmatrix}, [B]= egin{bmatrix}3& 5\ 2& 9\ 1& 6end{bmatrix} , [C]= egin{bmatrix}5& 2\ 3& 9\ 7& 6end{bmatrix}.$$ Illustrate the distributive law of binary matrix operations: $$[A]cdot([B]+[C]) = [A]cdot[B] + [A]cdot[C]$$
    Solution: $$[B]+[C] = egin{bmatrix}8& 7\ 5& 18\ 8& 12end{bmatrix}, [A]cdot([B]+[C]) = egin{bmatrix}71& 128\ 155& 276\ 45& 68end{bmatrix}$$ $$[A]cdot [B]=egin{bmatrix}17& 67\ 41& 147\ 11& 37end{bmatrix}, [A]cdot [C] = egin{bmatrix}54& 61\ 114& 129\ 34& 31end{bmatrix}\, [A]cdot [B]+[A]cdot [C]= egin{bmatrix}71& 128\ 155& 276\ 45& 68end{bmatrix}$$ Thus $$[A]cdot([B]+[C]) = [A]cdot[B] + [A]cdot[C]$$

    4. Let $[I]$ be a $n imes n$ identity matrix. Show that $[A]cdot[I] = [I]cdot[A]=[A]$ for every $n imes n$ matrix $[A]$.
    Solution:
    Let $[C]_{n imes n}=[A]_{n imes n}cdot[I]_{n imes n}$. So we have $$c_{ij}=a_{i1}i_{1j} + cdots + a_{i, j-1}i_{j-1, j} + a_{ij}i_{jj} + a_{i, j+1}i_{j+1, j}+cdots + a_{in}i_{nj} = sum_{p=1}^{n} a_{ip}i_{pj}$$ for each of $i=1, cdots, n$ and $j=1, cdots, n$. Since $$i_{ij}=egin{cases}0 & i eq j \ 1 & i=jend{cases}$$ Thus $$c_{ij} = sum_{p=1}^{n} a_{ip}i_{pj} = a_{ij}i_{jj} = a_{ij}$$ That is, $[A]cdot[I] = [A]$. Similarly, denote $[D]_{n imes n}=[I]_{n imes n}cdot [A]_{n imes n}$, and $$d_{ij}=i_{i1}a_{1j} + cdots + i_{i, i-1}a_{i-1, j} + i_{ii}a_{ij} + i_{i, i+1}a_{i+1, j}+cdots + i_{in}a_{nj} = sum_{p=1}^{n} i_{ip}a_{pj}$$ Because $i_{ij}=1$ when $i=j$, otherwise $i_{ij}=0$. Thus, $$d_{ij}= sum_{p=1}^{n} i_{ip}a_{pj} = a_{ij}$$ That is, $[I]cdot[A]=[A]$.

    5. Consider there are only two computer companies in a country. The companies are named Dude and Imac. Each year, company Dude keeps ${1/5}^{th}$ of its customers, while the rest switch to Imac. Each year, Imac keeps ${1/3}^{rd}$ of its customers, while the rest switch to Dude. If in 2002, Dude has ${1/6}^{th}$ of the market and Imac has ${5/6}^{th}$ of the market.
    (A) What is the distribution of the customers between the two companies in 2003? Write the answer first as multiplication of two matrices.
    (B) What would be distribution when the market becomes stable?
    Solution:
    (A) Denote $D_n$ and $M_n$ as the market share of Dude and Imac in the $n$-th year, respectively. $$egin{bmatrix}D_n \ M_n end{bmatrix} = egin{bmatrix}{1over5} & {2over3} \ {4over5} & {1over3}end{bmatrix}cdot egin{bmatrix}D_{n-1} \ M_{n-1} end{bmatrix}$$ Thus $$egin{bmatrix}D_{2003} \ M_{2003} end{bmatrix} = egin{bmatrix}{1over5} & {2over3} \ {4over5} & {1over3}end{bmatrix}cdot egin{bmatrix}D_{2002} \ M_{2002} end{bmatrix} = egin{bmatrix}{1over5} & {2over3} \ {4over5} & {1over3}end{bmatrix}cdot egin{bmatrix}{1over6} \ {5over6} end{bmatrix}= egin{bmatrix}{53over90} \ {37over90} end{bmatrix}$$
    (B) The stable system means the market share will not be changed from year to year, that is, $$egin{cases}D = {1over5}D+{2over3}M \ M = {4over5}D + {1over3}Mend{cases}Rightarrow {4over5}D-{2over3}M=0$$ On the other hand, $D + M =1$, thus we have $$egin{cases}{4over5}D-{2over3}M=0\ D + M =1end{cases}Rightarrowegin{cases}D={5over11}\ M={6over11}end{cases}$$ Hence the stable market share of Dude and Imac is ${5over11}$ and ${6over11}$, respectively.

    6. Given $$[A]=egin{bmatrix}12.3& -12.3& 10.3\ 11.3& -10.3& -11.3\ 10.3& -11.3& -12.3end{bmatrix}, [B]=egin{bmatrix}2& 4\ -5& 6\ 11& -20end{bmatrix}$$ if $[C] = [A]cdot[B]$, then what is $c_{31}$?
    Solution:
    $$c_{31} = egin{bmatrix}10.3& -11.3& -12.3end{bmatrix} cdot egin{bmatrix}2\-5\11end{bmatrix} = 10.3 imes2+11.3 imes5-12.3 imes11 = -58.2$$

    7. $[A]$ and $[B]$ are square matrices of $n imes n$ order. Then $([A] - [B])([A] - [B])$ is equal to ( ).
    Solution:
    $$([A]-[B])([A]-[B]) = [A]([A]-[B])-[B]([A]-[B])=[A]^2-[A][B]-[B][A]+[B]^2$$ Note that $[A][B]$ and $[B][A]$ is not equal to each other unless $[A][B]=[B][A]$.

    8. Given $[A]$ is a rectangular matrix and $c[A]=0$, then what are the values of $c$ and $[A]$?
    Solution:
    $c[A]=0Rightarrow c=0$ or $[A]=[0]$.

    9. You sell Jupiter and Fickers Candy bars. The sales in January are 25 and 30 of Jupiter and Fickers, respectively. In February, the sales are 75 and 35 of Jupiter and Fickers, respectively. If a Jupiter bar costs 2 dollars and a Fickers bar costs 7 dollars, then what is the total sales amount in each month?
    Solution:
    $$egin{bmatrix}25& 30\ 75& 35end{bmatrix}cdotegin{bmatrix} 2 \ 7 end{bmatrix} =egin{bmatrix} 260 \ 395 end{bmatrix} $$ Thus, the total sales amount in January and February are 260 dollars and 395 dollars, respectively.


    作者:赵胤
    出处:http://www.cnblogs.com/zhaoyin/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    三栏布局
    两栏布局
    WEB前端开发笔试题(1)
    JavaScript document 对象
    设计一个有3个超链接的页面,单击这些链接时分别打开和关闭窗口以及关闭本身窗口。
    在窗体中有两个多选列表,用户可以从左侧列表中选择任意项,添加到右侧列表中。反之亦然。
    How and when: ridge regression with glmnet
    Fitting Bayesian Linear Mixed Models for continuous and binary data using Stan: A quick tutorial
    An Introduction to Stock Market Data Analysis with R (Part 1)
    Lesser known purrr tricks
  • 原文地址:https://www.cnblogs.com/zhaoyin/p/4136441.html
Copyright © 2011-2022 走看看