UNPKG

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