library(pracma) A <- matrix(c(3, 2, 1, 0, 1, 1, 1, 2, 0), nrow = 3, byrow = TRUE) char_poly <- charpoly(A) char_poly
## [1] 1 -4 0 5