Stable solution to tridiagonal systems