矩阵论
1. 准备知识——复数域上矩阵,Hermite变换)
1.准备知识——复数域上的内积域正交阵
1.准备知识——Hermite阵,二次型,矩阵合同,正定阵,幂0阵,幂等阵,矩阵的秩
2. 矩阵分解——SVD准备知识——奇异值
2. 矩阵分解——SVD
2. 矩阵分解——QR分解
2. 矩阵分解——正定阵分解
2. 矩阵分解——单阵谱分解
2. 矩阵分解——正规分解——正规阵
2. 矩阵分解——正规谱分解
2. 矩阵分解——高低分解
3. 矩阵函数——常见解析函数
3. 矩阵函数——谱公式,幂0与泰勒计算矩阵函数
3. 矩阵函数——矩阵函数求导
4. 矩阵运算——观察法求矩阵特征值特征向量
4. 矩阵运算——张量积
4. 矩阵运算——矩阵拉直
4.矩阵运算——广义逆——加号逆定义性质与特殊矩阵的加号逆
4. 矩阵运算——广义逆——加号逆的计算
4. 矩阵运算——广义逆——加号逆应用
4. 矩阵运算——广义逆——减号逆
5. 线性空间与线性变换——线性空间
5. 线性空间与线性变换——生成子空间
5. 线性空间与线性变换——线性映射与自然基分解,线性变换
6. 正规方程与矩阵方程求解
7. 范数理论——基本概念——向量范数与矩阵范数
7.范数理论——基本概念——矩阵范数生成向量范数&谱范不等式
7. 矩阵理论——算子范数
7.范数理论——范数估计——许尔估计&谱估计
7. 范数理论——非负/正矩阵
8. 常用矩阵总结——秩1矩阵,优阵(单位正交阵),Hermite阵
8. 常用矩阵总结——镜面阵,正定阵
8. 常用矩阵总结——单阵,正规阵,幂0阵,幂等阵,循环阵

设
m
×
n
m\times n
m×n 阶矩阵
A
(
x
)
=
(
a
i
j
(
x
)
)
m
×
n
A(x)=\left(a_{ij}(x)\right)_{m\times n}
A(x)=(aij(x))m×n 中的元素都是 x 的可导函数,则
A
(
x
)
A(x)
A(x) 为关于
x
x
x 的求导为:
A
′
(
x
)
=
d
A
(
x
)
d
x
=
(
d
a
i
j
(
x
)
d
x
)
m
×
n
A'(x)=\frac{dA(x)}{dx}=\left(\frac{da_{ij}(x)}{dx}\right)_{m\times n}
A′(x)=dxdA(x)=(dxdaij(x))m×n
设
A
(
x
)
=
(
a
i
j
(
x
)
)
m
×
n
A(x)=\left(a_{ij}(x)\right)_{m\times n}
A(x)=(aij(x))m×n 的元素在区间
[
a
,
b
]
[a,b]
[a,b] 连续,在区间
[
a
,
b
]
[a,b]
[a,b] 上的积分记为
∫
a
b
A
(
x
)
d
x
=
∫
a
b
(
a
i
j
(
x
)
d
x
)
m
×
n
\int_a^bA(x)dx=\int_a^b\left(a_{ij}(x)dx\right)_{m\times n}
∫abA(x)dx=∫ab(aij(x)dx)m×n
eg

若 A ′ ( x ) = d A ( x ) d x ≡ 0 A'(x)=\frac{dA(x)}{dx}\equiv 0 A′(x)=dxdA(x)≡0 ⟺ \iff ⟺ A ( x ) = D ( 常数矩阵 ) A(x)=D(常数矩阵) A(x)=D(常数矩阵)
求和求导:设 A ( x ) = ( a i j ( x ) ) n × n A(x)=(a_{ij}(x))_{n\times n} A(x)=(aij(x))n×n , B ( x ) = ( b i j ( x ) ) n × n B(x)=(b_{ij}(x))_{n\times n} B(x)=(bij(x))n×n 在区间 [ a , b ] [a,b] [a,b] 可到,则有 d ( A ( x ) + B ( x ) ) d x = d A ( x ) d x + d B ( x ) d x = A ′ ( x ) + B ′ ( x ) \frac{d(A(x)+B(x))}{dx}=\frac{dA(x)}{dx}+\frac{dB(x)}{dx}=A'(x)+B'(x) dxd(A(x)+B(x))=dxdA(x)+dxdB(x)=A′(x)+B′(x)
乘积求导:

参数化:

求和积分:

积分倍乘:


N-L公式

逆阵求导:


对于三个矩阵函数
f
(
t
A
)
=
e
t
A
,
c
o
s
(
t
A
)
,
s
i
n
(
t
A
)
f(tA)=e^{tA},cos(tA),sin(tA)
f(tA)=etA,cos(tA),sin(tA) ,设方阵
A
∈
C
n
×
n
A\in C^{n\times n}
A∈Cn×n ,则有求导公式
d
e
t
A
d
t
=
A
e
t
A
d
(
s
i
n
(
t
A
)
)
d
t
=
A
c
o
s
(
t
A
)
d
c
o
s
(
t
A
)
d
t
=
−
A
s
i
n
(
t
A
)
\begin{aligned} &\frac{de^{tA}}{dt}=Ae^{tA}\\ &\frac{d(sin(tA))}{dt}=Acos(tA)\\ &\frac{dcos(tA)}{dt}=-Asin(tA) \end{aligned}
dtdetA=AetAdtd(sin(tA))=Acos(tA)dtdcos(tA)=−Asin(tA)
SP
d e − t A d t = − A e − t A d [ e − t A X ( t ) ] d t = X ′ ( t ) e − t A − A X ( t ) e − t A \begin{aligned} &\frac{de^{-tA}}{dt}=-Ae^{-tA}\\ &\frac{d[e^{-tA}X(t)]}{dt}=X'(t)e^{-tA}-AX(t)e^{-tA} \end{aligned} dtde−tA=−Ae−tAdtd[e−tAX(t)]=X′(t)e−tA−AX(t)e−tA
由欧拉公式
e t x = c o s t x + i s i n t x , e − t x = c o s t x − i s i n t x c o s ( t x ) = e i t x + e − i t x 2 , s i n ( t x ) = e i t A − e − i t A 2 i e^{tx}=costx+isintx,e^{-tx}=costx-isintx\\ cos(tx)=\frac{e^{itx}+e^{-itx}}{2},sin(tx)=\frac{e^{itA}-e^{-itA}}{2i} etx=costx+isintx,e−tx=costx−isintxcos(tx)=2eitx+e−itx,sin(tx)=2ieitA−e−itA
d c o s ( t A ) d t = 1 2 ( e i t A i A − i A e − i t A ) = i 2 2 i A ( e i t A − e − i t A ) = − e i t A − e − i t A 2 i A = − A s i n ( t A ) d s i n ( t A ) d t = 1 2 i ( e i t A i A + i A e − i t A ) = i 2 i A ( e i t A + e − i t A ) = e i t A + e − i t A 2 A = A s i n ( t A ) \frac{dcos(tA)}{dt}=\frac{1}{2}(e^{itA}iA-iAe^{-itA})=\frac{i^2}{2i}A(e^{itA}-e^{-itA})=-\frac{e^{itA}-e^{-itA}}{2i}A=-Asin(tA)\\ \frac{dsin(tA)}{dt}=\frac{1}{2i}(e^{itA}iA+iAe^{-itA})=\frac{i}{2i}A(e^{itA}+e^{-itA})=\frac{e^{itA}+e^{-itA}}{2}A=Asin(tA) dtdcos(tA)=21(eitAiA−iAe−itA)=2ii2A(eitA−e−itA)=−2ieitA−e−itAA=−Asin(tA)dtdsin(tA)=2i1(eitAiA+iAe−itA)=2iiA(eitA+e−itA)=2eitA+e−itAA=Asin(tA)
若已知 W ( t ) = f ( t A ) W(t)=f(tA) W(t)=f(tA) ,两边求导 d f ( t A ) d t = d W ( t ) d t ⇒ W ′ ( t ) = A f ′ ( t A ) \frac{df(tA)}{dt}=\frac{dW(t)}{dt}\Rightarrow W'(t)=Af'(tA) dtdf(tA)=dtdW(t)⇒W′(t)=Af′(tA)
若 W ( t ) = e t A W(t)=e^{tA} W(t)=etA ,两边求导 d W ( t ) d t = d ( e t A ) d t ⇒ W ′ ( t ) = A e t A \frac{dW(t)}{dt}=\frac{d(e^{tA})}{dt} \Rightarrow W'(t)=Ae^{tA} dtdW(t)=dtd(etA)⇒W′(t)=AetA

d e t A d t = ( ( c o s a t ) ′ ( − s i n a t ) ′ ( s i n a t ) ′ ( c o s a t ) ′ ) = ( − a s i n a t − a c o s a t a c o s a t − a s i n a t ) 令 t = 0 , 得 A = ( 0 − a a 0 ) \begin{aligned} &\frac{de^{tA}}{dt}=\left( \begin{matrix} (cosat)'&(-sinat)'\\(sinat)'&(cosat)' \end{matrix} \right)=\left( \begin{matrix} -asinat&-acosat\\acosat&-asinat \end{matrix} \right)\\ &令t=0,得A=\left( \begin{matrix} 0&-a\\a&0 \end{matrix} \right) \end{aligned} dtdetA=((cosat)′(sinat)′(−sinat)′(cosat)′)=(−asinatacosat−acosat−asinat)令t=0,得A=(0a−a0)

令 e t A = e 2 t B , 则 ( e t A ) ′ = ( e 2 t B ) ′ = 2 e 2 t B + e 2 t B ′ = 2 e 2 t ( 1 0 0 t 1 − t t t − t 1 + t ) + e 2 t ( 0 0 0 1 − 1 1 1 − 1 1 ) = e 2 t ( 2 0 0 2 t + 1 1 − 2 t 2 t + 1 2 t + 1 − 2 t − 1 3 + 2 t ) 由于 ( e t A ) ′ = A e t A , 若 t = 0 ,可得 A = ( e t A ) ′ , 代入的 A = ( 2 0 0 1 1 1 1 − 1 3 ) \begin{aligned} &令e^{tA}=e^{2t}B,则(e^{tA})'=(e^{2t}B)'=2e^{2t}B+e^{2t}B'=2e^{2t}\left( \begin{matrix} 1&0&0\\t&1-t&t\\t&-t&1+t \end{matrix} \right)+e^{2t}\left( \begin{matrix} 0&0&0\\1&-1&1\\1&-1&1 \end{matrix} \right)\\ &=e^{2t}\left( \begin{matrix} 2&0&0\\2t+1&1-2t&2t+1\\2t+1&-2t-1&3+2t \end{matrix} \right)\\ &由于(e^{tA})'=Ae^{tA},若t=0,可得A=(e^{tA})',代入的A=\left( \begin{matrix} 2&0&0\\1&1&1\\1&-1&3 \end{matrix} \right) \end{aligned} 令etA=e2tB,则(etA)′=(e2tB)′=2e2tB+e2tB′=2e2t 1tt01−t−t0t1+t +e2t 0110−1−1011 =e2t 22t+12t+101−2t−2t−102t+13+2t 由于(etA)′=AetA,若t=0,可得A=(etA)′,代入的A= 21101−1013
对于一阶线性常系数微分方程,有 { d x 1 ( t ) d t = a 11 x 1 ( t ) + ⋯ + a 1 n x n ( t ) + f 1 ( t ) ⋮ d x n ( t ) d t = a n 1 x 1 ( t ) + ⋯ + a n n x n ( t ) + f n ( t ) , 满足 x i ( t 0 ) = c i , i = 1 , ⋯ , n 若令 A = ( a i j ) n × n , c ⃗ = ( c 1 ⋮ c n ) , x ( t ) = ( x 1 ( t ) x 2 ( t ) ⋮ x n ( t ) ) , f ( t ) = ( f 1 ( t ) ⋮ f n ( t ) ) 可表示为 { d x ( t ) d t = A x ( t ) + f ( t ) x ( t = 0 ) = c ⃗ , 其中 f ( t ) 为非齐次项 若 f ( t ) = ( f 1 ( t ) ⋮ f n ( t ) ) = 0 ⃗ , 可得齐次微分方程, { d x ( t ) d t = A x ( t ) x ( t = 0 ) = c ⃗ \begin{aligned} &对于一阶线性常系数微分方程,有\left\{ \begin{aligned} \frac{dx_1(t)}{dt}&=a_{11}x_1(t)+\cdots+a_{1n}x_n(t)+f_1(t)\\ &\vdots\\ \frac{dx_n(t)}{dt}&=a_{n1}x_1(t)+\cdots+a_{nn}x_n(t)+f_n(t)\\ \end{aligned} \right. ,满足x_i(t_0)=c_i,i=1,\cdots,n\\ &若令A=\left(a_{ij}\right)_{n\times n},\vec{c}=\left( \begin{matrix} c_1\\\vdots\\c_n \end{matrix} \right),x(t)=\left( \begin{matrix} x_1(t)\\x_2(t)\\\vdots\\x_n(t) \end{matrix} \right),f(t)=\left( \begin{matrix} f_1(t)\\\vdots\\f_n(t) \end{matrix} \right)\\ &可表示为\left\{ \begin{aligned} &\frac{dx(t)}{dt}=Ax(t)+f(t)\\ &x(t=0)=\vec{c} \end{aligned} \right.,其中f(t)为非齐次项\\ &若f(t)=\left( \begin{matrix} f_1(t)\\\vdots\\f_n(t) \end{matrix} \right)=\vec{0},可得齐次微分方程,\left\{ \begin{aligned} &\frac{dx(t)}{dt}=Ax(t)\\ &x(t=0)=\vec{c} \end{aligned} \right. \end{aligned} 对于一阶线性常系数微分方程,有⎩ ⎨ ⎧dtdx1(t)dtdxn(t)=a11x1(t)+⋯+a1nxn(t)+f1(t)⋮=an1x1(t)+⋯+annxn(t)+fn(t),满足xi(t0)=ci,i=1,⋯,n若令A=(aij)n×n,c= c1⋮cn ,x(t)= x1(t)x2(t)⋮xn(t) ,f(t)= f1(t)⋮fn(t) 可表示为⎩ ⎨ ⎧dtdx(t)=Ax(t)+f(t)x(t=0)=c,其中f(t)为非齐次项若f(t)= f1(t)⋮fn(t) =0,可得齐次微分方程,⎩ ⎨ ⎧dtdx(t)=Ax(t)x(t=0)=c
若 d A ( t ) d t = A ′ ( t ) ≡ 0 , 则 A ( t ) ≡ 0 若\frac{dA(t)}{dt}=A'(t)\equiv 0,则A(t)\equiv 0 若dtdA(t)=A′(t)≡0,则A(t)≡0
齐次方程组 d A ( t ) d t = A x 有唯一解公式 : x = e A t c ⃗ ,即 x = e A t x ( 0 ) 齐次方程组 \frac{dA(t)}{dt}=Ax有唯一解公式:x=e^{At}\vec{c},即x=e^{At}x(0) 齐次方程组dtdA(t)=Ax有唯一解公式:x=eAtc,即x=eAtx(0)

eg

( 1 ) 求 e t A A − I = ( − 4 4 2 − 2 2 1 − 2 2 1 ) = ( 2 1 1 ) ( − 2 , 2 , 1 ) , r ( A − I ) = 1 , 且 λ ( A − I ) = { − 1 , 0 , 0 } ⇒ λ ( A ) = { 0 , 1 , 1 } 对于 2 重根 λ 2 = 1 , 有 r ( A − I ) = 3 − 2 = 1 , 故 A 为单阵 A 有谱分解, A = λ 1 G 1 + λ 2 G 2 ,令 f ( x ) = e t x , f ( λ 1 ) = e 0 = 1 , f ( λ 2 ) = e t ⋅ 1 = e t , G 1 = A − λ 2 I λ 1 − λ 2 = I − A , G 2 = A − λ 1 I λ 2 − λ 1 = A e t A = f ( λ 1 ) G 1 + f ( λ 2 ) G 2 = G 1 + e t G 2 = I − A + e t A = I + ( e t − 1 ) A = ( 4 − 3 e t 4 e t − 4 2 e t − 2 2 − 2 e t 3 e t − 2 e t − 1 2 − 2 e t 2 e t − 2 2 e t − 1 ) ( 2 ) 求齐次线性方程的解 X = e t A c ⃗ = ( 4 − 3 e t 4 e t − 4 2 e t − 2 2 − 2 e t 3 e t − 2 e t − 1 2 − 2 e t 2 e t − 2 2 e t − 1 ) ( 0 1 0 ) = ( 4 e t − 4 3 e t − 2 2 e t − 2 ) ( 3 ) 代入 t = 0 检验 , X ( 0 ) = ( 0 1 0 ) = c ⃗ \begin{aligned} &(1)求e^{tA}\\ &A-I=\left( \begin{matrix} -4&4&2\\-2&2&1\\-2&2&1 \end{matrix} \right)=\left( \begin{matrix} 2\\1\\1 \end{matrix} \right)(-2,2,1),r(A-I)=1,且\lambda(A-I)=\{-1,0,0\}\Rightarrow \lambda(A)=\{0,1,1\}\\ &对于2重根\lambda_2=1,有r(A-I)=3-2=1,故A为单阵\\ &A有谱分解,A=\lambda_1G_1+\lambda_2G_2,令f(x)=e^{tx},f(\lambda_1)=e^{0}=1,f(\lambda_2)=e^{t\cdot1}=e^t,G_1=\frac{A-\lambda_2I}{\lambda_1-\lambda_2}=I-A,G_2=\frac{A-\lambda_1I}{\lambda_2-\lambda_1}=A\\ &e^{tA}=f(\lambda_1)G_1+f(\lambda_2)G_2=G_1+e^tG_2=I-A+e^tA=I+(e^t-1)A=\left( \begin{matrix} 4-3e^t&4e^t-4&2e^t-2\\2-2e^t&3e^t-2&e^t-1\\2-2e^t&2e^t-2&2e^t-1 \end{matrix} \right)\\ &(2)求齐次线性方程的解X=e^{tA}\vec{c}=\left( \begin{matrix} 4-3e^t&4e^t-4&2e^t-2\\2-2e^t&3e^t-2&e^t-1\\2-2e^t&2e^t-2&2e^t-1 \end{matrix} \right)\left( \begin{matrix} 0\\1\\0 \end{matrix} \right)=\left( \begin{matrix} 4e^t-4\\3e^t-2\\2e^t-2 \end{matrix} \right)\\ &(3)代入t=0检验,X(0)=\left( \begin{matrix} 0\\1\\0 \end{matrix} \right)=\vec{c} \end{aligned} (1)求etAA−I= −4−2−2422211 = 211 (−2,2,1),r(A−I)=1,且λ(A−I)={−1,0,0}⇒λ(A)={0,1,1}对于2重根λ2=1,有r(A−I)=3−2=1,故A为单阵A有谱分解,A=λ1G1+λ2G2,令f(x)=etx,f(λ1)=e0=1,f(λ2)=et⋅1=et,G1=λ1−λ2A−λ2I=I−A,G2=λ2−λ1A−λ1I=AetA=f(λ1)G1+f(λ2)G2=G1+etG2=I−A+etA=I+(et−1)A= 4−3et2−2et2−2et4et−43et−22et−22et−2et−12et−1 (2)求齐次线性方程的解X=etAc= 4−3et2−2et2−2et4et−43et−22et−22et−2et−12et−1 010 = 4et−43et−22et−2 (3)代入t=0检验,X(0)= 010 =c

令 A = ( 3 − 1 1 1 ) , X = ( x y ) , 可写方程 d X d t = A X , 通解公式为 X = e t A c ⃗ , c ⃗ t = 0 = ( c 1 c 2 ) ( 1 ) A 为行和矩阵, λ ( A ) = { 2 , t r ( A ) − 2 } = { 2 , 2 } , A − 2 I = ( 1 − 1 1 − 1 ) , r ( A − 2 I ) = 1 ≠ 2 − 2 = 0 A 不是单阵, ( A − 2 I ) 2 = 0 , 故由平移幂 0 阵可写解析函数 f ( x ) = f ( 2 ) + f ′ ( 2 ) ( A − 2 I ) 矩阵函数为 f ( A ) = f ( 2 ) I + f ′ ( 2 ) ( A − 2 I ) 令 f ( A ) = e t x , f ( 2 ) = e 2 t , f ′ ( 2 ) = t e 2 t , 则 e t A = e 2 t I + t e 2 t ( A − 2 I ) = e 2 t [ I + t ( A − 2 I ) ] = e 2 t [ ( 1 1 ) + ( t − t t − t ) ] = e 2 t ( 1 + t − t t 1 − t ) ( 2 ) 求通解 X = e t A C = e 2 t ( 1 + t − t t 1 − t ) ( c 1 c 2 ) = e 2 t ( ( 1 + t ) c 1 − t c 2 t c 1 + ( 1 − t ) c 2 ) { x = e 2 t [ ( 1 + t ) c 1 − t c 2 ] y = e 2 t [ t c 1 + ( 1 − t ) c 2 ] , c 1 , c 2 为任意常数 \begin{aligned} &令A=\left( \begin{matrix} 3&-1\\1&1 \end{matrix} \right),X=\left( \begin{matrix} x\\y \end{matrix} \right),可写方程\frac{dX}{dt}=AX,通解公式为X=e^{tA}\vec{c},\vec{c}_{t=0}=\left( \begin{matrix} c_1\\c_2 \end{matrix} \right)\\ &(1)A为行和矩阵,\lambda(A)=\{2,tr(A)-2\}=\{2,2\},A-2I=\left( \begin{matrix} 1&-1\\1&-1 \end{matrix} \right),r(A-2I)=1\neq2-2=0\\ &\quad A不是单阵,(A-2I)^2=0,故由平移幂0阵可写解析函数f(x)=f(2)+f'(2)(A-2I)\\ &\quad 矩阵函数为f(A)=f(2)I+f'(2)(A-2I)\\ &\quad 令f(A)=e^{tx},f(2)=e^{2t},f'(2)=te^{2t},则e^{tA}=e^{2t}I+te^{2t}(A-2I)=e^{2t}\left[ I+t(A-2I) \right]=e^{2t}\left[ \left( \begin{matrix} 1&\\&1 \end{matrix} \right)+\begin{aligned} \left( \begin{matrix} t&-t\\t&-t \end{matrix} \right) \end{aligned} \right]=e^{2t}\left( \begin{matrix} 1+t&-t\\t&1-t \end{matrix} \right)\\ &(2) 求通解X=e^{tA}C=e^{2t}\left( \begin{matrix} 1+t&-t\\t&1-t \end{matrix} \right)\left( \begin{matrix} c_1\\c_2 \end{matrix} \right)=e^{2t}\left( \begin{matrix} (1+t)c_1-tc_2\\tc_1+(1-t)c_2 \end{matrix} \right)\\ &\quad \left\{ \begin{aligned} &x=e^{2t}[(1+t)c_1-tc_2]\\ &y=e^{2t}[tc_1+(1-t)c_2] \end{aligned} \right.,c_1,c_2为任意常数 \end{aligned} 令A=(31−11),X=(xy),可写方程dtdX=AX,通解公式为X=etAc,ct=0=(c1c2)(1)A为行和矩阵,λ(A)={2,tr(A)−2}={2,2},A−2I=(11−1−1),r(A−2I)=1=2−2=0A不是单阵,(A−2I)2=0,故由平移幂0阵可写解析函数f(x)=f(2)+f′(2)(A−2I)矩阵函数为f(A)=f(2)I+f′(2)(A−2I)令f(A)=etx,f(2)=e2t,f′(2)=te2t,则etA=e2tI+te2t(A−2I)=e2t[I+t(A−2I)]=e2t[(11)+(tt−t−t)]=e2t(1+tt−t1−t)(2)求通解X=etAC=e2t(1+tt−t1−t)(c1c2)=e2t((1+t)c1−tc2tc1+(1−t)c2){x=e2t[(1+t)c1−tc2]y=e2t[tc1+(1−t)c2],c1,c2为任意常数

令
y
=
x
′
=
x
′
(
t
)
,
可写方程组
{
d
x
d
t
=
y
d
y
d
t
=
−
x
⟺
{
d
d
t
(
x
y
)
=
(
0
1
−
1
0
)
(
x
y
)
令
X
=
(
x
y
)
,
A
=
(
0
1
−
1
0
)
⇒
d
X
d
t
=
A
X
通解公式为
e
t
A
c
⃗
t
=
0
,
c
⃗
t
=
0
=
(
c
1
c
2
)
⇒
e
t
A
=
(
c
o
s
t
s
i
n
t
−
s
i
n
t
c
o
s
t
)
可知
X
=
e
t
A
C
=
(
c
o
s
t
s
i
n
t
−
s
i
n
t
c
o
s
t
)
(
c
1
c
2
)
=
(
c
1
c
o
s
t
+
c
2
s
i
n
t
c
2
c
o
s
t
−
c
1
s
i
n
t
)
,故原方程通解
x
=
c
1
c
o
s
t
+
c
2
s
i
n
t
\begin{aligned} &令y=x'=x'(t),可写方程组\left\{ \begin{aligned} &\frac{dx}{dt}=y\\ &\frac{dy}{dt}=-x \end{aligned} \right.\iff \left\{ \frac{d}{dt}\left( \begin{matrix} x\\y \end{matrix} \right) \right.=\left( \begin{matrix} 0&1\\-1&0 \end{matrix} \right)\left( \begin{matrix} x\\y \end{matrix} \right)\\ &令X=\left( \begin{matrix} x\\y \end{matrix} \right),A=\left( \begin{matrix} 0&1\\-1&0 \end{matrix} \right)\Rightarrow \frac{dX}{dt}=AX\\ &通解公式为 e^{tA}\vec{c}_{t=0},\vec{c}_{t=0}=\left( \begin{matrix} c_1\\c_2 \end{matrix} \right)\Rightarrow e^{tA}=\left( \begin{matrix} cost&sint\\-sint&cost \end{matrix} \right)\\ &可知X=e^{tA}C=\left( \begin{matrix} cost&sint\\-sint&cost \end{matrix} \right)\left( \begin{matrix} c_1\\c_2 \end{matrix} \right)=\left( \begin{matrix} c_1cost+c_2sint\\c_2cost-c_1sint \end{matrix} \right),故原方程通解x=c_1cost+c_2sint \end{aligned}
令y=x′=x′(t),可写方程组⎩
⎨
⎧dtdx=ydtdy=−x⟺{dtd(xy)=(0−110)(xy)令X=(xy),A=(0−110)⇒dtdX=AX通解公式为etAct=0,ct=0=(c1c2)⇒etA=(cost−sintsintcost)可知X=etAC=(cost−sintsintcost)(c1c2)=(c1cost+c2sintc2cost−c1sint),故原方程通解x=c1cost+c2sint

x ′ ′ = − a 2 x , 令 { x ′ = a y ( t ) y ′ ( t ) = − a x ( a y ′ ( t ) = − a 2 x = x 2 ) , 即 d X d t = A X , A = { 0 a − a 0 } , X = ( x y ) 通解为 X = e t A C , 其中 e t A = e ( 0 a t − a t 0 ) = ( c o s a t s i n a t − s i n a t c o s a t ) , 设 C = ( c 1 c 2 ) X = e t A C = ( c o s a t s i n a t − s i n a t c o s a t ) ( c 1 c 2 ) = ( c 1 c o s a t + c 2 s i n a t c 2 c o s a t − c 1 s i n a t ) \begin{aligned} &x''=-a^2x,令\left\{ \begin{aligned} &x'=ay(t)\\ &y'(t)=-ax&(ay'(t)=-a^{2}x=x^2) \end{aligned} \right.,即\frac{dX}{dt}=AX,A=\left\{ \begin{matrix} 0&a\\-a&0 \end{matrix} \right\},X=\left( \begin{matrix} x\\y \end{matrix} \right)\\ &通解为 X=e^{tA}C,其中e^{tA}=e^{\left( \begin{matrix} 0&at\\-at&0 \end{matrix} \right)}=\left( \begin{matrix} cosat&sinat\\-sinat&cosat \end{matrix} \right),设C=\left( \begin{matrix} c_1\\c_2 \end{matrix} \right)\\ &X=e^{tA}C=\left( \begin{matrix} cosat&sinat\\-sinat&cosat \end{matrix} \right)\left( \begin{matrix} c_1\\c_2 \end{matrix} \right)=\left( \begin{matrix} c_1cosat+c_2sinat\\ c_2cosat-c_1sinat \end{matrix} \right) \end{aligned} x′′=−a2x,令{x′=ay(t)y′(t)=−ax(ay′(t)=−a2x=x2),即dtdX=AX,A={0−aa0},X=(xy)通解为X=etAC,其中etA=e(0−atat0)=(cosat−sinatsinatcosat),设C=(c1c2)X=etAC=(cosat−sinatsinatcosat)(c1c2)=(c1cosat+c2sinatc2cosat−c1sinat)
我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re
我正在尝试用ruby中的gsub函数替换字符串中的某些单词,但有时效果很好,在某些情况下会出现此错误?这种格式有什么问题吗NoMethodError(undefinedmethod`gsub!'fornil:NilClass):模型.rbclassTest"replacethisID1",WAY=>"replacethisID2andID3",DELTA=>"replacethisID4"}end另一个模型.rbclassCheck 最佳答案 啊,我找到了!gsub!是一个非常奇怪的方法。首先,它替换了字符串,所以它实际上修改了
我有一些代码在几个不同的位置之一运行:作为具有调试输出的命令行工具,作为不接受任何输出的更大程序的一部分,以及在Rails环境中。有时我需要根据代码的位置对代码进行细微的更改,我意识到以下样式似乎可行:print"Testingnestedfunctionsdefined\n"CLI=trueifCLIdeftest_printprint"CommandLineVersion\n"endelsedeftest_printprint"ReleaseVersion\n"endendtest_print()这导致:TestingnestedfunctionsdefinedCommandLin
点向量坐标矩阵的几何意义介绍旋转矩阵的几何含义之前,先介绍一下点向量坐标矩阵的几何含义点:在一维空间下就是一个标量,如同一条直线上,以任意某一个位置为0点,以一定的尺度间隔为1,2,3...,相反方向为-1,-2,-3...;如此就形成了一维坐标系,这时候任何一个点都可以用一个数值表示,如点p1=5,即即从原点出发沿着x轴正方向移动5个尺度;点p2=-3,负方向移动3个尺度; 在一维坐标系上过原点做垂直于一维坐标系的直线,则形成了二维坐标系,此时描述一个点需要两个数值来表示点p3=(3,2),即从原点出发沿着x轴正方向移动3个尺度,在此基础上沿着y轴正方向移动两个尺度的位置就是点p3。
如何在Ruby中按名称传递函数?(我使用Ruby才几个小时,所以我还在想办法。)nums=[1,2,3,4]#Thisworks,butismoreverbosethanI'dlikenums.eachdo|i|putsiend#InJS,Icouldjustdosomethinglike:#nums.forEach(console.log)#InF#,itwouldbesomethinglike:#List.iternums(printf"%A")#InRuby,IwishIcoulddosomethinglike:nums.eachputs在Ruby中能不能做到类似的简洁?我可以只
说在前面这部分我本来是合为一篇来写的,因为目的是一样的,都是通过独立按键来控制LED闪灭本质上是起到开关的作用,即调用函数和中断函数。但是写一篇太累了,我还是决定分为两篇写,这篇是调用函数篇。在本篇中你主要看到这些东西!!!1.调用函数的方法(主要讲语法和格式)2.独立按键如何控制LED亮灭3.程序中的一些细节(软件消抖等)1.调用函数的方法思路还是比较清晰地,就是通过按下按键来控制LED闪灭,即每按下一次,LED取反一次。重要的是,把按键与LED联系在一起。我打算用K1来作为开关,看了一下开发板原理图,K1连接的是单片机的P31口,当按下K1时,P31是与GND相连的,也就是说,当我按下去时
我需要一个通过输入字符串进行计算的方法,像这样function="(a/b)*100"a=25b=50function.something>>50有什么方法吗? 最佳答案 您可以使用instance_eval:function="(a/b)*100"a=25.0b=50instance_evalfunction#=>50.0请注意,使用eval本质上是不安全的,尤其是当您使用外部输入时,因为它可能包含注入(inject)的恶意代码。另请注意,a设置为25.0而不是25,因为如果它是整数a/b将导致0(整数)。
我需要从json记录中获取一些值并像下面这样提取curr_json_doc['title']['genre'].map{|s|s['name']}.join(',')但对于某些记录,curr_json_doc['title']['genre']可以为空。所以我想对map和join()使用try函数。我试过如下curr_json_doc['title']['genre'].try(:map,{|s|s['name']}).try(:join,(','))但是没用。 最佳答案 你没有正确传递block。block被传递给参数括号外的方法
在这段Ruby代码中:ModuleMClassC当我尝试运行时出现“'M:Module'的未定义方法'helper'”错误c=M::C.new("world")c.work但直接从另一个类调用M::helper("world")工作正常。类不能调用在定义它们的同一模块中定义的模块函数吗?除了将类移出模块外,还有其他解决方法吗? 最佳答案 为了调用M::helper,你需要将它定义为defself.helper;结束为了进行比较,请查看以下修改后的代码段中的helper和helper2moduleMclassC
也许这听起来很荒谬,但我想知道这对Ruby是否可行?基本上我有一个功能...defadda,bc=a+breturncend我希望能够将“+”或其他运算符(例如“-”)传递给函数,这样它就类似于...defsuma,b,operatorc=aoperatorbreturncend这可能吗? 最佳答案 两种可能性:以方法/算子名作为符号:defsuma,b,operatora.send(operator,b)endsum42,23,:+或者更通用的解决方案:采取一个block:defsuma,byielda,bendsum42,23,