0

I have a matrix that gives out something like that:

a = 
[[ 3.14333470e-02  3.11644303e-02  3.03622814e-02  2.90406252e-02
   2.72220757e-02  2.49377488e-02  2.22267299e-02  1.91354055e-02
   1.57166688e-02  1.20290155e-02  8.13554227e-03  4.10286765e-03
  -8.19802426e-09 -4.10288390e-03 -8.13555810e-03 -1.20290306e-02
  -1.57166830e-02 -1.91354185e-02 -2.22267415e-02 -2.49377588e-02
  -2.72220839e-02 -2.90406315e-02 -3.03622856e-02 -3.11644324e-02
  -3.14333470e-02]
 [ 0.00000000e+00  2.90117128e-03  5.75270270e-03  8.50580375e-03
   1.11133681e-02  1.35307796e-02  1.57166756e-02  1.76336548e-02
   1.92489172e-02  2.05348252e-02  2.14693765e-02  2.20365808e-02
   2.22267328e-02  2.20365792e-02  2.14693735e-02  2.05348208e-02
   1.92489114e-02  1.76336477e-02  1.57166674e-02  1.35307704e-02
   1.11133581e-02  8.50579304e-03  5.75269150e-03  2.90115979e-03
  -1.15937571e-08]
 [ 0.00000000e+00  2.90117128e-03  5.75270270e-03  8.50580375e-03
   1.11133681e-02  1.35307796e-02  1.57166756e-02  1.76336548e-02
   1.92489172e-02  2.05348252e-02  2.14693765e-02  2.20365808e-02
   2.22267328e-02  2.20365792e-02  2.14693735e-02  2.05348208e-02
   1.92489114e-02  1.76336477e-02  1.57166674e-02  1.35307704e-02
   1.11133581e-02  8.50579304e-03  5.75269150e-03  2.90115979e-03
  -1.15937571e-08]]

and I want to calculate the eigenvalues and eigenvectors

w, v = numpy.linalg.eig(a) 

How can I do this?

Jolosin
  • 33
  • 1
  • 6

2 Answers2

1

You cannot directly compute the eigenvalues of the matrix since it is not square. In order to find the eigenvalues and eigenvectors, the matrix has to be diagonalized, which involves taking a matrix inversion at an intermediate step, and only square matrices are invertible.

In order to find the eigenvalues from a non-square matrix you can compute the singular value decomposition (in numpy: np.linalg.svd). You can then relate the singular values with the eigenvalues as explained here, or here. Quoting one of the answers:

Definition: The singular values of a m×n matrix A are the positive square roots of the nonzero eigenvalues of the corresponding matrix A.T*A. The corresponding eigenvectors are called the singular vectors.

yatu
  • 86,083
  • 12
  • 84
  • 139
0

Your array is not square, just fill a zero column to fix it.

import numpy 

a = numpy.array(([1,7,3,9],[3,1,5,1],[4,2,6,3]))

# fill with zeros to get a square matrix
z = numpy.zeros((max(a.shape), max(a.shape)))
z[:a.shape[0],:a.shape[1]] = a
a = z
w, v = numpy.linalg.eig(a) 

print(w)

print(v)

Out:

[10.88979431 -2.23132083 -0.65847348  0.        ]
[[-0.55662903 -0.89297739 -0.8543584  -0.58834841]
 [-0.50308806  0.25253601 -0.0201359  -0.58834841]
 [-0.66111007  0.37258146  0.51929401  0.39223227]
 [ 0.          0.          0.          0.39223227]]

Zabir Al Nazi
  • 10,298
  • 4
  • 33
  • 60