Skip to content
DeepForgeby svx
All problems
MediumLinear Algebrala-118

Characteristic Polynomial 2x2

Problem

Return the coefficients [1.0, b, c] of the characteristic polynomial of a 2x2 matrix A:

lambda^2 - trace(A)*lambda + det(A)

So b = -trace(A) and c = det(A).

Hint

The leading coefficient of a monic characteristic polynomial is always 1.

Test cases

case 1
in: [[[2,0],[0,3]]]
expected: [1,-5,6]
case 2
in: [[[4,1],[2,3]]]
expected: [1,-7,10]
case 3
in: [[[0,1],[-2,-3]]]
expected: [1,3,2]
case 4
in: [[[1,1],[-1,1]]]
expected: [1,-2,2]
Starter codePython
def char_poly_2x2(A):
    # Your code here
    pass

4 test cases · run your code against them in the editor