﻿ BackSubstitution – Algosim documentation
Algosim documentation: BackSubstitution

# BackSubstitution

Solves a system of linear equations by means of back substitution.

## Syntax

• `BackSubstitution(A, y)`

• `A` is an upper triangular `n×n` matrix

• `y` is an `n`-dimensional matrix

## Description

If `A` is an upper triangular matrix of size `n×n` and `y` an `n`-dimensional vector, then `BackSubstitution(A, y)` solves the matrix equation `A⋅x = y` for `x` using back substitution.

If `A` isn’t square or if `y` isn’t of the right dimension, an error is generated. An error is also generated if `A` is singular. However, if non of these conditions apply but `A` isn’t upper triangular, a vector is returned, but it is not guaranteed to solve the equation.

## Examples

`A ≔ ❨❨2, 1, 0, 3❩, ❨0, 1, 4, 2❩, ❨0, 0, 1, 1❩, ❨0, 0, 0, 1❩❩`
```⎛2  1  0  3⎞
⎜0  1  4  2⎟
⎜0  0  1  1⎟
⎝0  0  0  1⎠
```
`y ≔ ❨5, −2, 0, 1❩`
``` ⎛5 ⎞
⎜−2⎟
e⎜0 ⎟
⎝1 ⎠
```
`x ≔ BackSubstitution(A, y)`
``` ⎛1 ⎞
⎜0 ⎟
e⎜−1⎟
⎝1 ⎠
```
`A⋅x`
``` ⎛5 ⎞
⎜−2⎟
e⎜0 ⎟
⎝1 ⎠
```