---
title: "Tridiagonal matrix, river stage and water table"
subject: "Computational Techniques in Civil Engineering"
chapter: 7
key: "semester_8/computational_techniques_in_civil_engineering:tridiagonal-matrix-river-aquifer"
source: https://www.bctengineer.com/q/semester_8/computational_techniques_in_civil_engineering/tridiagonal-matrix-river-aquifer
site: BCT Engineering
---

# Tridiagonal matrix, river stage and water table

Computational Techniques in Civil Engineering · Chapter 7: Simulation of Ground water flow

- Asked in: 2079 Jestha, 6 marks; 2073 Magh, 6 marks (asked 2 times)
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_8/computational_techniques_in_civil_engineering/tridiagonal-matrix-river-aquifer
- Whole chapter: https://www.bctengineer.com/md/semester_8/computational_techniques_in_civil_engineering/chapter-7

## Question

Develop a tridiagonal coefficient matrix to assess river stage and water table interactions for a groundwater aquifer along a river.

## Short answer

Apply implicit scheme to 1D groundwater equation: −λ h_{i-1}^{j+1}+(1+2λ)h_i^{j+1}−λ h_{i+1}^{j+1}=h_i^j, with λ=TΔt/(SΔx²). River boundary: h_0=h_L; no-flow far boundary: h_{N+1}=h_n. The tridiagonal matrix is solved by Thomas algorithm.

## Answer

A tridiagonal matrix arises when the 1D groundwater equation is written implicitly for every grid along a line from the river to the aquifer boundary.

```text
 river                                     barrier (no flow)
  hL  |  grid1  grid2  grid3  ...  gridN  |
  ~~~~|---o------o------o-------o------o--|
      0   1      2      3      N-1    N  N+1
      |<-dx->|
```

#### Governing equation
For a one-dimensional unconfined/confined aquifer next to a river (x measured from the river), with transmissivity $T$, storage coefficient $S$ and head $h$:
$$
T\frac{\partial^2h}{\partial x^2}=S\frac{\partial h}{\partial t}
$$

#### Implicit finite difference form
Divide the aquifer into $N$ grids of width $\Delta x$ (grid 1 next to the river). Use a backward difference in time and a central difference in space, with the space terms at the new time level $j+1$:
$$
T\,\frac{h_{i-1}^{j+1}-2h_i^{j+1}+h_{i+1}^{j+1}}{\Delta x^2}=S\,\frac{h_i^{j+1}-h_i^j}{\Delta t}
$$
With $\lambda=\dfrac{T\Delta t}{S\Delta x^2}$:
$$
-\lambda\,h_{i-1}^{j+1}+(1+2\lambda)\,h_i^{j+1}-\lambda\,h_{i+1}^{j+1}=h_i^j,\qquad i=1,\dots,N
$$
Each equation has three unknowns, so a set of $N$ simultaneous equations must be solved at each time step.

#### Boundary conditions
- River side: $h_0^{j+1}=h_L$ (the river stage, which may change with time). In the first equation the known term moves to the right-hand side: $(1+2\lambda)h_1-\lambda h_2=h_1^j+\lambda h_L$.
- Barrier (no flow) at the far end: $\partial h/\partial x=0\Rightarrow h_{N+1}=h_N$, so the last equation is $-\lambda h_{N-1}+(1+\lambda)h_N=h_N^j$. (If the far end has a specified head $h_R$, the last row is instead $-\lambda h_{N-1}+(1+2\lambda)h_N=h_N^j+\lambda h_R$.)

#### Tridiagonal coefficient matrix
$$
\begin{bmatrix}
1+2\lambda&-\lambda&&&\\
-\lambda&1+2\lambda&-\lambda&&\\
&\ddots&\ddots&\ddots&\\
&&-\lambda&1+2\lambda&-\lambda\\
&&&-\lambda&1+\lambda
\end{bmatrix}
\begin{bmatrix}h_1\\h_2\\ \vdots\\h_{N-1}\\h_N\end{bmatrix}^{j+1}
=
\begin{bmatrix}h_1^j+\lambda h_L\\h_2^j\\ \vdots\\h_{N-1}^j\\h_N^j\end{bmatrix}
$$
The matrix is symmetric, tridiagonal and diagonally dominant, so the system has a unique solution and can be solved efficiently by the Thomas algorithm.

#### Thomas algorithm for the solution
Write the rows as $a_ih_{i-1}+b_ih_i+c_ih_{i+1}=d_i$ with $a_i=c_i=-\lambda$. Forward elimination:
$$
c_1'=\frac{c_1}{b_1},\ d_1'=\frac{d_1}{b_1};\qquad c_i'=\frac{c_i}{b_i-a_ic_{i-1}'},\ \ d_i'=\frac{d_i-a_id_{i-1}'}{b_i-a_ic_{i-1}'}
$$
Back substitution: $h_N=d_N'$, $h_i=d_i'-c_i'h_{i+1}$. The new heads become the right-hand side for the next time step, with $h_L$ updated to the new river stage.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Why does the implicit finite difference form give a tridiagonal matrix?
   A. Each equation involves h at the new time for three adjacent grids (i-1, i, i+1)
   B. Each equation has all grid heads
   C. Because time derivatives are dropped
   D. Because heads are known at the new time
   Answer: A. The space terms at the new level involve only the node and its two neighbours, so only three diagonals are non-zero. (Key point: Why tridiagonal)

2. What is lambda and what are the diagonal and off-diagonal entries?
   A. lambda = S dx^2/(T dt); diagonal 1 - 2 lambda
   B. lambda = T dt/(S dx^2); diagonal 1 + 2 lambda, off-diagonals -lambda
   C. lambda = T dx/(S dt); diagonal 2 lambda
   D. lambda = T/S; diagonal 1
   Answer: B. Rearranging gives -lambda h(i-1) + (1+2 lambda) h(i) - lambda h(i+1) = h_i^j with lambda = T dt/(S dx^2). (Key point: Coefficient lambda)

3. How are the river side and no-flow barrier included?
   A. Both give a last diagonal 1 + 2 lambda
   B. River adds lambda h_L to the first right-hand side; barrier (h_(N+1) = h_N) makes the last diagonal 1 + lambda
   C. The barrier adds lambda h_L; the river changes diagonal to 1
   D. Boundaries are ignored in the matrix
   Answer: B. The known river head moves to the right side of row 1, and the zero-gradient barrier gives 1 + lambda in the last row. (Key point: Boundary conditions)

4. Which method solves the tridiagonal system efficiently?
   A. Trial and error
   B. Newton-Raphson on each grid
   C. Explicit marching
   D. Thomas algorithm (forward elimination, back substitution)
   Answer: D. The Thomas algorithm exploits the three-diagonal structure. (Key point: Solution method)

## Related in Computational Techniques in Civil Engineering

- [River stage and water table, three grids](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Ariver-stage-water-table-numerical) — Computational Techniques in Civil Engineering, chapter 7
- [1D implicit river stage - water table model](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Aone-d-implicit-river-stage-model) — Computational Techniques in Civil Engineering, chapter 7, asked 2×
- [Courant condition; 1-D implicit coefficient matrix](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Acourant-implicit-matrix-river-stage) — Computational Techniques in Civil Engineering, chapter 7
- [2D groundwater FD scheme, boundary conditions](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Agw-2d-fd-boundary-flow-coefficients) — Computational Techniques in Civil Engineering, chapter 7

## Related in other subjects

- [River features; hydrological cycle, aquifer](https://www.bctengineer.com/question.md?key=semester_3%2Fengineering_geology_i%3Ariver-features-hydrological-cycle-aquifer) — Engineering Geology I, chapter 6
- [River morphology; porosity, aquifer, piezometric level](https://www.bctengineer.com/question.md?key=semester_3%2Fengineering_geology_i%3Ariver-morphology-porosity-aquifer-piezometric) — Engineering Geology I, chapter 6
- [Lowering of groundwater table in Kathmandu](https://www.bctengineer.com/question.md?key=semester_5%2Fwater_supply_engineering%3Agroundwater-depletion-kathmandu) — Water Supply Engineering, chapter 2
- [Charge coefficient matrix with ground wires](https://www.bctengineer.com/question.md?key=semester_8%2Fhigh_voltage_engineering%3Acharge-coefficient-matrix-ground-wires) — High Voltage Engineering, chapter 5, asked 4×
