西电线性代数matlab上机报告On2021.6.14
作者:互联网
线性代数matlab上机
本文目的:
1. LaTeX \LaTeX LATEX数学公式练习
2. m a t l a b matlab matlab语法练习
3.线性代数复习
一.机算题
1.随机方阵的生成与基本运算
构造五阶随机方阵:
>> A=rand(5)
A =
0.6797 0.9597 0.2551 0.5472 0.2543
0.6551 0.3404 0.5060 0.1386 0.8143
0.1626 0.5853 0.6991 0.1493 0.2435
0.1190 0.2238 0.8909 0.2575 0.9293
0.4984 0.7513 0.9593 0.8407 0.3500
>> B=rand(5)
B =
0.1966 0.8308 0.7572 0.0540 0.5688
0.2511 0.5853 0.7537 0.5308 0.4694
0.6160 0.5497 0.3804 0.7792 0.0119
0.4733 0.9172 0.5678 0.9340 0.3371
0.3517 0.2858 0.0759 0.1299 0.1622
(1)计算 A + B , A − B , 6 A A+B,A-B,6A A+B,A−B,6A
>> A-B
ans =
0.4831 0.1289 -0.5021 0.4933 -0.3145
0.4040 -0.2449 -0.2478 -0.3922 0.3449
-0.4534 0.0355 0.3186 -0.6299 0.2316
-0.3543 -0.6934 0.3231 -0.6765 0.5921
0.1467 0.4654 0.8834 0.7108 0.1878
>> 6*A
ans =
4.0782 5.7585 1.5306 3.2833 1.5257
3.9306 2.0423 3.0357 0.8317 4.8857
0.9757 3.5116 4.1945 0.8958 1.4611
0.7140 1.3429 5.3454 1.5450 5.5756
2.9902 4.5076 5.7557 5.0443 2.0999
>> A+B
ans =
0.8763 1.7906 1.0123 0.6012 0.8231
0.9062 0.9256 1.2597 0.6694 1.2837
0.7787 1.1350 1.0795 0.9285 0.2554
0.5923 1.1410 1.4587 1.1915 1.2664
0.8500 1.0371 1.0351 0.9706 0.5122
(2)计算 ( A B ) T , B T A T , ( A B ) 100 (AB)^T,B^TA^T,(AB)^{100} (AB)T,BTAT,(AB)100
>> (A*B)'
ans =
0.8802 0.8779 0.7659 1.0771 1.3986
1.8412 1.3815 1.0685 1.2214 2.2522
1.6651 1.0856 0.9335 0.8144 1.8125
1.2890 0.8455 1.0352 1.1806 2.0038
1.0659 0.7172 0.4654 0.4209 0.9877
>> B'*A'
ans =
0.8802 0.8779 0.7659 1.0771 1.3986
1.8412 1.3815 1.0685 1.2214 2.2522
1.6651 1.0856 0.9335 0.8144 1.8125
1.2890 0.8455 1.0352 1.1806 2.0038
1.0659 0.7172 0.4654 0.4209 0.9877
>> (A*B)^100
ans =
1.0e+73 *
2.2209 3.3910 2.7399 2.7280 1.6017
1.6373 2.5000 2.0200 2.0112 1.1808
1.3878 2.1189 1.7121 1.7046 1.0008
1.5476 2.3631 1.9093 1.9011 1.1161
2.7521 4.2020 3.3952 3.3805 1.9847
(3)计算行列式 ∣ A ∣ , ∣ B ∣ , ∣ A B ∣ |A|,|B|,|AB| ∣A∣,∣B∣,∣AB∣
>> det(A)
ans =
0.1078
>> det(B)
ans =
0.0192
>> det(A*B)
ans =
0.0021
(4)若矩阵 A , B A,B A,B可逆,计算 A − 1 , B − 1 A^{-1},B^{-1} A−1,B−1
在(3)中我们已经算得 ∣ A ∣ |A| ∣A∣, ∣ B ∣ |B| ∣B∣均不为0,也就是两个矩阵可逆,直接使用inv命令求逆矩阵
>> inv(A)
ans =
-1.1525 2.3286 0.0554 -2.1182 1.0051
1.6431 -1.1107 1.0437 0.7390 -1.2981
-1.6393 0.7898 1.3159 -0.9644 0.9985
0.6041 -1.0864 -2.0734 0.9315 1.0583
1.1560 -0.4868 -0.9455 1.8359 -1.0666
>> inv(B)
ans =
-0.2008 0.6537 1.3752 -1.8679 2.5941
1.7895 -3.0156 0.0038 1.7813 -1.2513
0.9713 1.1514 2.2184 -2.2523 -2.2201
-1.5485 1.0096 -0.8385 1.3058 -0.1437
-1.9324 2.5503 -3.3544 0.9182 3.9000
(5)计算矩阵 A A A和矩阵 B B B的秩
>> rank(A)
ans =
5
>> rank(B)
ans =
5
(6)生成一个 6 6 6行 5 5 5列秩为 3 3 3的矩阵,并求其最简阶梯形
m
a
t
l
a
b
matlab
matlab没有生成规定秩矩阵的命令,
可以首先生成一个
6
∗
5
6*5
6∗5的随机矩阵,
然后取后三行为前三行的线性组合
用 r o u n d ( ) round() round()进行舍入,生成一个 6 ∗ 5 6 * 5 6∗5随机整数矩阵
>> round(rand(6,5)*10)
ans =
2 2 0 1 2
6 4 4 10 8
1 6 5 10 8
1 6 2 0 6
7 1 7 5 0
6 2 0 9 4
>> A=[2,2,0,1,2;6,4,4,10,8;1,6,5,10,6;4,4,0,2,4;2,12,10,20,12;7,10,9,20,14]
A =
2 2 0 1 2
6 4 4 10 8
1 6 5 10 6
4 4 0 2 4
2 12 10 20 12
7 10 9 20 14
>> rank(A)
ans =
3
>> rref(A)
ans =
1.0000 0 0 0.4000 0.6667
0 1.0000 0 0.1000 0.3333
0 0 1.0000 1.8000 0.6667
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
2.求解两个线性方程组
2.1非齐次线性方程组唯一解
非齐次线性方程组有唯一解的充要条件为
R
(
系
数
矩
阵
)
=
R
(
增
广
矩
阵
)
=
未
知
量
个
数
R(系数矩阵)=R(增广矩阵)=未知量个数
R(系数矩阵)=R(增广矩阵)=未知量个数
分别存储系数矩阵
A
A
A和列向量
B
B
B,使用"矩阵除法"求解
X
X
X
>> A=[2,1,2,4;-14,17,-12,7;7,7,6,6;-2,-9,21,-7]
A =
2 1 2 4
-14 17 -12 7
7 7 6 6
-2 -9 21 -7
>> rank(A)
ans =
4
证明系数矩阵A的秩等于未知量个数,方可继续计算
>> B=[5;8;5;10]
B =
5
8
5
10
>> X=A\B
X =
-0.8341
-0.2525
0.7417
1.3593
2.2非齐次线性方程组通解
m
a
t
l
a
b
matlab
matlab没有直接计算非齐次线性方程组通解的函数,需要按照书面计算的方法分步计算
首先存储系数矩阵
A
A
A和增广矩阵
B
B
B
>> A=[5,9,7,2,8;4,22,8,25,23;1,8,1,8,8;2,6,6,9,7]
A =
5 9 7 2 8
4 22 8 25 23
1 8 1 8 8
2 6 6 9 7
>> b=[4;9;1;7]
b =
4
9
1
7
>> B=[A b]
B =
5 9 7 2 8 4
4 22 8 25 23 9
1 8 1 8 8 1
2 6 6 9 7 7
然后判断 A A A和 B B B是否秩相同,不同则无解
>> rank(A)
ans =
3
>> rank(B)
ans =
3
R
(
A
)
=
R
(
B
)
R(A)=R(B)
R(A)=R(B)才可以继续计算
又
R
(
A
)
=
R
(
B
)
<
4
R(A)=R(B)<4
R(A)=R(B)<4证明有无穷多解,下面求其通解
首先将增广矩阵化为行最简形 C C C
>> C=rref(B)
C =
1.0000 0 0 -4.1827 -0.8558 -1.6635
0 1.0000 0 1.3269 1.0577 0.1346
0 0 1.0000 1.5673 0.3942 1.5865
0 0 0 0 0 0
非齐次线性方程组的特解为
ξ
=
[
−
1.6635
0.1346
1.5865
0
]
T
\xi=[-1.6635 \ \ 0.1346 \ \ 1.5865 \ \ 0]^T
ξ=[−1.6635 0.1346 1.5865 0]T
取两个自由量
X
4
,
X
5
X_4,X_5
X4,X5分别为
[
1
,
0
]
T
,
[
0
,
1
]
T
[1,0]^T,[0,1]^T
[1,0]T,[0,1]T
带入同解方程组
{
x
1
−
4.1827
x
4
−
0.8558
x
5
=
0
x
2
+
1.3269
x
4
+
1.0577
x
5
=
0
x
3
+
1.5673
x
4
+
0.3942
x
5
=
0
\begin{cases}x_1-4.1827 x_4-0.8558x_5=0\\ x_2+1.3269 x_4+1.0577 x_5=0\\ x_3+1.5673 x_4+0.3942 x_5=0 \end{cases}
⎩⎪⎨⎪⎧x1−4.1827x4−0.8558x5=0x2+1.3269x4+1.0577x5=0x3+1.5673x4+0.3942x5=0
得到通解
ξ
1
=
[
4.1827
−
1.3269
−
1.5673
1
0
]
T
\xi_1=[4.1827 \ \ -1.3269 \ \ -1.5673 \ \ 1 \ \ 0]^T
ξ1=[4.1827 −1.3269 −1.5673 1 0]T
ξ
2
=
[
0.8558
−
1.0577
−
0.3942
0
1
]
T
\xi_2=[0.8558 \ \ -1.0577 \ \ -0.3942 \ \ 0 \ \ 1]^T
ξ2=[0.8558 −1.0577 −0.3942 0 1]T
综上,原非齐次线性方程组的通解为:
ξ + k 1 ξ 1 + k 2 ξ 2 ( k 1 , k 2 ∈ N ) \xi+k_1\xi_1+k_2\xi_2(k_1,k_2 \in N) ξ+k1ξ1+k2ξ2(k1,k2∈N)
3.求最大无关组
>> format rat% 设置使用分数表示数值
>> A=[3,4,0,8,3;1,1,0,2,2;2,3,0,6,1;9,3,2,1,2;0,8,-2,21,10]
A =
3 4 0 8 3
1 1 0 2 2
2 3 0 6 1
9 3 2 1 2
0 8 -2 21 10
>> A=A'%将A转置,原行向量变成列向量才能进行初等行变换
A =
3 1 2 9 0
4 1 3 3 8
0 0 0 2 -2
8 2 6 1 21
3 2 1 2 10
>> B=rref(A)
B =
1 0 1 0 2
0 1 -1 0 3
0 0 0 1 -1
0 0 0 0 0
0 0 0 0 0
取
α
1
,
α
2
,
α
4
\alpha_1,\alpha_2,\alpha_4
α1,α2,α4为极大无关组
则
α
3
=
α
1
−
α
2
\alpha_3=\alpha_1-\alpha_2
α3=α1−α2
α
5
=
2
α
1
+
3
α
2
−
α
4
\alpha_5=2\alpha_1+3\alpha_2-\alpha_4
α5=2α1+3α2−α4
4.向量的坐标变换
概念与算法的复习:
基与坐标
R n R^n Rn空间中的n个线性无关的向量 ξ 1 , ξ 2 . . . ξ n \xi_1, \xi_2...\xi_n ξ1,ξ2...ξn组成 R n R^n Rn空间的一组基,
若 α ∈ R n \alpha \in R^n α∈Rn是 R n R^n Rn空间中任意一个向量,
且 α = k 1 ξ 1 + k 2 ξ 2 + . . . + k n ξ n \alpha =k_1\xi_1+k_2\xi_2+...+k_n\xi_n α=k1ξ1+k2ξ2+...+knξn
则称 k 1 , k 2 . . . k n k_1,k_2...k_n k1,k2...kn为 α \alpha α关于基 ξ 1 , ξ 2 . . . ξ n \xi_1, \xi_2...\xi_n ξ1,ξ2...ξn的坐标
记作 ( k 1 , k 2 . . . k n ) T (k_1,k_2...k_n)^T (k1,k2...kn)T
基变换与坐标变换
设 ξ 1 , ξ 2 . . . ξ n \xi_1, \xi_2...\xi_n ξ1,ξ2...ξn和 η 1 , η 2 . . . η n \eta_1, \eta_2...\eta_n η1,η2...ηn为 R n R^n Rn中两组基,且有
(
η
1
,
η
2
.
.
.
η
n
)
T
=
(
ξ
1
,
ξ
2
.
.
.
ξ
n
)
T
[
a
11
a
12
a
13
.
.
.
a
1
n
a
21
a
22
a
23
.
.
.
a
2
n
⋯
a
n
1
a
n
2
a
n
3
.
.
.
a
n
n
]
(\eta_1, \eta_2...\eta_n)^T=(\xi_1, \xi_2...\xi_n)^T \begin{bmatrix}a_{11} \ a_{12} \ a_{13}...a_{1n} \\ a_{21} \ a_{22} \ a_{23}...a_{2n} \\ \cdots \\ a_{n1} \ a_{n2} \ a_{n3}...a_{nn} \end{bmatrix}
(η1,η2...ηn)T=(ξ1,ξ2...ξn)T⎣⎢⎢⎡a11 a12 a13...a1na21 a22 a23...a2n⋯an1 an2 an3...ann⎦⎥⎥⎤
=
(
ξ
1
,
ξ
2
.
.
.
ξ
n
)
T
A
=(\xi_1, \xi_2...\xi_n)^TA
=(ξ1,ξ2...ξn)TA
其中
A
=
[
a
11
a
12
a
13
.
.
.
a
1
n
a
21
a
22
a
23
.
.
.
a
2
n
⋯
a
n
1
a
n
2
a
n
3
.
.
.
a
n
n
]
A=\begin{bmatrix}a_{11} \ a_{12} \ a_{13}...a_{1n} \\ a_{21} \ a_{22} \ a_{23}...a_{2n} \\ \cdots \\ a_{n1} \ a_{n2} \ a_{n3}...a_{nn} \end{bmatrix}
A=⎣⎢⎢⎡a11 a12 a13...a1na21 a22 a23...a2n⋯an1 an2 an3...ann⎦⎥⎥⎤为由基
ξ
1
,
ξ
2
.
.
.
ξ
n
\xi_1, \xi_2...\xi_n
ξ1,ξ2...ξn到
η
1
,
η
2
.
.
.
η
n
\eta_1, \eta_2...\eta_n
η1,η2...ηn的过度矩阵,
A
A
A为可逆矩阵
设
α
\alpha
α在两个基下的坐标分别为
X
=
(
x
1
,
x
2
.
.
.
x
n
)
T
X=(x_1,x_2...x_n)^T
X=(x1,x2...xn)T和
Y
=
(
y
1
,
y
2
.
.
.
y
n
)
T
Y=(y_1,y_2...y_n)^T
Y=(y1,y2...yn)T
则
X
=
A
Y
,
Y
=
A
−
1
X
X=AY,Y=A^{-1}X
X=AY,Y=A−1X即坐标变换公式
本题中的应用:
向量
α
\alpha
α的坐标实际上是在基
ξ
1
=
(
1
,
0
,
0
)
T
,
ξ
2
=
(
0
,
1
,
0
)
T
,
ξ
3
=
(
0
,
0
,
1
)
T
\xi_1=(1,0,0)^T,\xi_2=(0,1,0)^T,\xi_3=(0,0,1)^T
ξ1=(1,0,0)T,ξ2=(0,1,0)T,ξ3=(0,0,1)T下的表示
那么显然
(
β
1
β
2
β
3
)
T
=
(
ξ
1
ξ
2
ξ
3
)
T
B
(\beta_1 \ \ \beta_2 \ \ \beta_3)^T=(\xi_1\ \ \xi_2\ \ \xi_3)^TB
(β1 β2 β3)T=(ξ1 ξ2 ξ3)TB
从
ξ
1
ξ
2
ξ
3
\xi_1\ \ \xi_2\ \ \xi_3
ξ1 ξ2 ξ3到
β
1
β
2
β
3
\beta_1 \ \ \beta_2 \ \ \beta_3
β1 β2 β3的过度矩阵为
B
=
[
1
2
3
0
1
2
0
0
1
]
B=\begin{bmatrix}1 \ \ 2 \ \ 3\\ 0 \ \ 1 \ \ 2 \\ 0 \ \ 0 \ \ 1 \end{bmatrix}
B=⎣⎡1 2 30 1 20 0 1⎦⎤
则
α
\alpha
α在
β
1
β
2
β
3
\beta_1 \ \ \beta_2 \ \ \beta_3
β1 β2 β3下的坐标为
B
−
1
α
B^{-1}\alpha
B−1α
>> B=[1,2,3;0,1,2;0,0,1]
B =
1 2 3
0 1 2
0 0 1
>> a=[3,2,5]
a =
3 2 5
>> C=inv(B)
C =
1 -2 1
0 1 -2
0 0 1
>> a=a'
a =
3
2
5
>> D=C*a
D =
4
-8
5
即 α \alpha α在 β 1 β 2 β 3 \beta_1 \ \ \beta_2 \ \ \beta_3 β1 β2 β3下的坐标 ( 4 , − 8 , 5 ) T (4,-8,5)^T (4,−8,5)T
5.求解特征值和特征向量
只使用eig命令只能获得特征值,
>> eig(A)
ans =
25/158
3767/1010
3145/116
如果需要获得特征向量需要两个矩阵承载>> [V,D]=eig(A)
(1)
>> A=[1,2,3;2,5,6;3,6,25]
A =
1 2 3
2 5 6
3 6 25
>> format rat
>> [V,D]=eig(A)
V =
160/171 445/1357 1377/10567
-751/2135 1596/1781 417/1541
-301/10736 -712/2381 909/953
D =
25/158 0 0
0 3767/1010 0
0 0 3145/116
要注意特征值和特征向量的一一对应关系
特征值 λ 1 = 25 158 \lambda_1=\frac{25}{158} λ1=15825对应的特征向量为 ξ 1 = [ 160 171 , − 751 2135 , − 301 10736 ] T \xi_1=[ \frac{160}{171}, \frac {-751}{2135} ,\frac{-301}{10736} ]^T ξ1=[171160,2135−751,10736−301]T
特征值 λ 2 = 3767 1010 \lambda_2=\frac{3767}{1010} λ2=10103767对应的特征向量为 ξ 2 = [ 445 1357 , 1596 1781 , − 712 2381 ] T \xi_2=[ \frac{445}{1357}, \frac {1596}{1781} ,\frac{-712}{2381} ]^T ξ2=[1357445,17811596,2381−712]T
特征值 λ 3 = 3145 116 \lambda_3=\frac{3145}{116} λ3=1163145对应的特征向量为 ξ 3 = [ 1377 10567 , 417 1541 , 909 953 ] T \xi_3=[ \frac{1377}{10567}, \frac {417}{1541} ,\frac{909}{953} ]^T ξ3=[105671377,1541417,953909]T
三个特征值均为正数因此 A A A为正定矩阵
(2)
>> B=[-20,3,1;3,-10,-6;1,-6,-22]
B =
-20 3 1
3 -10 -6
1 -6 -22
>> [V,D]=eig(B)
V =
-357/937 4822/5323 500/2703
1060/2647 -19/1019 3681/4018
7996/9595 699/1652 -1609/4524
D =
-20323/802 0 0
0 -7348/375 0
0 0 -544/77
特征值 λ 1 = − 20323 802 \lambda_1=\frac{-20323}{802} λ1=802−20323对应的特征向量为 ξ 1 = [ − 357 937 , 1060 2647 , 7996 9595 ] T \xi_1=[ \frac{-357}{937}, \frac {1060}{2647} ,\frac{7996}{9595} ]^T ξ1=[937−357,26471060,95957996]T
特征值 λ 2 = − 7348 375 \lambda_2=\frac{-7348}{375} λ2=375−7348对应的特征向量为 ξ 2 = [ 4822 5323 , − 19 1019 , 3681 4018 ] T \xi_2=[ \frac{4822}{5323}, \frac {-19}{1019} ,\frac{3681}{4018} ]^T ξ2=[53234822,1019−19,40183681]T
特征值 λ 3 = − 544 77 \lambda_3=\frac{-544}{77} λ3=77−544对应的特征向量为 ξ 3 = [ 500 2703 , 3681 4018 , − 1609 4524 ] T \xi_3=[ \frac{500}{2703}, \frac {3681}{4018} ,\frac{-1609}{4524} ]^T ξ3=[2703500,40183681,4524−1609]T
所有特征值都为负因此 B B B为负定矩阵
6.正交变换法化二次型为标准型
步骤:
1.求特征值
λ
1
,
λ
2
.
.
.
.
λ
n
\lambda_1,\lambda_2....\lambda_n
λ1,λ2....λn,最终标准型即
d
i
a
g
{
λ
1
,
λ
2
.
.
.
.
λ
n
}
diag\{\lambda_1,\lambda_2....\lambda_n\}
diag{λ1,λ2....λn}
2.求特征值对应的所有解系
3.每个解系分别正交化
4.所有解单位化
5.所有解组成正交矩阵C
d
e
u
t
s
c
h
deutsch
deutsch球的学号
20009101015
20009101015
20009101015后三位
k
1
=
0
,
k
2
=
1
,
k
3
=
5
k_1=0,k_2=1,k_3=5
k1=0,k2=1,k3=5
>> A=[1,0,1/2;0,2,5/2;1/2,5/2,3]
A =
1 0 1/2
0 2 5/2
1/2 5/2 3
>> [V,D]=eig(A)
V =%特征向量矩阵
48/175 1001/1046 239/2525
930/1273 -127/468 631/1007
-686/1097 268/2609 591/764
D =%特征值矩阵(二次形)
-254/1815 0 0
0 962/913 0
0 0 1297/255
>> L1=sqrt(V(:,1)'*V(:,1))
L1 =
1
>> L2=sqrt(V(:,2)'*V(:,2))
L2 =
1
>> L3=sqrt(V(:,3)'*V(:,3))
L3 =
1
>> Q1=V(:,1)/L1
Q1 =
48/175
930/1273
-686/1097
>> Q2=V(:,2)/L2
Q2 =
1001/1046
-127/468
268/2609
>> Q3=V(:,3)/L3
Q3 =
239/2525
631/1007
591/764
>> Q=[Q1,Q2,Q3]
Q =%变换矩阵
48/175 1001/1046 239/2525
930/1273 -127/468 631/1007
-686/1097 268/2609 591/764
二.应用题
1.多项式求值
也就是求解
a
0
a_0
a0到
a
5
a_5
a5六个系数,然后带入
x
=
6
x=6
x=6求值
>> A=[1,0,0,0,0,0;1,1,1,1,1,1;1,2,4,8,16,32;1,3,9,27,81,243;1,4,16,64,256,1024;1,5,25,125,625,3125]
A =
1 0 0 0 0 0
1 1 1 1 1 1
1 2 4 8 16 32
1 3 9 27 81 243
1 4 16 64 256 1024
1 5 25 125 625 3125
>> b=[2;6;0;26;294;1302]
b =
2
6
0
26
294
1302
>> format short
>> X=A\b
X =
2.0000
5.0000
1.0000
-0.0000
-3.0000
1.0000
即 P 5 ( x ) = 2 + 5 x + x 2 − 3 x 4 + x 5 P_5(x)=2+5x+x^2-3x^4+x^5 P5(x)=2+5x+x2−3x4+x5
注意
P
P
P从高位到低位输入多项式
p
o
l
y
v
a
l
(
P
,
6
)
polyval(P,6)
polyval(P,6)表示计算P多项式在未知数指派为
6
6
6时的值
>> P=[1,-3,0,1,5,2]
P =
1 -3 0 1 5 2
>> y = polyval(P,6)
y =
3956
即 P 5 ( 6 ) = 3956 P_5(6)=3956 P5(6)=3956
2.矩阵求解线性数列通项
设第
n
n
n天的时候有
A
,
B
,
C
A,B,C
A,B,C类细菌各有
a
n
,
b
n
,
c
n
a_n,b_n,c_n
an,bn,cn个,那么从第
n
n
n天到第
n
+
1
n+1
n+1天的状态转移
a
n
+
1
=
4
5
a
n
+
3
10
b
n
+
3
10
c
n
a_{n+1}=\frac{4}{5}a_n+\frac{3}{10}b_n+\frac{3}{10}c_n
an+1=54an+103bn+103cn
b
n
+
1
=
1
20
a
n
+
3
5
b
n
+
1
5
c
n
b_{n+1}=\frac{1}{20}a_n+\frac{3}{5}b_n+\frac{1}{5}c_n
bn+1=201an+53bn+51cn
c
n
+
1
=
3
20
a
n
+
1
5
b
n
+
1
2
c
n
c_{n+1}=\frac{3}{20}a_n+\frac{1}{5}b_n+\frac{1}{2}c_n
cn+1=203an+51bn+21cn
即
[
a
n
+
1
b
n
+
1
c
n
+
1
]
=
[
4
5
3
10
3
10
1
20
3
5
1
5
3
20
1
5
1
2
]
[
a
n
b
n
c
n
]
\begin{bmatrix} a_{n+1} \\b_{n+1} \\c_{n+1} \end{bmatrix}= \begin{bmatrix} \ \frac{4}{5} \ \ \frac{3}{10} \frac{3}{10}\\ \frac{1}{20} \ \ \frac{3}{5} \ \ \frac{1}{5}\\ \frac{3}{20} \ \ \frac{1}{5} \ \ \frac{1}{2} \end{bmatrix} \begin{bmatrix} a_{n} \\b_{n} \\c_{n} \end{bmatrix}
⎣⎡an+1bn+1cn+1⎦⎤=⎣⎡ 54 103103201 53 51203 51 21⎦⎤⎣⎡anbncn⎦⎤
令 A = [ 4 5 3 10 3 10 1 20 3 5 1 5 3 20 1 5 1 2 ] A=\begin{bmatrix} \ \frac{4}{5} \ \ \frac{3}{10} \frac{3}{10}\\ \frac{1}{20} \ \ \frac{3}{5} \ \ \frac{1}{5}\\ \frac{3}{20} \ \ \frac{1}{5} \ \ \frac{1}{2} \end{bmatrix} A=⎣⎡ 54 103103201 53 51203 51 21⎦⎤
X n = [ a n b n c n ] X_n=\begin{bmatrix} a_{n} \\b_{n} \\c_{n} \end{bmatrix} Xn=⎣⎡anbncn⎦⎤
X
0
=
[
1
e
8
2
e
8
3
e
8
]
X_0=\begin{bmatrix} 1e8 \\2e8 \\3e8 \end{bmatrix}
X0=⎣⎡1e82e83e8⎦⎤
则
X
n
=
A
X
n
−
1
=
A
2
X
n
−
2
=
.
.
.
=
A
n
−
1
X
0
X_n=AX_{n-1}=A^2X_{n-2}=...=A^{n-1}X_0
Xn=AXn−1=A2Xn−2=...=An−1X0
>> A=[0.8,0.3,0.3;0.05,0.6,0.2;0.15,0.1,0.5]
A =
0.8000 0.3000 0.3000
0.0500 0.6000 0.2000
0.1500 0.1000 0.5000
>> X=[1e8;2e8;3e8]
X =
100000000
200000000
300000000
>> X1=A*X
X1 =%一天后
230000000
185000000
185000000
>> X14=A^14*X
X14 =%两周后
1.0e+08 *
3.5998
1.1002
1.2999
>> X21=A^21*X
X21 =%三周后
1.0e+08 *
3.6000
1.1000
1.3000
分析 n n n多天之后细菌数趋向稳定的原因:
>> Y=A^n*X
Y =
360000000 - 260000000*exp(-n*log(2))
390000000*exp(-n*log(2)) - 300000000*exp(n*log(2/5)) + 110000000
300000000*exp(n*log(2/5)) - 130000000*exp(-n*log(2)) + 130000000
>> limit(Y,inf)
ans =
360000000
110000000
130000000
即 Y = A n ∗ X Y=A^n*X Y=An∗X 存在极限,若干天后趋向于该极限 X i n f = [ 360000000 110000000 130000000 ] X_{inf}=\begin{bmatrix} 360000000 \\110000000 \\130000000 \end{bmatrix} Xinf=⎣⎡360000000110000000130000000⎦⎤
3.plot绘图
x(:,1)//表示第一列的所有数据,
x(:,2)//表示第二列的所有数据,
plot(x,y)表示以x为横坐标,y为纵坐标绘图
plot(x(:,1),x(:,2))表示以第一列所有数据为横坐标
>> X=[0,1,0,0;0,0,2,0;1,1,1,1]
X =
0 1 0 0
0 0 2 0
1 1 1 1
>> M=[1,0,20;0,1,-20;0,0,1]
M =
1 0 20
0 1 -20
0 0 1
>> R=[cos(pi/4),-sin(pi/4),0;sin(pi/4),cos(pi/4),0;0,0,1]
R =
0.7071 -0.7071 0
0.7071 0.7071 0
0 0 1.0000
>> Y1=M*R*X
Y1 =
20.0000 20.7071 18.5858 20.0000
-20.0000 -19.2929 -18.5858 -20.0000
1.0000 1.0000 1.0000 1.0000
>> plot(X(1,:),X(2,:))%开始绘图
>> hold on%保留刚才绘制的图形,继续绘制
>> fill(Y1(1,:),Y1(2,:),'black')
>> grid on
>> hold off%
效果:
4.解未知量系数方程组
T
=
k
u
p
T
u
p
+
k
d
o
w
n
T
d
o
w
n
+
k
l
e
f
t
T
l
e
f
t
+
k
r
i
g
h
t
T
r
i
g
h
t
=
α
T
u
p
+
β
T
d
o
w
n
+
λ
T
l
e
f
t
+
μ
T
r
i
g
h
t
T=k_{up}T_{up}+k_{down}T_{down}+k_{left}T_{left}+k_{right}T_{right} \\=\alpha T_{up}+\beta T_{down}+\lambda T_{left}+\mu T_{right}
T=kupTup+kdownTdown+kleftTleft+krightTright=αTup+βTdown+λTleft+μTright
T
1
=
α
a
+
β
T
3
+
λ
b
+
μ
T
2
T_1=\alpha a+\beta T_{3}+\lambda b+\mu T_{2}
T1=αa+βT3+λb+μT2
T
2
=
α
a
+
β
T
4
+
λ
T
1
+
μ
d
T_2=\alpha a+\beta T_{4}+\lambda T_{1}+\mu d
T2=αa+βT4+λT1+μd
T
3
=
α
T
1
+
β
c
+
λ
b
+
μ
T
4
T_3=\alpha T_{1}+\beta c+\lambda b+\mu T_{4}
T3=αT1+βc+λb+μT4
T
4
=
α
T
2
+
β
c
+
λ
T
3
+
μ
d
T_4=\alpha T_{2}+\beta c+\lambda T_{3}+\mu d
T4=αT2+βc+λT3+μd
即求解
T
1
T_1
T1到
T
4
T_4
T4
将含有未知数
T
1
T_1
T1到
T
4
T_4
T4的项移到等号左侧得到非齐次线性方程组
{
T
1
−
μ
T
2
−
β
T
3
+
0
T
4
=
α
a
+
λ
b
−
λ
T
1
+
T
2
+
0
T
3
−
β
T
4
=
α
a
+
μ
d
−
α
T
1
+
0
T
2
+
T
3
−
μ
T
4
=
β
c
+
λ
b
0
T
1
−
α
T
2
−
λ
T
3
+
T
4
=
β
c
+
μ
d
\begin{cases}T_1-\mu T_2-\beta T_3+0T_4=\alpha a+ \lambda b\\ -\lambda T_1+T_2+0T_3-\beta T_4=\alpha a+\mu d \\ -\alpha T_1+0T_2+T_3-\mu T_4=\beta c+\lambda b\\ 0T_1-\alpha T_2-\lambda T_3+T_4=\beta c+\mu d \end{cases}
⎩⎪⎪⎪⎨⎪⎪⎪⎧T1−μT2−βT3+0T4=αa+λb−λT1+T2+0T3−βT4=αa+μd−αT1+0T2+T3−μT4=βc+λb0T1−αT2−λT3+T4=βc+μd
以下只需求出该方程组的解
由于
m
a
t
l
a
b
matlab
matlab中不方便输入希腊字母
用小写字母代替希腊字母输入
m
=
α
m=\alpha
m=α
n
=
β
n=\beta
n=β
p
=
λ
p=\lambda
p=λ
q
=
μ
q=\mu
q=μ
{
T
1
−
q
T
2
−
n
T
3
+
0
T
4
=
m
a
+
p
b
−
p
T
1
+
T
2
+
0
T
3
−
b
T
4
=
m
a
+
q
d
−
m
T
1
+
0
T
2
+
T
3
−
q
T
4
=
n
c
+
p
b
0
T
1
−
m
T
2
−
p
T
3
+
T
4
=
n
c
+
q
d
\begin{cases}T_1-q T_2-n T_3+0T_4=m a+ p b\\ -p T_1+T_2+0T_3-b T_4=m a+q d \\ -m T_1+0T_2+T_3-q T_4=n c+p b\\ 0T_1-m T_2-p T_3+T_4=n c+q d \end{cases}
⎩⎪⎪⎪⎨⎪⎪⎪⎧T1−qT2−nT3+0T4=ma+pb−pT1+T2+0T3−bT4=ma+qd−mT1+0T2+T3−qT4=nc+pb0T1−mT2−pT3+T4=nc+qd
>> syms m n p q a b c d
>> A=[1,-q,-n,0;-p,1,0,-b;-m,0,1,-q;0,-m,-p,1]
A =
[ 1, -q, -n, 0]
[-p, 1, 0, -b]
[-m, 0, 1, -q]
[ 0, -m, -p, 1]
>> b=[m*a+p*b;m*a+q*d;n*c+p*b;n*c+q*d]
b =
a*m + b*p
a*m + d*q
c*n + b*p
c*n + d*q
>> X=A\b
X =
-(- b^2*m*n*p - b^2*m*p + b^2*p^2*q - a*b*m^2 - c*b*m*n^2 + c*b*n*p*q + b*n*p + c*b*n*q - b*p^2*q + b*p + d*b*q^2 + a*m^2*n*q + d*m*n*q^2 - a*m*p*q^2 - a*m*p*q + a*m*q + a*m + c*n^2*q + c*n^2 + d*n*q^2 - d*p*q^3 + d*q^2)/(b*m + m*n + 2*p*q - p^2*q^2 - b*m^2*n + b*m*p*q + m*n*p*q - 1)
-(b^2*m*p^2 + b^2*p^2 + a*b*m^2*p - c*b*m*n^2 - d*b*m*n*q + b*n*p^2 + c*b*n*p + c*b*n - b*p^3*q + b*p^2 + d*b*q - a*m^2*n - d*m*n*q - a*m*p^2*q - a*m*p*q + a*m*p + a*m + c*n^2*p*q + c*n^2*p + d*n*p*q^2 - d*p*q^2 + d*q)/(b*m + m*n + 2*p*q - p^2*q^2 - b*m^2*n + b*m*p*q + m*n*p*q - 1)
-(- b^2*m^2*p - b^2*m*p - a*b*m^3 + b*m*p^2*q + b*m*p + d*b*m*q^2 + c*n*b*m*q - c*n*b*m - b*p^2*q + b*p + a*m^2*p*q + 2*a*m^2*q + a*m^2 + 2*d*m*q^2 - d*p*q^3 - c*n*p*q^2 - c*n*p*q + d*q^2 + c*n*q + c*n)/(b*m + m*n + 2*p*q - p^2*q^2 - b*m^2*n + b*m*p*q + m*n*p*q - 1)
-(- a*m^3*n - d*m^2*n*q + a*m^2*p*q + 2*a*m^2*p + a*m^2 + c*m*n^2*p - c*m*n^2 + b*m*n*p^2 - d*m*n*q + 2*b*m*p^2 + d*m*p*q^2 + d*m*q - c*n*p^2*q - c*n*p*q + c*n*p + c*n - b*p^3*q + b*p^2 - d*p*q^2 + d*q)/(b*m + m*n + 2*p*q - p^2*q^2 - b*m^2*n + b*m*p*q + m*n*p*q - 1)
因此
T
1
=
−
(
−
b
2
∗
m
∗
n
∗
p
−
b
2
∗
m
∗
p
+
b
2
∗
p
2
∗
q
−
a
∗
b
∗
m
2
−
c
∗
b
∗
m
∗
n
2
+
c
∗
b
∗
n
∗
p
∗
q
+
b
∗
n
∗
p
+
c
∗
b
∗
n
∗
q
−
b
∗
p
2
∗
q
+
b
∗
p
+
d
∗
b
∗
q
2
+
a
∗
m
2
∗
n
∗
q
+
d
∗
m
∗
n
∗
q
2
−
a
∗
m
∗
p
∗
q
2
−
a
∗
m
∗
p
∗
q
+
a
∗
m
∗
q
+
a
∗
m
+
c
∗
n
2
∗
q
+
c
∗
n
2
+
d
∗
n
∗
q
2
−
d
∗
p
∗
q
3
+
d
∗
q
2
)
/
(
b
∗
m
+
m
∗
n
+
2
∗
p
∗
q
−
p
2
∗
q
2
−
b
∗
m
2
∗
n
+
b
∗
m
∗
p
∗
q
+
m
∗
n
∗
p
∗
q
−
1
)
T_1=-(- b^2*m*n*p - b^2*m*p + b^2*p^2*q - a*b*m^2 - c*b*m*n^2 + c*b*n*p*q + b*n*p + c*b*n*q - b*p^2*q + b*p + d*b*q^2 + a*m^2*n*q + d*m*n*q^2 - a*m*p*q^2 - a*m*p*q + a*m*q + a*m + c*n^2*q + c*n^2 + d*n*q^2 - d*p*q^3 + d*q^2)/(b*m + m*n + 2*p*q - p^2*q^2 - b*m^2*n + b*m*p*q + m*n*p*q - 1)
T1=−(−b2∗m∗n∗p−b2∗m∗p+b2∗p2∗q−a∗b∗m2−c∗b∗m∗n2+c∗b∗n∗p∗q+b∗n∗p+c∗b∗n∗q−b∗p2∗q+b∗p+d∗b∗q2+a∗m2∗n∗q+d∗m∗n∗q2−a∗m∗p∗q2−a∗m∗p∗q+a∗m∗q+a∗m+c∗n2∗q+c∗n2+d∗n∗q2−d∗p∗q3+d∗q2)/(b∗m+m∗n+2∗p∗q−p2∗q2−b∗m2∗n+b∗m∗p∗q+m∗n∗p∗q−1)
T 2 = − ( b 2 ∗ m ∗ p 2 + b 2 ∗ p 2 + a ∗ b ∗ m 2 ∗ p − c ∗ b ∗ m ∗ n 2 − d ∗ b ∗ m ∗ n ∗ q + b ∗ n ∗ p 2 + c ∗ b ∗ n ∗ p + c ∗ b ∗ n − b ∗ p 3 ∗ q + b ∗ p 2 + d ∗ b ∗ q − a ∗ m 2 ∗ n − d ∗ m ∗ n ∗ q − a ∗ m ∗ p 2 ∗ q − a ∗ m ∗ p ∗ q + a ∗ m ∗ p + a ∗ m + c ∗ n 2 ∗ p ∗ q + c ∗ n 2 ∗ p + d ∗ n ∗ p ∗ q 2 − d ∗ p ∗ q 2 + d ∗ q ) / ( b ∗ m + m ∗ n + 2 ∗ p ∗ q − p 2 ∗ q 2 − b ∗ m 2 ∗ n + b ∗ m ∗ p ∗ q + m ∗ n ∗ p ∗ q − 1 ) T_2=-(b^2*m*p^2 + b^2*p^2 + a*b*m^2*p - c*b*m*n^2 - d*b*m*n*q + b*n*p^2 + c*b*n*p + c*b*n - b*p^3*q + b*p^2 + d*b*q - a*m^2*n - d*m*n*q - a*m*p^2*q - a*m*p*q + a*m*p + a*m + c*n^2*p*q + c*n^2*p + d*n*p*q^2 - d*p*q^2 + d*q)/(b*m + m*n + 2*p*q - p^2*q^2 - b*m^2*n + b*m*p*q + m*n*p*q - 1) T2=−(b2∗m∗p2+b2∗p2+a∗b∗m2∗p−c∗b∗m∗n2−d∗b∗m∗n∗q+b∗n∗p2+c∗b∗n∗p+c∗b∗n−b∗p3∗q+b∗p2+d∗b∗q−a∗m2∗n−d∗m∗n∗q−a∗m∗p2∗q−a∗m∗p∗q+a∗m∗p+a∗m+c∗n2∗p∗q+c∗n2∗p+d∗n∗p∗q2−d∗p∗q2+d∗q)/(b∗m+m∗n+2∗p∗q−p2∗q2−b∗m2∗n+b∗m∗p∗q+m∗n∗p∗q−1)
T 3 = − ( − b 2 ∗ m 2 ∗ p − b 2 ∗ m ∗ p − a ∗ b ∗ m 3 + b ∗ m ∗ p 2 ∗ q + b ∗ m ∗ p + d ∗ b ∗ m ∗ q 2 + c ∗ n ∗ b ∗ m ∗ q − c ∗ n ∗ b ∗ m − b ∗ p 2 ∗ q + b ∗ p + a ∗ m 2 ∗ p ∗ q + 2 ∗ a ∗ m 2 ∗ q + a ∗ m 2 + 2 ∗ d ∗ m ∗ q 2 − d ∗ p ∗ q 3 − c ∗ n ∗ p ∗ q 2 − c ∗ n ∗ p ∗ q + d ∗ q 2 + c ∗ n ∗ q + c ∗ n ) / ( b ∗ m + m ∗ n + 2 ∗ p ∗ q − p 2 ∗ q 2 − b ∗ m 2 ∗ n + b ∗ m ∗ p ∗ q + m ∗ n ∗ p ∗ q − 1 ) T_3=-(- b^2*m^2*p - b^2*m*p - a*b*m^3 + b*m*p^2*q + b*m*p + d*b*m*q^2 + c*n*b*m*q - c*n*b*m - b*p^2*q + b*p + a*m^2*p*q + 2*a*m^2*q + a*m^2 + 2*d*m*q^2 - d*p*q^3 - c*n*p*q^2 - c*n*p*q + d*q^2 + c*n*q + c*n)/(b*m + m*n + 2*p*q - p^2*q^2 - b*m^2*n + b*m*p*q + m*n*p*q - 1) T3=−(−b2∗m2∗p−b2∗m∗p−a∗b∗m3+b∗m∗p2∗q+b∗m∗p+d∗b∗m∗q2+c∗n∗b∗m∗q−c∗n∗b∗m−b∗p2∗q+b∗p+a∗m2∗p∗q+2∗a∗m2∗q+a∗m2+2∗d∗m∗q2−d∗p∗q3−c∗n∗p∗q2−c∗n∗p∗q+d∗q2+c∗n∗q+c∗n)/(b∗m+m∗n+2∗p∗q−p2∗q2−b∗m2∗n+b∗m∗p∗q+m∗n∗p∗q−1)
T 4 = − ( − a ∗ m 3 ∗ n − d ∗ m 2 ∗ n ∗ q + a ∗ m 2 ∗ p ∗ q + 2 ∗ a ∗ m 2 ∗ p + a ∗ m 2 + c ∗ m ∗ n 2 ∗ p − c ∗ m ∗ n 2 + b ∗ m ∗ n ∗ p 2 − d ∗ m ∗ n ∗ q + 2 ∗ b ∗ m ∗ p 2 + d ∗ m ∗ p ∗ q 2 + d ∗ m ∗ q − c ∗ n ∗ p 2 ∗ q − c ∗ n ∗ p ∗ q + c ∗ n ∗ p + c ∗ n − b ∗ p 3 ∗ q + b ∗ p 2 − d ∗ p ∗ q 2 + d ∗ q ) / ( b ∗ m + m ∗ n + 2 ∗ p ∗ q − p 2 ∗ q 2 − b ∗ m 2 ∗ n + b ∗ m ∗ p ∗ q + m ∗ n ∗ p ∗ q − 1 ) T_4=-(- a*m^3*n - d*m^2*n*q + a*m^2*p*q + 2*a*m^2*p + a*m^2 + c*m*n^2*p - c*m*n^2 + b*m*n*p^2 - d*m*n*q + 2*b*m*p^2 + d*m*p*q^2 + d*m*q - c*n*p^2*q - c*n*p*q + c*n*p + c*n - b*p^3*q + b*p^2 - d*p*q^2 + d*q)/(b*m + m*n + 2*p*q - p^2*q^2 - b*m^2*n + b*m*p*q + m*n*p*q - 1) T4=−(−a∗m3∗n−d∗m2∗n∗q+a∗m2∗p∗q+2∗a∗m2∗p+a∗m2+c∗m∗n2∗p−c∗m∗n2+b∗m∗n∗p2−d∗m∗n∗q+2∗b∗m∗p2+d∗m∗p∗q2+d∗m∗q−c∗n∗p2∗q−c∗n∗p∗q+c∗n∗p+c∗n−b∗p3∗q+b∗p2−d∗p∗q2+d∗q)/(b∗m+m∗n+2∗p∗q−p2∗q2−b∗m2∗n+b∗m∗p∗q+m∗n∗p∗q−1)
5.解方程组
对A点:
x
1
+
x
8
=
120
+
80
x_1+x_8=120+80
x1+x8=120+80
对B点:
x
8
+
x
9
−
x
7
=
350
x_8+x_9-x_7=350
x8+x9−x7=350
对C点:
x
6
+
x
7
=
100
+
50
x_6+x_7=100+50
x6+x7=100+50
对D点:
x
5
−
x
6
−
x
11
=
−
400
x_5-x_6-x_{11}=-400
x5−x6−x11=−400
对E点:
x
4
−
x
5
=
234
−
100
x_4-x_5=234-100
x4−x5=234−100
对F点:
x
3
−
x
12
−
x
4
=
−
500
x_3-x_{12}-x_4=-500
x3−x12−x4=−500
对G点:
x
2
−
x
3
=
266
−
100
x_2-x_3=266-100
x2−x3=266−100
对H点:
x
1
−
x
2
+
x
10
=
300
x_1-x_2+x_{10}=300
x1−x2+x10=300
对O点:
−
x
9
−
x
10
+
x
11
+
x
12
=
0
-x_9-x_{10}+x_{11}+x_{12}=0
−x9−x10+x11+x12=0
带入已知量
x
8
=
0
,
x
10
=
300
,
x
11
=
660
,
x
12
=
0
x_8=0,x_{10}=300,x_{11}=660,x_{12}=0
x8=0,x10=300,x11=660,x12=0
对A点:
x
1
=
120
+
80
x_1=120+80
x1=120+80
对B点:
−
x
7
+
x
9
=
350
-x_7+x_9=350
−x7+x9=350
对C点:
x
6
+
x
7
=
100
+
50
x_6+x_7=100+50
x6+x7=100+50
对D点:
x
5
−
x
6
=
660
−
400
x_5-x_6=660-400
x5−x6=660−400
对E点:
x
4
−
x
5
=
234
−
100
x_4-x_5=234-100
x4−x5=234−100
对F点:
x
3
−
x
4
=
−
500
x_3-x_4=-500
x3−x4=−500
对G点:
x
2
−
x
3
=
266
−
100
x_2-x_3=266-100
x2−x3=266−100
对H点:
x
1
−
x
2
=
300
−
300
x_1-x_2=300-300
x1−x2=300−300
对O点:
−
x
9
=
300
−
660
-x_9=300-660
−x9=300−660
即解上述方程组
在
m
a
t
l
a
b
matlab
matlab中只需
A
=
A=
A=系数矩阵
b
=
常
向
量
b=常向量
b=常向量
计算
X
=
A
X=A
X=A\
b
b
b
解得
{
x
1
=
200
x
2
=
200
x
3
=
34
x
4
=
534
x
5
=
400
x
6
=
140
x
7
=
10
x
8
=
0
x
9
=
360
x
10
=
300
x
11
=
660
x
12
=
0
\begin{cases}x_1=200\\ x_2=200\\ x_3=34\\ x_4=534\\ x_5=400\\ x_6=140\\ x_7=10\\ x_8=0\\ x_9=360\\ x_{10}=300\\ x_{11}=660\\ x_{12}=0 \end{cases}
⎩⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎧x1=200x2=200x3=34x4=534x5=400x6=140x7=10x8=0x9=360x10=300x11=660x12=0
6. H i l l 2 Hill_2 Hill2加密与解密(尚未解决)
首先将密文
W
O
W
U
Y
S
B
A
C
P
G
Z
S
A
V
C
O
V
K
P
E
W
C
P
A
D
K
P
P
A
B
U
J
C
Q
L
Y
X
Q
E
Z
A
A
C
P
P
WOWUYSBACPGZSAVCOVKPEWCPADKPPABUJCQLYXQEZAACPP
WOWUYSBACPGZSAVCOVKPEWCPADKPPABUJCQLYXQEZAACPP离散化:
根据字母字典序赋值
A
=
0
A=0
A=0
B
=
1
B=1
B=1
.
.
.
...
...
Z
=
25
Z=25
Z=25
则原密文为
W
O
W
U
Y
S
B
A
C
P
G
Z
S
A
V
C
O
V
K
P
E
W
C
P
A
D
K
P
P
A
B
U
J
C
Q
L
Y
X
Q
E
Z
A
A
C
P
P
22
14
22
20
24
18
1
0
2
15
6
25
18
0
21
2
14
21
10
15
4
22
2
15
0
3
10
15
15
0
1
20
9
2
16
11
24
23
16
4
25
0
0
2
15
15
W\ O\ W\ \ U\ \ Y\ \ S\ B\ A\ C\ P\ G\ Z\ \ S\ A\ V\ C\ O\ V\ \ K\ \ P\ \ E\ W\ C\ P\ A\ D\ K\ P\ \ P\ A\ B\ U\ J\ C\ Q\ L\ \ Y\ \ X\ \ Q\ E\ Z\ A\ A\ C\ P\ P\\ 22\ 14\ 22\ 20\ 24\ 18\ \ 1 \ \ 0 \ \ 2 \ 15\ 6\ 25 \ 18 \ 0\ 21\ 2 \ 14 \ 21\ 10 \ 15 \ \ 4\ \ 22 \ \ 2\ 15 \ 0 \ \ 3\ 10 \ 15 \ 15\ 0\ \ 1 \ 20\ 9 \ \ 2 \ 16 \ 11\ 24\ 23 \ 16\ 4 \ 25\ \ 0\ 0\ \ 2\ 15\ 15
W O W U Y S B A C P G Z S A V C O V K P E W C P A D K P P A B U J C Q L Y X Q E Z A A C P P22 14 22 20 24 18 1 0 2 15 6 25 18 0 21 2 14 21 10 15 4 22 2 15 0 3 10 15 15 0 1 20 9 2 16 11 24 23 16 4 25 0 0 2 15 15
密钥A为二阶方阵,那么令原密文两两组成列向量 x i x_i xi,计算
标签:10,xi,frac,On2021.6,...,西电,matlab,alpha,20 来源: https://blog.csdn.net/qq_26131031/article/details/117910891