syms X;
X=[1;1;1;1];
A1=[0 -2/5 -2/5 -12/5;
    1/4 0 -1/2 5;
    -1/5 3/10 0 3/10;
    0 0 0 1];
sym(A1*X)
sym(A1^2*X)
sym(A1^3*X)
A2=[0 -2/5 -2/5 -12/5;
    0 1 0 0;
    0 0 1 0;
    0 0 0 1];
A2=[1 0 0 0;
    1/4 0 -1/2 5;
    0 0 1 0;
    0 0 0 1]*A2
A2=[1 0 0 0;
    0 1 0 0;
    -1/5 3/10 0 3/10;
    0 0 0 1]*A2
sym(A2*X)
sym(A2^2*X)
vpa(A2^2*X,9)
sym(A2^3*X)
vpa(A2^3*X,9)

%

clc,clear;
A=[0.9 0.4 0.4;
    0.4 1 0.8;
    0.4 0.8 1];
sym(A)
L=-tril(A,-1)
U=-triu(A,1)
D=diag(diag(A))
BJ=D^(-1)*(L+U);
sym(BJ)
syms l;
eq=det(l*diag(ones(size(A(:,1))))-BJ)==0
factor(det(l*diag(ones(size(A(:,1))))-BJ))
ans=solve(eq,l)
vpa(ans,9)

% 然后发现谱半径大于1，不收敛

BS=(D-L)^(-1)*U;
sym(BS)
syms l;
l*diag(ones(size(A(:,1))))-BS
eq=det(l*diag(ones(size(A(:,1))))-BS)==0
factor(det(l*diag(ones(size(A(:,1))))-BS))
ans=solve(eq,l)
vpa(ans,9)

% 可见是收敛的
%

clc,clear;
A=[3 2 -2;
    1 1 1;
    2 2 1];
sym(A)
L=-tril(A,-1)
U=-triu(A,1)
D=diag(diag(A))
BJ=D^(-1)*(L+U);
sym(BJ)
syms l;
l*diag(ones(size(A(:,1))))-BJ
eq=det(l*diag(ones(size(A(:,1))))-BJ)==0
factor(det(l*diag(ones(size(A(:,1))))-BJ))
ans=solve(eq,l)
vpa(ans,9)
BS=(D-L)^(-1)*U;
sym((D-L)^(-1))
sym(BS)
syms l;
l*diag(ones(size(A(:,1))))-BS
eq=det(l*diag(ones(size(A(:,1))))-BS)==0
factor(det(l*diag(ones(size(A(:,1))))-BS))
ans=solve(eq,l)
vpa(ans,9)

% 所以也不收敛
%

clc,clear;
A=[3 -1 0;
    -1 4 -1;
    0 -1 4];
b=[1 4 -3]';
sym(A^(-1)*b)%精确解