This looks like you are trying to solve the generalized eigenvalue problem, with y
being the unknown generalized eigenvalue λ and x
being the corresponding generalized eigenvector. If that is what you want, you can use scipy.linalg.eig
. Here's an example.
To keep the output readable, I'll use arrays with shape (2, 2).
In [91]: from scipy.linalg import eig
In [92]: A
Out[92]:
array([[2, 3],
[1, 1]])
In [93]: B
Out[93]:
array([[0, 1],
[3, 0]])
These are the matrices in the equation.
In [94]: a = A.T.dot(A)
In [95]: b = B.dot(B.T)
Solve the generalized eigenvalue problem:
In [96]: lam, v = eig(a, b)
These are the generalized eigenvalues (your y
):
In [97]: lam
Out[97]: array([ 6.09287487+0.j, 0.01823624+0.j])
The columns of v
are the generalized eigenvectors (your x
):
In [98]: v
Out[98]:
array([[ 0.98803087, -0.81473616],
[ 0.1542563 , 0.57983187]])
Verify the solution. Note that the results are on the order of 1e-16, i.e. numerically close to 0.
In [99]: (a - lam[0]*b).dot(v[:,0])
Out[99]: array([ 2.22044605e-16+0.j, -8.88178420e-16+0.j])
In [100]: (a - lam[1]*b).dot(v[:,1])
Out[100]: array([ 0.+0.j, 0.+0.j])