﻿ ForwardSubstitution – Algosim documentation
Algosim documentation: ForwardSubstitution

# ForwardSubstitution

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

## Syntax

• `ForwardSubstitution(A, y)`

• `A` is a lower triangular `n×n` matrix

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

## Description

If `A` is a lower triangular matrix of size `n×n` and `y` an `n`-dimensional vector, then `ForwardSubstitution(A, y)` solves the matrix equation `A⋅x = y` for `x` using forward 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 lower triangular, a vector is returned, but it is not guaranteed to solve the equation.

## Examples

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