Find characteristic Polynomial of a matrix?

I’m trying to find the Characteristic Polynomial of a matrix. I have the worked solution to the problem, but all my polynomials seem to be the solutions I find, but multiplied by -1. I don’t know what I’m doing incorrectly.

For example, I run the line"

CharacteristicPolynomial[{{-6, 4, -8}, {28, -15, 32}, {21, -12, 25}}, x]

and get

2 - 5 x + 4 x^2 - x^3

where as my book’s solution is:
-2 + 5 x - 4 x^2 + x^3

This is making my graphs completely upside-down. Here is the full problem:

[M] Let A = [ {-6, 4, -8}, {28, -15, a}, {21, -12, 25}] where each {} contains a column of matrix A

For each value of a in the set {32, 31.9, 31.8, 32.1, 32.2}, compute the characteristic polynomial of A and the eigenvalues. In each case, create a graph of the characteristic polynomial p(t) = det(A-tI) for 0<=t<=3. If possible, construct all graphs on one coordinate system. Describe how the graphs reveal the changes in the eigenvalues as a changes.

Any help would be greatly appreciated!

It is a matter of definition: as documented, Mathematica computes the characteristic polynomial of A as Det[A - x I] while some authors may use Det[x I - A]. Of course going from one definition to the other is trivial, just multiply by (-1)^First[Dimensions[A]].

Mathematica is calculating the characteristic polynomial according to the common convention:

CharacteristicPolynomial[{{-6,4,-8},{28,-15,32},{21,-12,25}},x]

(* 2-5 x+4 x^2-x^3 *)

m={{-6,4,-8},{28,-15,32},{21,-12,25}};

Det[m-IdentityMatrix[3]x]

(* 2-5 x+4 x^2-x^3 *)

It may be that your book is always adjusting the polynomial such that the sign on the highest power is positive, by multiplying by -1 as needed. There is no harm in this, since the usual use of the polynomial is to solve for its roots, which are not changed by doing this,

Best regards,

David

Sorry, Ilian. We were working together!

Edit: I think Ilian’s answer more likely, that the book is using a different convention. In any case, you can be comfortable multiplying by -1, as the roots are unchanged.

Hi,

I agree with others that the sign does not matter here. The roots are the only values of interest. It’s worthwhile – though somewhat circular – to calculate the characteristic polynomial as follows:

Poly =  Times @@ ((x - #) & /@ Eigenvalues[{{-6, 4, -8}, {28, -15, 32}, {21, -12, 25}}])
Expand@Poly

Out[]= (-2 + x) (-1 + x)^2
Out[]= -2 + 5 x - 4 x^2 + x^3

Then we see that, possibly, your book’s convention involves choice between either

P_{+}(x) = \prod (x-x_{i})
P_{-}(x) = - \prod (x-x_{i})

with x_i the i eigenvalue. I think this is probably the clearest way to state the sign convention, but it is also equivalent to saying ‘‘highest power of x positive’’.