Unformatted text preview:

December 2001 10.001 Introduction to ComputerMethodsCourse ReviewWhat you hopefully have learned:1. How to navigate inside MIT computer system:Athena, UNIX, emacs etc. (GCR)2. General ideas about programming (GCR):• formulating the problem, “coding” in English• translation into computer language• editing• compiling + debugging• running3. Quite a bit of knowledge of C (GCR, midterm).December 2001 10.001 Introduction to ComputerMethodsCourse Review4. MATLAB:• Matlab = matrix laboratory, matrix oriented.• Any variable is an array by default, thus almost nodeclarations. All variables are by default double• High level language:• (i) quick and easy coding• (ii) lots of tools (Spectral Analysis, ImageProcessing, Signal Processing, Financial, SymbolicMath etc.)• (iii) relatively slowDecember 2001 10.001 Introduction to ComputerMethodsCourse Review• Translator - interpreter, reads and executes line afterline, but All Matlab functions are precompiled.• One (YOU) may add extra functions by creating M-files.• Language structure is similar to C:- MATLAB supports variables, arrays, structures,subroutines, files, flow of control structures-MATLAB does NOT support pointers and does notrequire variable declarationsDecember 2001 10.001 Introduction to ComputerMethodsDealing with Matrices in Matlab• Matlab has all standard operations & functionsimplemented for matrices (& vectors).• Standard math. functions of matrices operate inarray sense (act on each matrix entry independently:exp(A), sin(A), sqrt(A) = A.^0.5>> B = exp(A)B(i,j) = exp(A(i,j))• Any matrix multiplication/division or rising matrixinto some power may be both matrix and arrayoperation.December 2001 10.001 Introduction to ComputerMethodsDealing with Matrices in Matlab• A*B - matrix product of n x m and m x p matrices,but A.*B - array (element by element) product of twon x m matrices.• B=sqrt(A) Å Bij=sqrt(Aij), A&B - any matrices,but B=A^0.5 Å A=B*B and A&B should be square.• Submatrices:A(1:4,3) - column vector, first 4 elements of the3-d column of A.A(:,3) - the 3-d column of AA(:,[2 4]) - 2 columns of A: 2-d & 4-th./December 2001 10.001 Introduction to ComputerMethodsDealing with Matrices, Examples>> C = A + B;C(k,l) = A(k,l) + B(k,l)>> C = A*B;C(k,l) = A(k,m) * B(m,l)>> C = A.*BC(k,l) = A(k,l)*B(k,l)>> C = A^alpha;>> C = A.^alpha;C(k,l) = A(k,l)^alphaMatrix multiplication,summation over the repeatingindex is implied.Element-wise (array)operationDecember 2001 10.001 Introduction to ComputerMethodsCourse ReviewI hope you’ve learned the basic linear algebra and it’sMatlab implications:1. Matrix(vector) addition/subtraction & multiplication.Say, what is the difference between a*b’ and a’*b, wherea and b are vectors?2. Colon notation and operating with submatrices.Remember, lots of summation, multiplication etc. loopsmay be eliminated by using the colon notation (seesolution to hw8-10 for example).3. Basic Matlab syntax: Given you know C, you mayfigure out many Matlab properties by analogy, but stillyou are expected to have a clear idea about:December 2001 10.001 Introduction to ComputerMethodsCourse Review• writing functions in Matlab• flow of control statements• How to use desktop & maintain the workspace.• How to deal with “black boxes”:i) help FUNCTIONNAMEii) what does the function do?iii) what’s in and what’s out?iv) how to prepare what’s in (usually vectorsand matrices)v) ideally: what’s inside the black box,to predict possible problemsDecember 2001 10.001 Introduction to ComputerMethods5. You have learned about a set of general problems,which can be solved by programming:root finding (GCR),systems of linear equations,systems of non-linear equations,fitting experimental data.December 2001 10.001 Introduction to ComputerMethods Matrix Formulation of SLESystem of linear equations, example:a11x1 + a12x2 + …+ a1nxn = b1a21x1 + a22x2 + ….+ a2nxn = b2…..an1x1 + an1x2 +…+annxn = bnA - coefficient matrix, b - load vectorbxAbbbxxxnn=⋅=…………...... a a a.. a a a a a a2121nnn2n12n22211n12 11December 2001 10.001 Introduction to ComputerMethodsGaussian EliminationExample: x + 2 y + z = 02 x + 2 y + 3 z = 3-x + 3 y + 0 z = -41. Eliminate x from eqs 2 & 3.2. Eliminate y from equation 2.3. Solve eq. 3 for z and backsubstitute to eqs 1&24. Solve eq. 2 for y and backsubstitute to eq. 1.5. Solve eq. 1 for x.December 2001 10.001 Introduction to ComputerMethods**)3(33)3(33*)2(23)2(232)2(221313212111)3()2()1(bxabxaxabxaxaxa==+=++)2(232)2(3)3(3)2(2332)2(33)3(33bmbbamaa−=−=Subtract m32 times (2) from (3)*The new coefficients are give byGaussian Elimination (last step)December 2001 10.001 Introduction to ComputerMethodsScalabilityCode for Gaussian elimination contains 3 loops:1. makes n-1 runs to eliminate variables2. k-th run goes through n-k rows (k = 1,. . ., n-1)3. in i-th row we calculate aij = aij - m akj n-k timesOverall about operations.∑−=−−1n1k)kn)(kn(Time scales as n3 ! A rather poor scalability.December 2001 10.001 Introduction to ComputerMethodsLU factorization.A ------> U (upper diagonal) A = LUb -------> cb = L cA = LUL-1 describes Gussian elimination.c = L-1 bGEGEDecember 2001 10.001 Introduction to ComputerMethodsNumerical StabilityProblems appear if we have small numbers at thediagonal of the coefficients matrix. Solution -”pivoting”.Pivoting algorithm:Searches for the largest aik in each row below thecurrent one to use for the next elimination step, andrearranges the rows so that mik is always less thanone.December 2001 10.001 Introduction to ComputerMethods Introduction to Data Analysis• Random & Systematic Errors• How to Report and Use Experimental Errors• Statistical Analysis of Data– Statistics of random errors– Error propagation, functions of measurables– Plotting and displaying the data– Fitting the data: linear and non-linear regressionDecember 2001 10.001 Introduction to ComputerMethodsStatistical Analysis of Random Errors.∑===N1iibestxN1xxMeanDeviationxxdii−=Standard deviation,root mean squareof the measurements2N1ii2N1iix)xx(N1)d(N1−==∑∑==σDecember 2001 10.001 Introduction to ComputerMethodsPropagation of ErrorsIf errors are independent and random:for the sum/difference the errors of the independent items are added in quadrature.()()() ()() ( )22222 2... ( ... )... ......


View Full Document

MIT 10 001 - Course Review

Download Course Review
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Course Review and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Course Review 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?