Linear System expensive p=[0,0.2,0.4,0.45,0.5,0.55,0.6,0.8,1]; t=[1:8; 2:9]; e=[1,9]; n = length(p); % number of nodes m = size(t,2); % number of elements.

Slides:



Advertisements
Similar presentations
Numerical Solution of Linear Equations
Advertisements

Parallel Jacobi Algorithm Steven Dong Applied Mathematics.
Linear System Remark: Remark: Remark: Example: Solve:
Algebraic, transcendental (i.e., involving trigonometric and exponential functions), ordinary differential equations, or partial differential equations...
Linear Systems of Equations
Solving Linear Systems (Numerical Recipes, Chap 2)
Systems of Linear Equations
SOLVING SYSTEMS OF LINEAR EQUATIONS. Overview A matrix consists of a rectangular array of elements represented by a single symbol (example: [A]). An individual.
Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible.
Numerical Algorithms Matrix multiplication
Modern iterative methods For basic iterative methods, converge linearly Modern iterative methods, converge faster –Krylov subspace method Steepest descent.
Special Matrices and Gauss-Siedel
1 Systems of Linear Equations Iterative Methods. 2 B. Iterative Methods 1.Jacobi method and Gauss Seidel 2.Relaxation method for iterative methods.
Shawn Sickel A Comparison of some Iterative Methods in Scientific Computing.
Linear Systems What is the Matrix?. Outline Announcements: –Homework III: due Wed. by 5, by Office Hours: Today & tomorrow, 11-1 –Ideas for Friday?
1 Systems of Linear Equations Iterative Methods. 2 B. Direct Methods 1.Jacobi method and Gauss Seidel 2.Relaxation method for iterative methods.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 20 Solution of Linear System of Equations - Iterative Methods.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 19 Solution of Linear System of Equations - Iterative Methods.
Special Matrices and Gauss-Siedel
ECIV 520 Structural Analysis II Review of Matrix Algebra.
Ordinary least squares regression (OLS)
CS240A: Conjugate Gradients and the Model Problem.
Thomas algorithm to solve tridiagonal matrices
ECIV 301 Programming & Graphics Numerical Methods for Engineers REVIEW II.
Monica Garika Chandana Guduru. METHODS TO SOLVE LINEAR SYSTEMS Direct methods Gaussian elimination method LU method for factorization Simplex method of.
Iterative Methods for Solving Linear Systems of Equations ( part of the course given for the 2 nd grade at BGU, ME )
Scientific Computing Matrix Norms, Convergence, and Matrix Condition Numbers.
Example: Introduction to Krylov Subspace Methods DEF: Krylov sequence
Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
Chapter 8 Objectives Understanding matrix notation.
Computer Engineering Majors Authors: Autar Kaw
ITERATIVE TECHNIQUES FOR SOLVING NON-LINEAR SYSTEMS (AND LINEAR SYSTEMS)
Scientific Computing Linear Systems – LU Factorization.
9/7/ Gauss-Siedel Method Chemical Engineering Majors Authors: Autar Kaw Transforming.
Numerical Linear Algebra IKI Course outline Review linear algebra Square linear systems Least Square Problems Eigen Problems Text: Applied Numerical.
Linear Algebra and Complexity Chris Dickson CAS Advanced Topics in Combinatorial Optimization McMaster University, January 23, 2006.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
1 Iterative Solution Methods Starts with an initial approximation for the solution vector (x 0 ) At each iteration updates the x vector by using the sytem.
Introduction to Scientific Computing II From Gaussian Elimination to Multigrid – A Recapitulation Dr. Miriam Mehl.
Chapter 3 Solution of Algebraic Equations 1 ChE 401: Computational Techniques for Chemical Engineers Fall 2009/2010 DRAFT SLIDES.
Linear System function [A,b,c] = assem_boundary(A,b,p,t,e); np = size(p,2); % total number of nodes bound = unique([e(1,:) e(2,:)]); % boundary nodes inter.
Parallel Solution of the Poisson Problem Using MPI
Linear Systems – Iterative methods
Introduction to Scientific Computing II Overview Michael Bader.
1 Solving the algebraic equations A x = B =. 2 Direct solution x = A -1 B = = Applicable only to small problems For the vertical in the spectral technique.
1 Chapter 7 Numerical Methods for the Solution of Systems of Equations.
Part 3 Chapter 12 Iterative Methods
Gaoal of Chapter 2 To develop direct or iterative methods to solve linear systems Useful Words upper/lower triangular; back/forward substitution; coefficient;
數值方法, Applied Mathematics NDHU 1 Linear system. 數值方法, Applied Mathematics NDHU 2 Linear system.
MA237: Linear Algebra I Chapters 1 and 2: What have we learned?
Lecture 9 Numerical Analysis. Solution of Linear System of Equations Chapter 3.
ALGEBRAIC EIGEN VALUE PROBLEMS
MA2213 Lecture 12 REVIEW. 1.1 on page Compute Compute quadratic Taylor polynomials for 12. Compute where g is the function in problems 11 and 12.
Iterative Solution Methods
Simultaneous Linear Equations
Solving Systems of Linear Equations: Iterative Methods
بسم الله الرحمن الرحيم.
Gauss-Siedel Method.
Numerical Analysis Lecture12.
Linear Algebra Lecture 15.
A Comparison of some Iterative Methods in Scientific Computing
CSE 245: Computer Aided Circuit Simulation and Verification
Autar Kaw Benjamin Rigsby
CSE 245: Computer Aided Circuit Simulation and Verification
Matrix Methods Summary
MATH-321 In One Slide MATH-321 & MATLAB Command.
Numerical Linear Algebra
Linear Algebra Lecture 16.
Multiply by 5/40 and sum with 2nd row
Ax = b Methods for Solution of the System of Equations:
Presentation transcript:

Linear System expensive p=[0,0.2,0.4,0.45,0.5,0.55,0.6,0.8,1]; t=[1:8; 2:9]; e=[1,9]; n = length(p); % number of nodes m = size(t,2); % number of elements uexact = inline('x*(1-x)','x'); [M] = createM(p,e,t) [K] = createK(p,e,t) [L] = createL(p,e,t) A = K + M; for i=1:length(e) ib = e(i); A(ib,:)=sparse(1,n);A(:,ib)=sparse(n,1); A(ib,ib)=1;L(ib)=0; end U = A\L; ezplot('x*(1-x)',[0,1]); hold on; plot(p,U,'r-o'); grid on; hold off

tic; any matlab line; toc p=[0,0.2,0.4,0.45,0.5,0.55,0.6,0.8,1]; t=[1:8; 2:9]; e=[1,9]; n = length(p); % number of nodes m = size(t,2); % number of elements uexact = inline('x*(1-x)','x'); [M] = createM(p,e,t) [K] = createK(p,e,t) [L] = createL(p,e,t) A = K + M; for i=1:length(e) ib = e(i); A(ib,:)=sparse(1,n);A(:,ib)=sparse(n,1); A(ib,ib)=1;L(ib)=0; End tic U = A\L; toc ezplot('x*(1-x)',[0,1]); hold on; plot(p,U,'r-o'); grid on; hold off The most expensive line in the code is solving the linear system of equations

Linear System We want to solve the following linear system These methods generate a sequence of approximate solutions Gaussian Elimination LU, Choleski 2 classes of methods Direct Methods Iterative Methods

Linear System (Numerical Linear Algebra, Trefethen) Gaussian Elimination LU, Choleski Direct Methods We want to solve the following linear system We apply a sequence of row operations to convert the matrix A into an upper triangular matrix

Linear System We want to solve the following linear system 2 classes of methods Direct Methods Iterative Methods (Trefethen book) The following table gives a thumbnail of matrix computations over the year: 1950n= n= n= n=20000 These numbers represent a rough approximation to what dimensions might have been considered “very large” for a dense, direct matrix computations at the indicated dates

observations made by Horst Simon [173]. He predicted that by now we will have to solve routinely linear problems with some 5 × 10^9 unknowns. From extrapolation of the CPU times observed for a characteristic model problem, he estimated the CPU time for the most efficient direct method as years, provided that the computation can be carried out at a speed of 1 TFLOPS. On the other hand, the extrapolated guess for the CPU time with preconditioned conjugate gradients, still assuming a processing speed of 1 TFLOPS, is 575 seconds. ‘flops’ floating point operations. Each addition, subtraction, multiplication, division, or square root counts as one flop.

Linear System Iterative Methods Krylov subspace splitting others Jacobi, GS, SOR,..PCG, MINRES, GMRES, …

Linear System Remark: (1) has a unique solution We want to solve the following linear system A is invertable Remark: A is invertable det(A)=0 Remark: A is invertable Example: Solve:

Linear System We want to solve the following linear system Remark: Definition: Example:

Iterative Method These methods generate a sequence of approximate solutions Remark:

DEF: with eigenvalues Splittings and Convergence DEF: spectral radius of A is defined to be Splitting A large family of iteration

Splittings and Convergence A large family of iteration DiagonalLowerUpper Jacobi:Gauss-Seidel:

Jacobi Method Consider 4x4 case Example

K=6K=7K=8K=9K=10 x1 x2 x3 X4 K=1K=2K=3K=4K=5 x1 x2 x3 X4 Jacobi Method

K=1K=2K=3K=4K=5 x1 x2 x3 X4 Gauss Seidel Method Note that in the Jacobi iteration one does not use the most recently available information.

Gauss-Seidel iteration for general n: Gauss Seidel Method Jacobi iteration for general n:

Splittings and Convergence THM: A large family of iteration

Splittings and Convergence Example: Jacobi: U=triu(A,1) L=tril(A,-1) D=diag(diag(A)) eig(inv(M)*N) GS: i i

Splittings and Convergence THM: A large family of iteration Proof: (Golub p511) Remarks:

Splittings and Convergence THM: Proof: (Golub p512) show that all eigenvalues are less than one. Positive Definite Symmetric Stiffness Matrix Mass Matrix

Example: Splittings and Convergence DEF: IF THM:

Successive over Relaxation The Gauss-Seidel iteration is very attractive because of its simplicity. Unfortunately, if the spectral radius is close to one, then convergence is vey slow. One solution for this Successive over Relaxation GS:

Successive over Relaxation Example:

K=1K=2K=3 x1 x2 x3 X4 Successive over Relaxation Example:

MATLAB CODE Jacobi iteration for general n: Ex: Write a Matlab function for Jacobi function [sol,X]=jacobi(A,b,x0) n=length(b); maxiter=10; x=x0; for k=1:maxiter for i=1:n sum1=0; for j=1:i-1 sum1=sum1+A(i,j)*x(j); end sum2=0; for j=i+1:n sum2=sum2+A(i,j)*x(j); end xnew(i)=(b(i)-sum1-sum2)/A(i,i) end X(1:n,k)=xnew; x=xnew; end sol=xnew;

MATLAB CODE GS iteration for general n: Ex: Write a Matlab function for GS function [sol,X]=gs(A,b,x0) n=length(b); maxiter=10; x=x0; for k=1:maxiter for i=1:n sum1=0; for j=1:i-1 sum1=sum1+A(i,j)*x(j); end sum2=0; for j=i+1:n sum2=sum2+A(i,j)*x(j); end x(i)=(b(i)-sum1-sum2)/A(i,i) end X(1:n,k)=x; end sol=x;