AMATH 301 Lecture 7: LU Decomposition and Timing Code in MATLAB
Document Summary
Lu composition code example - to use in homework, tests 2. %to solve this system, the worst case scenario is that each equation. %takes around n-1 flops + 1 flop to divide out at the end for a total of. %n flops per equations, meaning total number to solve everything is. %lower triangular = l, upper triangular = u. %ly = b (we can solve this with simple substitution), and then ux = y is. %lu = pa is how matlab wants to solve the problem. %matrix that looks like the identity matrix but is mixed up. Lecture 7 notes a = [2 1 1; %backslash solves a system of equations quickly x = a\b; %[l,u,p] = lu(a) returns unit lower triangular matrix l, upper. %triangular matrix u, and permutation matrix p so that p*a = l*u. Lu composition code example - to use in homework, tests. [l,u,p] = lu(a); y = l\(p*b); x = u\y;