# Eliminate the higher powers of eigenvalues of a matrix

I want to found de eigenvalue of following matrix

gh[A_, B_, Z_, M_, X_,S_] := {{Z, A, B, 0, 0, 0, 0, S}, {A, M, 0, A, 0, -S, 0, 0}, {B, 0,X, B, 0, 0, -S, 0}, {0, A, B, Z, S, 0, 0, 0}, {0, 0,0, -S, -Z, -A, -B, 0}, {0, S, 0, 0, -A, M, 0, -A}, {0, 0, S, 0, -B,0, X, -B}, {-S, 0, 0, 0, 0, -A, -B, -Z}}


i use the intructions:

F[A_,B_]:=ToRadicals[Eigenvalues[gh[A, B, Z, M, X, S]]];


I need to eliminate the higher powers of 2 from A and B,

F[A,B]/.{ A^b_ /; b >= 3 -> 0 }/. {B^b_ /; b >= 3 -> 0}


To test this instruction I consider that I eliminate all A and B with powers greater than or equal to 1, but the results is very long and different that F[0,0]

F[A,B]/.{ A^b_ /; b >= 0 -> 0 }/. {B^b_ /; b >= 0 -> 0}


For the case b>=3, The ToRadicals function does not eliminate the roots

Let be

ei = Eigenvalues[gh[A, B, Z, M, X, S]]


Try this:

(ei[[3]] /. (A^b_ /; b >= 3) :> 0 /. (B^b_ /; b >= 3) :> 0)


The result is long.

ei[[3]] /. {A -> 0, B -> 0} // ToRadicals

(*  -I (S + I X)  *)