(1)
>> diag(sym('a%d',[1,12]))
(2)
>> A=eye(4),B=diag([1,2,3,4])
>> A=sym(A);
>> A*B,B*A
(3)
J1=-5*eye(5)+diag(ones(4,1),1)
(4)
while(1),A=randi([0,1],10);if det(A)==1,break;end,end
(5)
>> clear
>> syms a b x;
>> v=sym(zeros(20,1));v(20)=b;
>> A=a*eye(20)+hankel(v);B=(x-a)*eye(20)+a*ones(20);
>> det(A),simplify(det(B)),trace(A),trace(B),charpoly(A),charploy(B)
(6)
n=10;a=ones(1,n);H=diag(a,1);H^(n+1);
(7)
>> A=[ 5 7 6 5 1 6 5;
2 3 1 0 0 1 4;
6 4 2 0 6 4 4;
3 9 6 3 6 6 2;
10 7 6 0 0 7 7;
7 2 4 4 0 7 7;
4 8 6 7 2 1 7];
>> B=[ 3 5 5 0 1 2 3;
3 2 5 4 6 2 5;
1 2 1 1 3 4 6;
3 5 1 5 2 1 2;
4 1 0 1 2 0 1;
-3 -4 -7 3 7 8 12;
1 -10 7 -6 8 1 5];
>> A2=sym(A);B2=sym(B);
(8)
>> syms a x;v=sym('x%d',[10,1]);
>> clear;
>> n=10;syms a x;v=sym('x%d',[n,1]);
>> A=a*ones(n)+(x-2*a)*eye(n);B=a*ones(n)+diag(v-a*ones(n,1))
>> simplify(det(A)),simplify(det(B))
(9)
>> syms alpha beta gamma delta real;
>> v=[alpha beta gamma];
>> A=[sin(v') cos(v') sin(v'+delta)]
>> simplify(det(A))
>> syms x y z a b c;
>> f(x,a)=(a^x+a^(-x))^2;g(x,a)=(a^x-a^(-x))^2;
>> B=[f(x,a) g(x,a) 1;f(y,b) g(y,b) 1;f(z,c) g(z,c) 1]
>> simplify(det(B))
(10)
>> syms a b c d e;vec=[a b c d e];simplify(det(vander(vec)))
(11)
>> ss=0;for k=1:2:100,if(det(magic(sym(k)))==0),ss=ss+1;end ,end
(12)使用第(7)题的矩阵A、B
>> A=sym(A);det(A),rank(A),trace(A),inv(A)*A,A*inv(A);
>> B=sym(B);det(B),rank(B),trace(B),pinv(B)*B,B*pinv(B);
(13)同上使用(7)的A、B
>> A=[ 5 7 6 5 1 6 5;2 3 1 0 0 1 4;6 4 2 0 6 4 4;3 9 6 3 6 6 2;10 7 6 0 0 7 7; 7 2 4 4 0 7 7;4 8 6 7 2 1 7];
>> B=[ 3 5 5 0 1 2 3;3 2 5 4 6 2 5;1 2 1 1 3 4 6;3 5 1 5 2 1 2;4 1 0 1 2 0 1;-3 -4 -7 3 7 8 12;1 -10 7 -6 8 1 5];
>> A=sym(A);B=sym(B);charpoly(A),charpoly(B),[Va,Da]=eig(A),[Vb,Db]=eig(B)
>> %转化回双精度
>> A=double(A);B=double(B);
>> p1=poly(A);p2=poly(B);norm(polyvalm(p1,A)),norm(polyvalm(p2,B))
>> p1=poly1(A);p2=poly1(B);norm(polyvalm(p1,A)),norm(polyvalm(p2,B))