Välkomna till NUMPK09: DN1212 Numeriska metoder och grundläggande programmering för K2 och Bio3, 9 hp Kurshemsida http://www.csc.kth.se/dn1212/numpk09/ 091027 DN1212 NUMPK09 1
Beatrice Frock, beatrice@csc.kth.se (kursansvarig, numeriska metoder, Bio) Jesper Oppelstrup, jespero@csc.kth.se (MATLAB, Bio) Eva Hansén, K Rodrigo Vilela de Abreu, K Kurslitteratur,säljs på kårbokhandeln 1. P.Pohl: Grundkurs i Numeriska metoder (GNM) 2. S.J. Chapman: Matlab Programming for Engineers (PEng) Kursbunt, 120SEK, 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 091027 DN1212 NUMPK09 2
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 per vecka förutom schemalagd tid. 091027 DN1212 NUMPK09 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/3, kl 14 17 i D, E, V och Q salar Kursutvärderingsenkät I slutet av kursen. Synpunkter mottages tacksamt när som helst direkt till lärare, eller via e-mail. 091027 DN1212 NUMPK09 4
VECKA 44 27/10 F1 Introduktion. MATLAB. Kap 1-2 i PEng 27/10 Ö1 Programmering, t.ex 2.1, 2.6, 2.10, 2.16 (2.14) i PEng 30/10 F2 Styrstrukturer, programmeringsteknik. Kap 3 4 i PEng 30/10,2/11 Ö2 Programmering, t.ex. 3.3, 3.7, 4.7a, 4.8a, 4.9a, 4.19 i PEng VECKA 45 3/11 F3 Funktioner, kap 5 i PEng 3/11 Ö3, Programmering, t.ex. 5.2, 5.9, 5.22 (5.17), 5.28 (5.24) i PEng 4/11 TÖ1 Checka in i res. Arbete med och redovisning av Lab 1 091027 DN1212 NUMPK09 5
It is hard to understand an ocean because it is too big. It is hard to understand a molecule because it is too small. It is hard to understand nuclear physics because it is too fast. It is hard to understand 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? Al Gore, 1990, Scientific Computing (A Convenient Truth!) 091027 DN1212 NUMPK09 6
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) 091027 DN1212 NUMPK09 7
Helt dominerande program för ingenjörsberäkningar, numerisk analys, visualisering, 1974 Matrix Laboratory C.Moler Nu: MathWorks > 2200 pers. MATLAB 20 årsdag 2004: Varför MATLAB? Life is too short for writing do-loops C.Moler, 1974 091027 DN1212 NUMPK09 8
Sverige Germund Dahlquist 1925-2005, KTH Svante Littmarck, Dr HC, KTH Huvudkontor Boston:150 Utveckling:Stockholm: 30 091027 DN1212 NUMPK09 9
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) c c end do i=1,n 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 Swap diagonal element with found pivot k = p(i) Intel x86 assembler 500 rader.file.section "msolve.f".rodata.str1.1,"ams",@progbits,1 091027 DN1212 NUMPK09 10.LC0:.globl msolve_ msolve_:.l4:.string.text.type "Memory allocation failed" msolve_, @function pushl %ebp %esp, %ebp pushl %edi pushl %esi pushl %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 pushl %eax call malloc addl $16, %esp testl %eax, %eax %eax, -44(%ebp) je.l39 notl %ea (%ebx), %edx $0, -40(%ebp) %edx, %eax
MATLAB: (s = 3;) s = s + 2; PowerPC Assembler LD r14,[s] ADDI r14,r14,2 ST [s] r14 Minne 0 0 Nr. 102679 Minnesplats för s ( symbolisk adress ) Fysisk adress: 102679 3 CPU-register 5 r15 r14 r13 091027 DN1212 NUMPK09 11