## Author: M. Turhan ÇOBAN
## Created: 2021-06-13
function retval = characteristic_poly(A)
 n=length(A);
 B=A
 a=zeros(1,n+1);
 a(n+1)=1.0;
 a(n)=-trace(B);
 I=eye(n);
 for k=n-1:-1:1
   C=add(B,a(k+1))
   B=A.*C;
   a(k)=-trace(B)/(n-k);
 endfor
 retval=a;
endfunction
