1 restart(1);maple_mode(1);cas_setup(0,0,0,1,0,1e-10,10,[1,50,0,25],0,0,0); #radians,pas de cmplx, pas de  Sqrt
2/* -------------------Polynome caracteristique et mineurs diagonaux------------------------------------------------------------------------------*/
3n:=5; In:={seq(i,i=1..n)}; In minus {2,4};
4 extr:=proc(A,II,JJ)
5 matrix([seq([seq(A[i,j],j=JJ)],i=II)]);
6 end_proc;
7/* Attention, diff(f,x,y) derive en x puis y, alors que diff(f,[x,y])�donne la liste des derive en x et en y.*/
8diff(x*y,x,y);diff(x*y,[x,y]);
9 purge(a,x);
10 n:=5;A:=matrix(n,n,(i,j)->a[i,j]);
11 d:=diag(seq(x[i],i=1..n));
12 II:=In minus {1,3};# on essaye (i,j)=(1,3)
13 extr(A,II,II);
14 dij:=diff(det(A-d),x[1],x[3]);
15 normal(det( extr(A,II,II)) - subs(x=[0,0,0,0,0],dij));
16 II:=In minus {2,3};# on essaye (i,j)=(2,3)
17 extr(A,II,II);
18 dij:=diff(det(A-d),x[2],x[3]);
19 normal(det( extr(A,II,II)) - subs(x=[0,0,0,0,0],dij));
20 II:=In minus {4,5};# on essaye (i,j)=(4,5)
21 extr(A,II,II);
22 dij:=diff(det(A-d),x[4],x[5]);
23 normal(det( extr(A,II,II)) - subs(x=[0,0,0,0,0],dij));
24 B:=A-x*identity(n);
25 d:=seq(normal(subs(x=0,diff(det(B),x,i))/i!),i=n..1);
26 P:=charpoly(A);
27 monpolyfaddeev:=proc(A)
28 local a,n,B,P;
29 n:=dim(A)[1];a:=1:B:=identity(n);P:=[a];
30 for i from n-1 to 0 by -1 do
31 B:=normal(B*A);
32 a:=trace(B)/(i-n);
33 P:=[op(P),a];B:=B+a*identity(n) od;
34 P;
35 end proc:
36 n:=30;A:=matrix(n,n,(i,j)->rand(21)-10):
37 normal(poly2symb(monpolyfaddeev(A),x));
38  charpoly(A)-monpolyfaddeev(A);
39time(monpolyfaddeev(A)):
40time(charpoly(A)):
41 coeff(3*x^4+2*x^3+y^3,x,3);
42 A:=matrix(3,4,2);matrix(op(dim(A)));
43 cf:=proc(P,k)
44 local i,j;
45 matrix(op(dim(P)),(i,j)->coeff(P[i,j],x,k));
46 end_proc;
47 P:=matrix[[2*x^4+2*x^3+x^2+4,2*x^4+5*x^2+5*x+3,3*x^2+5],[2*x^4+3*x^3+6*x^2+5*x+5,x^4+4*x^3+2*x^2+x,5*x^4+5*x^3+x^2+6*x+6],[x^4+2*x^3+2*x^2+x+6,6*x^4+x^3+x^2+2,x^4+2*x^3+5*x^2+2*x+5]]; // matrix(3,3,(i,j)->add(rand(7)*x^l,l=0..4));
48A:=matrix(3,3,(i,j)->a[i,j]);
49cf(P,4);
50R:=P;k:=4;Q:=0;
51R:=normal(R-cf(R,k)*x^(k-1)*(x*identity(3)-A));Q:=cf(R,k)*x^(k-1)+Q:k:=k-1;
52R:=normal(R-cf(R,k)*x^(k-1)*(x*identity(3)-A));Q:=cf(R,k)*x^(k-1)+Q:k:=k-1;
53R:=normal(R-cf(R,k)*x^(k-1)*(x*identity(3)-A));Q:=cf(R,k)*x^(k-1)+Q:k:=k-1;
54R:=normal(R-cf(R,k)*x^(k-1)*(x*identity(3)-A));Q:=cf(R,k)*x^(k-1)+Q:k:=k-1;
55R2:=add(cf(P,i)*A^i,i=0..4):;
56normal(R2-R);
57