All problems
Minimal Polynomial 2x2
Problem
Return the coefficients of the minimal polynomial of a 2x2 matrix A.
If A = lam*I, the minimal polynomial is degree 1 and the coefficients are [1.0, -lam]. Otherwise it equals the characteristic polynomial [1.0, -tr(A), det(A)].
Hint
Scalar matrices are the only 2x2 matrices whose minimal polynomial has degree 1.
Test cases
case 1
in: [[[2,0],[0,2]]]
expected: [1,-2]
case 2
in: [[[2,0],[0,3]]]
expected: [1,-5,6]
case 3
in: [[[1,1],[0,1]]]
expected: [1,-2,1]
case 4
in: [[[0,0],[0,0]]]
expected: [1,0]
Starter codePython
def minimal_polynomial_2x2(A):
# Your code here
pass4 test cases · run your code against them in the editor