utrisol

Purpose

Computes the solution of \(Ux = b\) where \(U\) is an upper triangular matrix.

Format

x = utrisol(b, U)
Parameters:
  • b (PxK matrix) – data

  • U (PxP upper triangular matrix) – data

Returns:

x (PxK matrix) – solution of \(Ux = b\).

Example

// Create upper triangular matrix
U = { 9.8    -0.32     0.66       1.28,
        0     9.32    -0.25    -0.0084,
        0        0     8.37       0.54,
        0        0        0      10.17 };

b = { -0.7,
       1.5,
      -0.8,
    -0.003 };

// Solve the system of equations
x = utrisol(b, U);

b_pred = U * x;

The above code will make the following assignments:

 x = -0.0597827
       0.158381
     -0.0955604
   -0.000294985

b_pred = -0.7
          1.5
         -0.8
       -0.003

Remarks

utrisol() applies a back solve to \(Ux = b\) to solve for \(x\). If \(b\) has more than one column, each column is solved for separately, i.e., utrisol() applies a back solve to \(U * x[., i] = b[., i]\).

See also

Functions ltrisol(), solpd()