1 |
|
2 |
|
3 | # Function lusolve
|
4 |
|
5 | Solves the linear system `A * x = b` where `A` is an [n x n] matrix and `b` is a [n] column vector.
|
6 |
|
7 |
|
8 | ## Syntax
|
9 |
|
10 | ```js
|
11 | math.lusolve(A, b) // returns column vector with the solution to the linear system A * x = b
|
12 | math.lusolve(lup, b) // returns column vector with the solution to the linear system A * x = b, lup = math.lup(A)
|
13 | ```
|
14 |
|
15 | ### Parameters
|
16 |
|
17 | Parameter | Type | Description
|
18 | --------- | ---- | -----------
|
19 | `A` | Matrix | Array | Object | Invertible Matrix or the Matrix LU decomposition
|
20 | `b` | Matrix | Array | Column Vector
|
21 | `order` | number | The Symbolic Ordering and Analysis order, see slu for details. Matrix must be a SparseMatrix
|
22 | `threshold` | Number | Partial pivoting threshold (1 for partial pivoting), see slu for details. Matrix must be a SparseMatrix.
|
23 |
|
24 | ### Returns
|
25 |
|
26 | Type | Description
|
27 | ---- | -----------
|
28 | DenseMatrix | Array | Column vector with the solution to the linear system A * x = b
|
29 |
|
30 |
|
31 | ## Examples
|
32 |
|
33 | ```js
|
34 | const m = [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]
|
35 |
|
36 | const x = math.lusolve(m, [-1, -1, -1, -1]) // x = [[-1], [-0.5], [-1/3], [-0.25]]
|
37 |
|
38 | const f = math.lup(m)
|
39 | const x1 = math.lusolve(f, [-1, -1, -1, -1]) // x1 = [[-1], [-0.5], [-1/3], [-0.25]]
|
40 | const x2 = math.lusolve(f, [1, 2, 1, -1]) // x2 = [[1], [1], [1/3], [-0.25]]
|
41 |
|
42 | const a = [[-2, 3], [2, 1]]
|
43 | const b = [11, 9]
|
44 | const x = math.lusolve(a, b) // [[2], [5]]
|
45 | ```
|
46 |
|
47 |
|
48 | ## See also
|
49 |
|
50 | [lup](lup.md),
|
51 | [slu](slu.md),
|
52 | [lsolve](lsolve.md),
|
53 | [usolve](usolve.md)
|