Välkomna till NUMPBIO11: DN1212 Numeriska metoder och grundläggande programmering för Bio3, 9 hp Kurshemsida http://www.csc.kth.se/dn1212/numpbio11/ 110824 DN1212 NUMPB11 1 Beatrice Frock, beatrice@csc.kth.se (kursansvarig, numeriska metoder) Jesper Oppelstrup, jespero@csc.kth.se (MATLAB) Övningsledare Grupp 1: Beatrice Frock Grupp 2: Jennifer Grünig Grupp 2: Kaspar Müller Kurslitteratur, säljs på kårbokhandeln 1. P.Pohl: Grundkurs i Numeriska metoder (GNM) 2. S.J. Chapman: Matlab Programming for Engineers (PEng) Kursbunt, xxxsek, säljs på CSC stud exp: Osquars B. 2, plan 2 - kontant snabbare än kort! Kursprogram, Hederskodex Edsberg, Eriksson, Lindberg: Exempelsamling i numeriska metoder Laborationsuppgifter Användarhandledning för Matlab på Nada, Matlabterminologi Extentor 110824 DN1212 NUMPB11 2 1
Laborationer 6 obligatoriska,rapporteras i Ladok, syns i Mina sidor som LAB1 (1 + 2), LAB2 (3), LAB3 (4 + 5), LAB4 (6, = projektet). Grupper om 2. Redovisas för handledare i datorsal. Terminalövningar i datorsal : handledare tillgängliga för konsultationer och redovisningar. Lab-arbete: ca. 160 tim = 5-7 tim eget arbete/vecka förutom schemalagd tid. Det behövs datorkonto för att köra på CSC-datorer. Delas ut nu, på F2 31/8 och TÖ1 1/9. Vänta inte till TÖ! 110824 DN1212 NUMPB11 3 Bonus Laborationer som redovisas i tid ger bonus, max. 4 tp. Tentamen samma för alla DN1212-kurser Inga hjälpmedel, 3 timmar. Två delar. Godkänd del 1 ger betyget E. Del 2 rättas endast om del 1 är godkänd: D-A. Del 1: flervalsuppgifter Del 2: problemuppgifter, Matlab-program, algoritmbeskrivning. Ordinarie tenta: ons 17/12, kl 9 12, sal: Lxx & Qyy Kursutvärderingsenkät I slutet av kursen. Synpunkter mottages tacksamt när som helst direkt till lärare, eller via e-mail. 110824 DN1212 NUMPB11 4 2
VECKA 35 29/8 F1 Introduktion. MATLAB. Kap 1-2 i PEng 29/8 Ö1 Programmering, t.ex 2.1, 2.6, 2.10, 2.16 (2.14) i PEng 31/8 F2 Styrstrukturer, programmeringsteknik. Kap 3 4 i PEng 1/9 TÖ1 kursreg. via Rapp. Arbete med och redovisning av Lab 1 2/9 Ö2 Programmering, t.ex. 3.3, 3.7, 4.7a, 4.8a, 4.9a, 4.19 i PEng VECKA 36 5/9 F3 Funktioner, kap 5 i PEng 6/9 Ö3, Programmering, t.ex. 5.2, 5.9, 5.22 (5.17), 5.28 (5.24) i PEng 7/9 TÖ2 Arbete med Lab 2 110824 DN1212 NUMPB11 5 It is hard to understand... an ocean because it is too big. a molecule because it is too small. nuclear physics because it is too fast. the greenhouse effect because it is too slow. [Super] Computers break these barriers to understanding. They, in effect, shrink oceans, zoom in on molecules, slow down physics, and fast-forward climates. Clearly a scientist who can see natural phenomena at the right size and the right speed learns more than one who is faced with a blur. Vem, när? 110824 DN1212 NUMPB11 6 3
The purpose of computing is insight, not numbers. (R.W.Hamming) The Unreasonable Effectiveness of Mathematics (1980) There are three kinds of lies: Lies, damn lies, and colorful computer pictures (P.Colella) 110824 DN1212 NUMPB11 7... not 110824 DN1212 NUMPB11 8 4
Helt dominerande program för ingenjörsberäkningar, numerisk analys, visualisering, 1974 Matrix Laboratory C.Moler Nu: MathWorks > 2200 pers. MATLAB Varför MATLAB? 20 årsdag 2004: Life is too short for writing do-loops C.Moler, 1974 110824 DN1212 NUMPB11 9 http://www.ima.umn.edu/~arnold/disasters/disasters.htm Have you been paying attention in your numerical analysis [] courses? If not, it could be a costly mistake. Here are some real life examples...: The Patriot Missile failure, in Dharan, Saudi Arabia, February 25, 1991... poor handling of rounding errors. The explosion of the Ariane 5 rocket just after lift-off on its maiden voyage off French Guiana, on June 4, 1996,... the consequence of a simple overflow. The sinking of the Sleipner A offshore platform in Gandsfjorden near Stavanger, Norway, on August 23, 1991,... the result of inaccurate finite element analysis. 110824 DN1212 NUMPB11 10 5
MATLAB 1 rad: x = A\b; F77 50 rader subroutine msolve(n,a,b,x) implicit none integer n real*8 A(n,n),b(n),x(n) do i=1,n c Search for pivot element col = i row = i do j=i,n do k=i,n if(abs(a(p(k),q(j))).gt. abs(a(p(row),q(col)))) then row = k col = j endif enddo enddo c Swap diagonal element with found pivot k = p(i) end Intel x86 assembler 500 rader.file "msolve.f".section.rodata.str1.1,"ams",@progbits,1.lc0:.string "Memory allocation failed".text.globl msolve_.type msolve_, @function msolve_: %ebp %esp, %ebp %edi %esi %ebx subl $108, %esp 8(%ebp), %ebx 12(%ebp), %eax 16(%ebp), %edx 20(%ebp), %ecx (%ebx), %esi %eax, -76(%ebp) %edx, -80(%ebp) %ecx, -84(%ebp) %esi, %eax notl %eax sarl $31, %eax andl %eax, %esi %esi, -20(%ebp) -20(%ebp), %eax notl %esi %esi, -56(%ebp) $0, -44(%ebp) sall $2, %eax je.l4 subl $12, %esp %eax call malloc addl $16, %esp testl %eax, %eax %eax, -44(%ebp) je.l39.l4: (%ebx), %edx $0, -40(%ebp) %edx, %eax notl %ea 110824 DN1212 NUMPB11 11 MATLAB: (s = 3;) s = s + 2; PowerPC Assembler LD r14,[s] ADDI r14,r14,2 ST [s],r14 Nr. 102679 Minne 0 0 Minnesplats för s ( symbolisk adress ) Fysisk adress: 102679 3 CPU-register 5 r15 r14 r13 110824 DN1212 NUMPB11 12 6
Sverige Germund Dahlquist 1925-2005, KTH Svante Littmarck, Dr HC, KTH Huvudkontor Boston:150 Utveckling:Stockholm: 30 110824 DN1212 NUMPB11 13 7