The linear function named scipy.linalg.solveh_triangular is used to solve the banded matrix equation. In the below given example we will be solving the triangular system ax = b where −
$$\mathrm{a} = \begin{bmatrix} 3 & 0 & 0 & 0\\ 2 & 1 & 0 & 0\\ 1 &0 &1 &0 \\ 1& 1& 1& 1 \end{bmatrix};\; \mathrm{b} =\begin{bmatrix} 1\\ 2\\ 1\\ 2 \end{bmatrix}$$
from scipy.linalg import solve_triangular import numpy as np a = np.array([[3, 0, 0, 0], [2, 1, 0, 0], [1, 0, 1, 0], [1, 1, 1, 1]]) b = np.array([1, 2, 1, 2]) x = solve_triangular(a, b, lower=True) print (x)
array([ 0.33333333, 1.33333333, 0.66666667, -0.33333333])