User:R perry/td

Derivation
The derivation of the tridiagonal matrix algorithm involves manually performing some specialized Gaussian elimination in a generic manner.

Suppose that the unknowns are $$x_1,\ldots, x_n$$, and that the equations to be solved are:


 * $$\begin{align}

d_1 x_1 + c_1 x_2 & = b_1;& i & = 1 \\ a_i x_{i - 1} + d_i x_i + c_i x_{i + 1} & = b_i;& i & = 2, \ldots, n - 1 \\ a_n x_{n - 1} + d_n x_n & = b_n;& i & = n \end{align} $$

Consider modifying the second ($$i = 2$$) equation with the first equation as follows:



(\mbox{equation 2}) \cdot d_1 - (\mbox{equation 1}) \cdot a_2 $$

which would give:



(a_2 x_1 + d_2 x_2 + c_2 x_3) d_1 - (d_1 x_1  + c_1 x_2) a_2 = b_2 d_1 - b_1 a_2 \,$$



(d_2 d_1 - c_1 a_2) x_2 + c_2 d_1 x_3 = b_2 d_1 - b_1 a_2 \,$$

and the effect is that $$x_1$$ has been eliminated from the second equation. Using a similar tactic with the modified second equation on the third equation yields:



(a_3 x_2 + d_3 x_3 + c_3 x_4) (d_2 d_1 - c_1 a_2) - ((d_2 d_1 - c_1 a_2) x_2 + c_2 d_1 x_3) a_3 = b_3 (d_2 d_1 - c_1 a_2) - (b_2 d_1 - b_1 a_2) a_3 \,$$



(d_3 (d_2 d_1 - c_1 a_2) - c_2 d_1 a_3 )x_3 + c_3 (d_2 d_1 - c_1 a_2) x_4 = b_3 (d_2 d_1 - c_1 a_2) - (b_2 d_1 - b_1 a_2) a_3 \,$$

This time $$x_2$$ was eliminated. If this procedure is repeated until the $$n^{th}$$ row; the (modified) $$n^{th}$$ equation will involve only one unknown, $$x_n$$. This may be solved for and then used to solve the $$(n - 1)^{th}$$ equation, and so on until all of the unknowns are solved for.

Clearly, the coefficients on the modified equations get more and more complicated if stated explicitly. By examining the procedure, the modified coefficients (notated with tildes) may instead be defined recursively:


 * $$\tilde a_i = 0\,$$


 * $$\tilde d_1 = d_1\,$$
 * $$\tilde d_i = d_i \tilde d_{i - 1} - \tilde c_{i - 1} a_i\,$$


 * $$\tilde c_1 = c_1\,$$
 * $$\tilde c_i = c_i \tilde d_{i - 1}\,$$


 * $$\tilde b_1 = b_1\,$$
 * $$\tilde b_i = b_i \tilde d_{i - 1} - \tilde b_{i - 1} a_i\,$$

To further hasten the solution process, $$\tilde d_i$$ may be divided out (if there's no division by zero risk), the newer modified coefficients notated with an asterisk will be:


 * $$a'_i = 0\,$$


 * $$b'_i = 1\,$$


 * $$c'_1 = \frac{c_1}{d_1}\,$$
 * $$c'_i = \frac{c_i}{d_i - c'_{i - 1} a_i}\,$$


 * $$d'_1 = \frac{b_1}{d_1}\,$$
 * $$d'_i = \frac{d_i - d'_{i - 1} a_i}{b_i - c'_{i - 1} a_i}\,$$

This gives the following system with the same unknowns and coefficients defined in terms of the original ones above:


 * $$\begin{array}{lcl}

x_i + c'_i x_{i + 1} = d'_i \qquad &;& \ i = 1, \ldots, n - 1 \\ x_n = d'_n \qquad &;& \ i = n \\ \end{array} \,$$

The last equation involves only one unknown. Solving it in turn reduces the next last equation to one unknown, so that this backward substitution can be used to find all of the unknowns:


 * $$x_n = d'_n\,$$


 * $$x_i = d'_i - c'_i x_{i + 1} \qquad ; \ i = n - 1, n - 2, \ldots, 1$$