Sponsored Links

Kamis, 18 Januari 2018

Sponsored Links

Numerical Tridiagonal Matrix to Solve Math Problem - YouTube
src: i.ytimg.com

In numerical linear algebra, the tridiagonal matrix algorithm, also known as the Thomas algorithm (named after Llewellyn Thomas), is a simplified form of Gaussian elimination that can be used to solve tridiagonal systems of equations. A tridiagonal system for n unknowns may be written as

a i x i - 1 + b i x i + c i x i + 1 = d i , {\displaystyle a_{i}x_{i-1}+b_{i}x_{i}+c_{i}x_{i+1}=d_{i},\,\!}

where a 1 = 0 {\displaystyle a_{1}=0\,} and c n = 0 {\displaystyle c_{n}=0\,} .

[ b 1 c 1 0 a 2 b 2 c 2 a 3 b 3 ? ? ? c n - 1 0 a n b n ] [ x 1 x 2 x 3 ? x n ] = [ d 1 d 2 d 3 ? d n ] . {\displaystyle {\begin{bmatrix}{b_{1}}&{c_{1}}&{}&{}&{0}\\{a_{2}}&{b_{2}}&{c_{2}}&{}&{}\\{}&{a_{3}}&{b_{3}}&\ddots &{}\\{}&{}&\ddots &\ddots &{c_{n-1}}\\{0}&{}&{}&{a_{n}}&{b_{n}}\\\end{bmatrix}}{\begin{bmatrix}{x_{1}}\\{x_{2}}\\{x_{3}}\\\vdots \\{x_{n}}\\\end{bmatrix}}={\begin{bmatrix}{d_{1}}\\{d_{2}}\\{d_{3}}\\\vdots \\{d_{n}}\\\end{bmatrix}}.}

For such systems, the solution can be obtained in O ( n ) {\displaystyle O(n)} operations instead of O ( n 3 ) {\displaystyle O(n^{3})} required by Gaussian elimination. A first sweep eliminates the a i {\displaystyle a_{i}} 's, and then an (abbreviated) backward substitution produces the solution. Examples of such matrices commonly arise from the discretization of 1D Poisson equation and natural cubic spline interpolation; similar systems of matrices arise in tight binding physics or nearest neighbor effects models.

Thomas' algorithm is not stable in general, but is so in several special cases, such as when the matrix is diagonally dominant (either by rows or columns) or symmetric positive definite; for a more precise characterization of stability of Thomas' algorithm, see Higham Theorem 9.12. If stability is required in the general case, Gaussian elimination with partial pivoting (GEPP) is recommended instead.


Video Tridiagonal matrix algorithm



Method

The forward sweep consists of modifying the coefficients as follows, denoting the new coefficients with primes:

c i ? = { c i b i ; i = 1 c i b i - a i c i - 1 ? ; i = 2 , 3 , ... , n {\displaystyle c'_{i}={\begin{cases}{\begin{array}{lcl}{\cfrac {c_{i}}{b_{i}}}&;&i=1\\{\cfrac {c_{i}}{b_{i}-a_{i}c'_{i-1}}}&;&i=2,3,\dots ,n\\\end{array}}\end{cases}}\,}

and

d i ? = { d i b i ; i = 1 d i - a i d i - 1 ? b i - a i c i - 1 ? ; i = 2 , 3 , ... , n . {\displaystyle d'_{i}={\begin{cases}{\begin{array}{lcl}{\cfrac {d_{i}}{b_{i}}}&;&i=1\\{\cfrac {d_{i}-a_{i}d'_{i-1}}{b_{i}-a_{i}c'_{i-1}}}&;&i=2,3,\dots ,n.\\\end{array}}\end{cases}}\,}

The solution is then obtained by back substitution:

x n = d n ? {\displaystyle x_{n}=d'_{n}\,}
x i = d i ? - c i ? x i + 1 ;   i = n - 1 , n - 2 , ... , 1. {\displaystyle x_{i}=d'_{i}-c'_{i}x_{i+1}\qquad ;\ i=n-1,n-2,\ldots ,1.}

Maps Tridiagonal matrix algorithm



Derivation

The derivation of the tridiagonal matrix algorithm is a special case of Gaussian elimination.

Suppose that the unknowns are x 1 , ... , x n {\displaystyle x_{1},\ldots ,x_{n}} , and that the equations to be solved are:

b 1 x 1 + c 1 x 2 = d 1 ; i = 1 a i x i - 1 + b i x i + c i x i + 1 = d i ; i = 2 , ... , n - 1 a n x n - 1 + b n x n = d n ; i = n . {\displaystyle {\begin{aligned}b_{1}x_{1}+c_{1}x_{2}&=d_{1};&i&=1\\a_{i}x_{i-1}+b_{i}x_{i}+c_{i}x_{i+1}&=d_{i};&i&=2,\ldots ,n-1\\a_{n}x_{n-1}+b_{n}x_{n}&=d_{n};&i&=n.\end{aligned}}}

Consider modifying the second ( i = 2 {\displaystyle i=2} ) equation with the first equation as follows:

( equation 2 ) ? b 1 - ( equation 1 ) ? a 2 {\displaystyle ({\mbox{equation 2}})\cdot b_{1}-({\mbox{equation 1}})\cdot a_{2}}

which would give:

( a 2 x 1 + b 2 x 2 + c 2 x 3 ) b 1 - ( b 1 x 1 + c 1 x 2 ) a 2 = d 2 b 1 - d 1 a 2 {\displaystyle (a_{2}x_{1}+b_{2}x_{2}+c_{2}x_{3})b_{1}-(b_{1}x_{1}+c_{1}x_{2})a_{2}=d_{2}b_{1}-d_{1}a_{2}\,}
( b 2 b 1 - c 1 a 2 ) x 2 + c 2 b 1 x 3 = d 2 b 1 - d 1 a 2 {\displaystyle (b_{2}b_{1}-c_{1}a_{2})x_{2}+c_{2}b_{1}x_{3}=d_{2}b_{1}-d_{1}a_{2}\,}

where the second equation immediately above is a simplified version of the equation immediately preceding it. The effect is that x 1 {\displaystyle 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 + b 3 x 3 + c 3 x 4 ) ( b 2 b 1 - c 1 a 2 ) - ( ( b 2 b 1 - c 1 a 2 ) x 2 + c 2 b 1 x 3 ) a 3 = d 3 ( b 2 b 1 - c 1 a 2 ) - ( d 2 b 1 - d 1 a 2 ) a 3 {\displaystyle (a_{3}x_{2}+b_{3}x_{3}+c_{3}x_{4})(b_{2}b_{1}-c_{1}a_{2})-((b_{2}b_{1}-c_{1}a_{2})x_{2}+c_{2}b_{1}x_{3})a_{3}=d_{3}(b_{2}b_{1}-c_{1}a_{2})-(d_{2}b_{1}-d_{1}a_{2})a_{3}\,}
( b 3 ( b 2 b 1 - c 1 a 2 ) - c 2 b 1 a 3 ) x 3 + c 3 ( b 2 b 1 - c 1 a 2 ) x 4 = d 3 ( b 2 b 1 - c 1 a 2 ) - ( d 2 b 1 - d 1 a 2 ) a 3 . {\displaystyle (b_{3}(b_{2}b_{1}-c_{1}a_{2})-c_{2}b_{1}a_{3})x_{3}+c_{3}(b_{2}b_{1}-c_{1}a_{2})x_{4}=d_{3}(b_{2}b_{1}-c_{1}a_{2})-(d_{2}b_{1}-d_{1}a_{2})a_{3}.\,}

This time x 2 {\displaystyle x_{2}} was eliminated. If this procedure is repeated until the n t h {\displaystyle n^{th}} row; the (modified) n t h {\displaystyle n^{th}} equation will involve only one unknown, x n {\displaystyle x_{n}} . This may be solved for and then used to solve the ( n - 1 ) t h {\displaystyle (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:

a ~ i = 0 {\displaystyle {\tilde {a}}_{i}=0\,}
b ~ 1 = b 1 {\displaystyle {\tilde {b}}_{1}=b_{1}\,}
b ~ i = b i b ~ i - 1 - c ~ i - 1 a i {\displaystyle {\tilde {b}}_{i}=b_{i}{\tilde {b}}_{i-1}-{\tilde {c}}_{i-1}a_{i}\,}
c ~ 1 = c 1 {\displaystyle {\tilde {c}}_{1}=c_{1}\,}
c ~ i = c i b ~ i - 1 {\displaystyle {\tilde {c}}_{i}=c_{i}{\tilde {b}}_{i-1}\,}
d ~ 1 = d 1 {\displaystyle {\tilde {d}}_{1}=d_{1}\,}
d ~ i = d i b ~ i - 1 - d ~ i - 1 a i . {\displaystyle {\tilde {d}}_{i}=d_{i}{\tilde {b}}_{i-1}-{\tilde {d}}_{i-1}a_{i}.\,}

To further hasten the solution process, b ~ i {\displaystyle {\tilde {b}}_{i}} may be divided out (if there's no division by zero risk), the newer modified coefficients, each notated with a prime, will be:

a i ? = 0 {\displaystyle a'_{i}=0\,}
b i ? = 1 {\displaystyle b'_{i}=1\,}
c 1 ? = c 1 b 1 {\displaystyle c'_{1}={\frac {c_{1}}{b_{1}}}\,}
c i ? = c i b i - c i - 1 ? a i {\displaystyle c'_{i}={\frac {c_{i}}{b_{i}-c'_{i-1}a_{i}}}\,}
d 1 ? = d 1 b 1 {\displaystyle d'_{1}={\frac {d_{1}}{b_{1}}}\,}
d i ? = d i - d i - 1 ? a i b i - c i - 1 ? a i . {\displaystyle 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:

x i + c i ? x i + 1 = d i ? ;   i = 1 , ... , n - 1 x n = d n ? ;   i = n . {\displaystyle {\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 ? {\displaystyle x_{n}=d'_{n}\,}
x i = d i ? - c i ? x i + 1 ;   i = n - 1 , n - 2 , ... , 1. {\displaystyle x_{i}=d'_{i}-c'_{i}x_{i+1}\qquad ;\ i=n-1,n-2,\ldots ,1.}

MATLAB Programming Tutorial 24 Tri Diagonal Matrix Algorithm HD ...
src: i.ytimg.com


Variants

In some situations, particularly those involving periodic boundary conditions, a slightly perturbed form of the tridiagonal system may need to be solved:

a 1 x n + b 1 x 1 + c 1 x 2 = d 1 , a i x i - 1 + b i x i + c i x i + 1 = d i , i = 2 , ... , n - 1 a n x n - 1 + b n x n + c n x 1 = d n . {\displaystyle {\begin{aligned}a_{1}x_{n}+b_{1}x_{1}+c_{1}x_{2}&=d_{1},\\a_{i}x_{i-1}+b_{i}x_{i}+c_{i}x_{i+1}&=d_{i},\quad \quad i=2,\ldots ,n-1\\a_{n}x_{n-1}+b_{n}x_{n}+c_{n}x_{1}&=d_{n}.\end{aligned}}}

In this case, we can make use of the Sherman-Morrison formula to avoid the additional operations of Gaussian elimination and still use the Thomas algorithm. The method requires solving a modified non-cyclic version of the system for both the input and a sparse corrective vector, and then combining the solutions. This can be done efficiently if both solutions are computed at once, as the forward portion of the pure tridiagonal matrix algorithm can be shared.

In other situations, the system of equations may be block tridiagonal (see block matrix), with smaller submatrices arranged as the individual elements in the above matrix system (e.g., the 2D Poisson problem). Simplified forms of Gaussian elimination have been developed for these situations.

The textbook Numerical Mathematics by Quarteroni, Sacco and Saleri, lists a modified version of the algorithm which avoids some of the divisions (using instead multiplications), which is beneficial on some computer architectures.


Quantum circuits for circulant operators | Open Science
src: rsos.royalsocietypublishing.org


References

  • Conte, S.D. & deBoor, C. (1972). Elementary Numerical Analysis. McGraw-Hill, New York. ISBN 0070124469. 
  • This article incorporates text from the article Tridiagonal_matrix_algorithm_-_TDMA_(Thomas_algorithm) on CFD-Wiki that is under the GFDL license.
  • Press, WH; Teukolsky, SA; Vetterling, WT; Flannery, BP (2007). "Section 2.4". Numerical Recipes: The Art of Scientific Computing (3rd ed.). New York: Cambridge University Press. ISBN 978-0-521-88068-8 

Source of the article : Wikipedia

Comments
0 Comments