1 |
|
2 |
|
3 | # Function eigs
|
4 |
|
5 | Compute eigenvalue and eigenvector of a real symmetric matrix.
|
6 | Only applicable to two dimensional symmetric matrices. Uses Jacobi
|
7 | Algorithm. Matrix containing mixed type ('number', 'bignumber', 'fraction')
|
8 | of elements are not supported. Input matrix or 2D array should contain all elements
|
9 | of either 'number', 'bignumber' or 'fraction' type. For 'number' and 'fraction', the
|
10 | eigenvalues are of 'number' type. For 'bignumber' the eigenvalues are of ''bignumber' type.
|
11 | Eigenvectors are always of 'number' type.
|
12 |
|
13 |
|
14 | ## Syntax
|
15 |
|
16 | ```js
|
17 | math.eigs(x)
|
18 | ```
|
19 |
|
20 | ### Parameters
|
21 |
|
22 | Parameter | Type | Description
|
23 | --------- | ---- | -----------
|
24 | `x` | Array | Matrix | Matrix to be diagonalized
|
25 |
|
26 | ### Returns
|
27 |
|
28 | Type | Description
|
29 | ---- | -----------
|
30 | {values: Array, vectors: Array} | {values: Matrix, vectors: Matrix} | Object containing eigenvalues (Array or Matrix) and eigenvectors (2D Array/Matrix with eigenvectors as columns).
|
31 |
|
32 |
|
33 | ## Examples
|
34 |
|
35 | ```js
|
36 | const H = [[5, 2.3], [2.3, 1]]
|
37 | const ans = math.eigs(H) // returns {values: [E1,E2...sorted], vectors: [v1,v2.... corresponding vectors as columns]}
|
38 | const E = ans.values
|
39 | const U = ans.vectors
|
40 | math.multiply(H, math.column(U, 0)) // returns math.multiply(E[0], math.column(U, 0))
|
41 | const UTxHxU = math.multiply(math.transpose(U), H, U) // rotates H to the eigen-representation
|
42 | E[0] == UTxHxU[0][0] // returns true
|
43 | ```
|
44 |
|
45 |
|
46 | ## See also
|
47 |
|
48 | [inv](inv.md)
|