Cmputatinal Methds CMSC/AMSC/MAPL 460 Ramani Duraiswami, Dept. f Cmputer Science
Curse Gals Intrductin t the use f scientific cmputing techniques t slve prblems in varius dmains Understand principles behind algrithms Intelligent chice and use f available sftware Understand hw t Cnvert a mdel int a discrete system n the cmputer Hw t deal with data perfrm simulatins fr applicatins Display and evaluate simulatin results Appreciate which cmputatins are feasible
New Paradigm Scientific Discvery thrugh Cmputing Paradigm? A set f assumptins, cncepts, values, and practices that cnstitutes a way f viewing reality fr the cmmunity that shares them, especially in an intellectual discipline. Engineering (aernautics, fluid dynamics, circuit design, radar, antennas, signal prcessing, ) Physics (stellar dynamics, materials, ) Ecnmics/Scilgy (mdeling and analyzing data, cmputatinal statistics, stck picking, ) Bilgy (bistatistics, cmputatinal bilgy, genmics and prtemics, ) Cmputer Science (mdeling systems/netwrk perfrmance, infrmatin retrieval, ) Yur field
Anther paradigm : Data driven science Grab data and prcess it Audi, vide, text, MRI, X-Ray, weather, strain-gage, flw, gene-chip, seismgraph, Mre s law drives bth prcessing pwer, memry, sensr cst and capability Mre s law: Prcessr speed dubles every 18 mnths Mre generally: Technlgy X capability will duble in Y mnths Need algrithms t prcess larger and larger data sets, and extract infrmatin frm them Fit data, Extract mdel parameters, Learn relatinships In general cmpute with the data
The Curse Tw lectures a week Hmewrk every week r ther week 40% hmewrk, 25% exam 1, 35 % final Attendance/participatin will be a factr Class web site: http://www.umiacs.umd.edu/~ramani/cmsc460/index.html Required Bk Numerical Cmputing with MATLAB by Cleve Mler The gd news The cmplete bk is nline! Bk is als nt as expensive as sme thers (~$40)
Curse Curse cmes with Matlab sftware that is dwnladable frm the bk web site Anther excellent bk/resurce: Numerical Recipes by William H. Press, Saul A. Teuklsky, William T. Vetterling, Brian P. Flannery Als available nline! G t www.nr.cm Practical in the trenches bk
Hmewrk Hmewrk will invlve prgramming in MATLAB mainly prblems frm the text Style/Clarity/Cleanliness f utput will cunt Wrk/Results must be easily understd t be interpreted Visualizatin (graphs) Cmmented cde
Syllabus Intrductin, Cmputer Arithmetic and Errrs (Chapter 1) (apprx. 3 lectures) curse survey intrductin t Matlab machine arithmetic and errr analysis stability and cnditining Slving Linear Systems f Equatins (Chapter 2) (apprx. 4 lectures) Gaussian eliminatin well-cnditining vs. ill-cnditining, matrix and vectr nrms Ntins f algrithm cmplexity sparse systems: direct and iterative methds
Syllabus Interplatin (Chapters 3) (apprx. 4 lectures) plynmial interplatin Other basis functins and plynmials piecewise plynmial interplatin spline interplatin Zers and Rts (Chapter 4) (apprx. 3 lectures) Linear and Nnlinear systems f equatins Bisectin, Secant and Newtn methd Intrductin t ptimizatin Slving Linear Least Squares Prblems (Chapter 5) (apprx. 3 lectures) data-fitting and least squares QR factrizatin
Syllabus Integratin/Quadrature (Chapter 6) elementary integratin frmulas (midpint, trapezid, etc.) cmpund and adaptive integratin frmulas Gaussian quadrature Furier Analysis (Chapter 8) Ordinary Differential Equatins (Chapter 9) (apprx. 4 lectures) rdinary differential equatins and Euler's methd adaptive methds fr rdinary differential equatins methds fr stiff systems
Histry f MATLAB Strengths f MATLAB Weaknesses f MATLAB MATLAB Overview
MATLAB MATrix LABratry Interactive system Prgramming language Extendable What is MATLAB?
What is MATLAB?: 2 Cnsidering MATLAB at hme Standard editin Available fr rughly 2 thusand dllars Student editin Available fr rughly 1 hundred dllars. Sme limitatins Shrter license perid On campus Site license
Histry f MATLAB Ancestral sftware t MATLAB Frtran subrutines fr slving linear (LINPACK) and eigenvalue (EISPACK) prblems
Histry f MATLAB, cn t: 2 One f the develpers f these packages, Cleve Mler wanted his students t be able t use LINPACK and EISPACK withut requiring knwledge f Frtran MATLAB develped as an interactive system t access LINPACK and EISPACK
Histry f MATLAB, cn t: 3 MATLAB gained ppularity primarily thrugh wrd f muth because it was nt fficially distributed In the 1980 s, MATLAB was rewritten in C with mre functinality (such as pltting rutines)
Histry f MATLAB, cn t: 4 The Mathwrks, Inc. was created in 1984 The Mathwrks is nw respnsible fr develpment, sale, and supprt fr MATLAB
Strengths f MATLAB MATLAB is relatively easy t learn MATLAB cde is ptimized t be relatively quick when perfrming matrix peratins MATLAB may behave like a calculatr r as a prgramming language MATLAB is interpreted, errrs are easier t fix Althugh primarily prcedural, MATLAB des have sme bject-riented elements
Weaknesses f MATLAB MATLAB is NOT a general purpse prgramming language MATLAB is an interpreted language (making it fr the mst part slwer than a cmpiled language such as C++) MATLAB is designed fr scientific cmputatin and is nt suitable fr sme things (such as parsing text)
Matlab Windws Cmmand line Interface ( Main Windw) Editr Windw Present Directry Directry Cntents and Wrkspace variables Cmmand line Cmmand Histry
Matrices in Matlab Entering a Matrix: >> A(:,1) >> A = [ 0-0.8-0.6 ; 0.8-0.36 0.48 ; 0.6 0.48-0.64] A = >> A(1,2) ans = -0.8000 >> A(2,:) ans = 0-0.8000-0.6000 0.8000-0.3600 0.4800 0.6000 0.4800-0.6400 Matrix referencing: 0.8000-0.3600 0.4800 ans = 0 0.8000 0.6000 >> A+A; >> A.*A; >> 3*A; >> A*A Matrix Operatins: ans = -1.0000 0 0 0-0.2800-0.9600 0-0.9600 0.2800
Built-in functins Inverting a Matrix >> inv(a) Determinant >> det(a) ans = -1.000 Rank >> rank(a) ans = 3 ans = -0.0000 0.8000 0.6000-0.8000-0.3600 0.4800-0.6000 0.4800-0.6400 Transpse f a Matrix >> A' ans = 0 0.8000 0.6000-0.8000-0.3600 0.4800-0.6000 0.4800-0.6400
Slving Linear System Linear system f algebraic equatins: >> A = [ -1 1 2; 3-1 1 ; -1 3 4] A = -1 1 2 3-1 1-1 3 4 >> b = [2 6 4 ]' b = x 1 + x 2 + 2x 3 = 2 3x 1 x 2 + x 3 = 6 x 1 + 3x 2 + 4x 3 = 4 2 6 4 >> rank(a) ans = 3 >> x = b\a (als culd d inv(a)*b, but nt recmmended) x = Ax=b 1.0000-1.0000 2.0000
Pltting a functin y 1 7x 0.6 + x y 2 5x 0.08 + x >> x = [ 0:0.01:5]; >> y1 = 7 * x./ ( 0.6 + x ); >> y2 = 5 * x./ ( 0.08 + x ); >> plt(x,y1,x,y2) >> legend('y1','y2')
Intrductin t MATLAB Vectrs, Matrices, Syntax Vectr peratins, including the \dt cmmands length, size, linspace, lgspace, size, rand, randn, randperm Special vectrs and matrices: zers, nes, eye, magic Scripts and functins Diary Graphing: plt, special fnts, plt3, semilgx, semilgy, title, xlabel, ylabel, axis, grid, legend, subplt, Frmatted utput: Sprintf, ;, disp, input Prgramming: fr, if, while, &,, ~ General/misc cmmands ginput set, size, max, sum, clse, figure, hist, any, all, flr, fix, rund, Graphical prgramming and callbacks