eigs.md (1612B)
1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. --> 2 3 # Function eigs 4 5 Compute eigenvalues and eigenvectors of a matrix. The eigenvalues are sorted by their absolute value, ascending. 6 An eigenvalue with multiplicity k will be listed k times. The eigenvectors are returned as columns of a matrix – 7 the eigenvector that belongs to the j-th eigenvalue in the list (eg. `values[j]`) is the j-th column (eg. `column(vectors, j)`). 8 If the algorithm fails to converge, it will throw an error – in that case, however, you may still find useful information 9 in `err.values` and `err.vectors`. 10 11 12 ## Syntax 13 14 ```js 15 math.eigs(x, [prec]) 16 ``` 17 18 ### Parameters 19 20 Parameter | Type | Description 21 --------- | ---- | ----------- 22 `x` | Array | Matrix | Matrix to be diagonalized 23 `prec` | number | BigNumber | Precision, default value: 1e-15 24 25 ### Returns 26 27 Type | Description 28 ---- | ----------- 29 {values: Array | Matrix, vectors: Array | Matrix} | Object containing an array of eigenvalues and a matrix with eigenvectors as columns. 30 31 32 ### Throws 33 34 Type | Description 35 ---- | ----------- 36 37 38 ## Examples 39 40 ```js 41 const { eigs, multiply, column, transpose } = math 42 const H = [[5, 2.3], [2.3, 1]] 43 const ans = eigs(H) // returns {values: [E1,E2...sorted], vectors: [v1,v2.... corresponding vectors as columns]} 44 const E = ans.values 45 const U = ans.vectors 46 multiply(H, column(U, 0)) // returns multiply(E[0], column(U, 0)) 47 const UTxHxU = multiply(transpose(U), H, U) // diagonalizes H 48 E[0] == UTxHxU[0][0] // returns true 49 ``` 50 51 52 ## See also 53 54 [inv](inv.md)