Thomas algorithm to solve tridiagonal matrices
Basically sets up an LU decomposition three parts 1) decomposition 2) forward substitution 3) backward substitution
1) decomposition loop from rows 2 to n ai = ai/bi-1 bi = bi-ai*ci-1 end loop 2) forward substitution loop from 2 to n ri = ri - ai*ri-1
3) back substitution xn = rn/bn loop from n-1 to 1 xi = (ri-ci*xi+1)/bi end loop
Example First decompose T
loop from rows 2 to 5 ai = ai/bi-1 bi = bi-ai*ci-1 end loop
forward substitution loop from 2 to n ri = ri - ai*ri-1 end loop
back substitution xn = rn/bn loop from n-1 to 1 xi = (ri-ci*xi+1)/bi end loop
Crout algorithm - alternate LU decomposition Instead of 1’s on diagonal of L, get 1’s on diagonal of U Operate on rows and columns sequentially, narrowing down to single element
Algorithm for j=2 to n-1 For j=n
Cholesky decomposition A decomposition for symmetric matrices Symmetric matrix e.g. a covariance matrix
For symmetric matrices, can write Can develop relationships for l
Example: 1st row Skip this equation
Row 2
Row 3
Row 4
Iterative methods for solving matrix equations 1. Jacobi 2. Gauss-Seidel 3. Successive overrelaxation (SOR) Idea behind iterative methods: Convert Ax=b into Cx=d, which has sequence of approximations x(1), x(2), … with
What are C and d? Recall from fixed-point iteration
Rewrite matrix equation in same way becomes
Then
Jacobi method is like fixed point iteration Example: Shape of a stretched membrane
Shape can be described by potential function Let us give some boundary conditions
Problem look likes this Solve for u’s
Leads to this system of equations
Choose an initial u=[1 1 1 1 …1]’ Iterate using x=Cx+d
Matlab solution, 49 iterations
Gauss-Seidel method differs from Jacobi by sequential updating - use new xi’s as they become available
Example: Jacobi Gauss-Seidel