## `linalg::matlinsolveLU` -- solving the linear system given by an LU decomposition

#### Introduction

`linalg::matlinsolveLU``(L, U, b)` solves the linear system L*U*x=b, where the matrices L and U form an LU-decomposition, as computed by `linalg::factorLU`.

#### Call(s)

`linalg::matlinsolveLU(L, U, b)`
`linalg::matlinsolveLU(L, U, B)`

#### Parameters

`L` | - | an n x n lower triangular matrix of a domain of category `Cat::Matrix`
`U` | - | an n x n upper triangular form matrix of the same domain as `L`
`B` | - | an n x k matrix of a domain of category `Cat::Matrix`
`b` | - | an n-dimensional column vector, i.e., an n x 1 matrix of a domain of category `Cat::Matrix`

#### Returns

an n-dimensional solution vector or n x k dimensional solution matrix, respectively, of the domain type `Dom::Matrix(R)`, where `R` is the component ring of `A`.

#### Related Functions

`linalg::factorLU`, `linalg::inverseLU`, `linalg::matlinsolve`

#### Details

- If the third parameter is an n x k matrix `B` then the result is an n x k matrix X satisfying the matrix equation L*U*X=B.
- The system to be solved always has a unique solution.
- The diagonal entries of the lower diagonal matrix `L` must be equal to one (Doolittle-decomposition, see `linalg::factorLU`).
- `linalg::matlinsolveLU` expects `L` and `U` to be nonsingular.
- `linalg::matlinsolveLU` does not check on any of the required properties of `L` and `U`.
- The component ring of the matrices `L` and `U` must be a field, i.e., a domain of category `Cat::Field`.
- The parameters must be defined over the same component ring.

#### Example 1

We solve the system

    +-           -+       +-         -+
    |  2, -3, -1  |       |  1, 0, 0  |
    |             |       |           |
    |  1,  1, -1  | * X = |  0, 1, 0  |:
    |             |       |           |
    |  0,  1, -1  |       |  0, 0, 1  |
    +-           -+       +-         -+

    >> MatR := Dom::Matrix(Dom::Real):
       A  := MatR([[2, -3, -1], [1, 1, -1], [0, 1, -1]]);
       I3 := MatR::identity(3)

                                  +-           -+
                                  |  2, -3, -1  |
                                  |             |
                                  |  1,  1, -1  |
                                  |             |
                                  |  0,  1, -1  |
                                  +-           -+

                                   +-         -+
                                   |  1, 0, 0  |
                                   |           |
                                   |  0, 1, 0  |
                                   |           |
                                   |  0, 0, 1  |
                                   +-         -+

We start by computing an LU-decomposition of A:

    >> LU := linalg::factorLU(A)

              -- +-             -+  +-              -+            --
              |  |   1,   0,  0  |  |  2,  -3,  -1   |             |
              |  |               |  |                |             |
              |  |  1/2,  1,  0  |, |  0, 5/2, -1/2  |, [1, 2, 3]  |
              |  |               |  |                |             |
              |  |   0,  2/5, 1  |  |  0,  0,  -4/5  |             |
              -- +-             -+  +-              -+            --

Now we solve the system A * X = I, which gives us the inverse of A:

    >> Ai := linalg::matlinsolveLU(LU[1], LU[2], I3)

                               +-                 -+
                               |    0,   1,   -1   |
                               |                   |
                               |  -1/4, 1/2, -1/4  |
                               |                   |
                               |  -1/4, 1/2, -5/4  |
                               +-                 -+

    >> A * Ai, Ai * A

                           +-         -+  +-         -+
                           |  1, 0, 0  |  |  1, 0, 0  |
                           |           |  |           |
                           |  0, 1, 0  |, |  0, 1, 0  |
                           |           |  |           |
                           |  0, 0, 1  |  |  0, 0, 1  |
                           +-         -+  +-         -+

#### Changes

- new function

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000