I know how to solve basic linear matrix equations with numpy.
However, I have a matrix A and the equation A^2 + xA + yI = 0, where x and y are not vectors, but rather a scalar. I is the identity matrix, and 0 is the zero matrix of dimensions matching A.
This is a super easy on paper for small matrices (assuming of course that a solution exists), but I'm practicing for a coding interview and will be expected to solve problems like this with python. And maybe the matrix given will be quite large...
Here is a sample matrix A, which results in solutions x=-2, y=1:
np.array([[1,1,0],
[0,1,0]
[0,0,1]]
On paper, this is as easy as solving the system of linear equations x = -2 and x+y=-1. The issue I am facing is parsing the equation in its form above to one that is in the form of a system of equations (or alternatively a linear matrix equation of the form Ax = B).
y
is also an unknown scalar? So you are trying to find scalarsx
andy
to satisfy the equation? - Warren Weckesser