ECIV 301 Programming & Graphics Numerical Methods for Engineers REVIEW II
Topics Introduction to Matrix Algebra Gauss Elimination LU Decomposition Matrix Inversion Iterative Methods Function Interpolation & Approximation Newton Polynomials Lagrange Polynomials
Matrix Algebra Rectangular Array of Elements Represented by a single symbol [A]
Matrix Algebra Row 1 Row 3 Column 2Column m n x m Matrix
Matrix Algebra 3 rd Row 2 nd Column
Matrix Algebra 1 Row, m Columns Row Vector
Matrix Algebra n Rows, 1 Column Column Vector
Matrix Algebra If n = m Square Matrix e.g. n=m=5 Main Diagonal
Matrix Algebra Special Types of Square Matrices Symmetric: a ij = a ji
Matrix Algebra Diagonal: a ij = 0, i j Special Types of Square Matrices
Matrix Algebra Identity: a ii =1.0 a ij = 0, i j Special Types of Square Matrices
Matrix Algebra Upper Triangular Special Types of Square Matrices
Matrix Algebra Lower Triangular Special Types of Square Matrices
Matrix Algebra Banded Special Types of Square Matrices
Matrix Operating Rules - Equality [A] mxn =[B] pxq n=pm=qa ij =b ij
Matrix Operating Rules - Addition [C] mxn = [A] mxn +[B] pxq n=p m=q c ij = a ij +b ij
Matrix Operating Rules - Addition Properties [A]+[B] = [B]+[A] [A]+([B]+[C]) = ([A]+[B])+[C]
Multiplication by Scalar
Matrix Multiplication [A] n x m. [B] p x q = [C] n x q m=p
Matrix Multiplication
Matrix Multiplication - Properties Associative: [A]([B][C]) = ([A][B])[C] If dimensions suitable Distributive: [A]([B]+[C]) = [A][B]+[A] [C] Attention: [A][B] [B][A]
Operations - Transpose
Operations - Inverse [A][A] -1 [A] [A] -1 =[I] If [A] -1 does not exist [A] is singular
Operations - Trace Square Matrix tr[A] = a ii
Linear Equations in Matrix Form
Gauss Elimination Consider (Eq 1) (Eq 2) Solution 2*(Eq 1) (Eq 2) Solution !!!!!! Scaling Does Not Change the Solution
Gauss Elimination Consider (Eq 1) (Eq 2)-(Eq 1) Solution !!!!!! (Eq 1) (Eq 2) Solution Operations Do Not Change the Solution
Gauss Elimination Example Forward Elimination
Gauss Elimination -
Substitute 2 nd eq with new
Gauss Elimination -
Substitute 3rd eq with new
Gauss Elimination -
Substitute 3rd eq with new
Gauss Elimination Forward Elimination
Gauss Elimination Back Substitution
Gauss Elimination – Potential Problem Pivoting
Partial Pivoting a 32 >a 22 a l2 >a 22 NO YES
Partial Pivoting
Full Pivoting In addition to row swaping Search columns for max elements Swap Columns Change the order of x i Most cases not necessary
LU Decomposition
PIVOTS Column 1 PIVOTS Column 2
LU Decomposition As many as, and in the location of, zeros Upper Triangular Matrix U
LU Decomposition PIVOTS Column 1 PIVOTS Column 2 Lower Triangular Matrix L
LU Decomposition = This is the original matrix!!!!!!!!!!
LU Decomposition Lyb
Lyb
Ax=b A=LU -LU Decomposition Ly=b- Solve for y Ux=y- Solve for x
Matrix Inversion
[A][A] -1 [A] [A] -1 =[I] If [A] -1 does not exist [A] is singular
Matrix Inversion
Solution
Matrix Inversion To calculate the invert of a nxn matrix solve n times :
Iterative Methods Recall Techniques for Root finding of Single Equations Initial Guess New Estimate Error Calculation Repeat until Convergence
Gauss Seidel
First Iteration: Better Estimate
Gauss Seidel Second Iteration: Better Estimate
Gauss Seidel Iteration Error: Convergence Criterion:
Jacobi Iteration
First Iteration: Better Estimate
Jacobi Iteration Second Iteration: Better Estimate
Jacobi Iteration Iteration Error:
Determinants Are composed of same elements Completely Different Mathematical Concept
Determinants Defined in a recursive form 2x2 matrix
Determinants Defined in a recursive form 3x3 matrix
Determinants Minor a 11
Determinants Minor a 12
Determinants Minor a 13
Singular Matrices If det[A]=0 solution does NOT exist
Determinants and LU Decomposition
Curve Fitting Often we are faced with the problem… what value of y corresponds to x=0.935?
Curve Fitting Question 1 : Is it possible to find a simple and convenient formula that reproduces the points exactly? e.g. Straight Line ? …or smooth line ? …or some other representation? Interpolation
Curve Fitting Question 2 : Is it possible to find a simple and convenient formula that represents data approximately ? e.g. Best Fit ? Approximation
Linear Interpolation Slope of Line 1 st DIVIDED DIFFERENCE f [x i+1,x i ] First order interpolating polynomial
Function Interpolation Quadratic Interpolation Better Accuracy if 2 nd Order Polynomial x
General Form of Newton’s Interpolating Polynomials
Lagrange Interpolating Polynomials Reformulation of Newton’s Polynomials Avoid Calculation of Divided Differences xf(x) xoxo f(x o ) x1x1 f(x 1 ) x2x2 f(x 2 ) …… xnxn f(x n )
Lagrange Interpolating Polynomial Cardinal Functions: Product of n-1 linear factors Skip x i Property:
Errors in Polynomial Interpolation It is expected that as number of nodes increases, error decreases, HOWEVER…. At all interpolation nodes x i Error=0 At all intermediate points Error: f(x)-f n-1 (x) f(x)
Errors in Polynomial Interpolation Beware of Oscillations…. For Example: Consider f(x)=(1+x 2 ) -1 evaluated at 9 points in [-5,5] And corresponding p 8 (x) Lagrange Interpolating Polynomial P 8 (x) f(x)
Other Methods Direct Evaluation n+1 coefficients n+1 Data Points Interpolating Polynomial should represent them exactly
Other Methods Direct Evaluation
Other Methods Solve Using any of the methods we have learned
Other Methods Not the most efficient method Ill-conditioned matrix (nearly singular) If n is large highly inaccurate coefficients Limit to lower order polynomials
Inverse Interpolation X=?
X=? Switch x and y and then interpolate? Not a Good Idea!
Splines
Piecewise smooth polynomials
E.G Quadratic Splines Function Values at adjacent polynomials are equal at interior nodes
E.G Quadratic Splines First and Last Functions pass through end points
E.G Quadratic Splines First Derivatives at Interior nodes are equal
E.G Quadratic Splines Assume Second First Point=0
E.G Quadratic Splines Assume Second First Point=0 Solve 3nx3n system of Equations
Spline Interpolation Polynomial Interpolation Spline Interpolation Polynomial Interpolation