2 base(pol):=if atom(pol) or inpart(pol,0) # "^" then pol else inpart(pol,1)$
4 rateigenvectors(mat,[var]):=
5 block([scalarmatrixp:false,
6 listarith:algebraic:inflag:true,
9 id:ident(length(mat))],
10 var:if var=[] then 'lambda else var[1],
11 for pol in 'false*factor(charpoly(mat,var)) do
12 if not(freeof(var,pol))
13 then (rat(base(pol),var),
14 tellrat(%%/coeff(%%,var,hipow(%%,var))),
15 ans:cons(cons(pol,args(transpose(%rateig(echelon(mat-var*id),id)))),
17 apply('tellrat,tellrats),
22 else if mat*id=id then zeromatrix(length(mat),0)
23 else if mat[1,1]=0 then addcol(col(id,1),
26 %rateig(submatrix(rest(mat,-1),1),
28 else addrow(matrix(-rest(mat[1])),id:submatrix(1,id,1))
30 %rateig(submatrix(1,mat,1),id)$