Apr 01, 2015

- Slide 1

Material 1.Grading sheet 2.Micromanaged schedule 3.Literature list 4.Reading list and lecture content 5.Matlab introduction exercises 6.Project 1 Part 1: Air resistance Part 2: Planetary motion Part 3: Advanced exercises 7. Numerical methods lit. extracts 8. Mechanics lit. extracts Address to e-book linked at web site: http://www.springerlink.com/content/w8302n/http://www.springerlink.com/content/w8302n/? p=35f7440cdc9b4ab6bc38d380d9b3c4aa&pi=0 Numeriska berkningar i Naturvetenskap och Teknik Slide 2 Part A, Technical aspects and the use of MATLAB 1.Short history. Why machine based computing? 2.Programming 3.Demonstration of basics Part B, Numerical Methods 1. Numerical solution of differential equations 2. Numerical solution of algebraic equations 3. Fitting models to data 4. Adaptation to problem in physics: planetary motion Numeriska berkningar i Naturvetenskap och Teknik Slide 3 Why compute using machines and numerical methods? 1. Work saving for extensive and trivial calculations 2. Reproducible results, minimizes errors due to the human factor. However, new possibilities or mistakes arise: programming errors 3. Equation solving: including algebraic equations but above all differential equations that lack solution in closed form, i.e. that have no analytical solution. 4. Monte Carlo simulations of stochastic processes Points 3 and 4 are the main reasons computers are vital in modern physics. Numeriska berkningar i Naturvetenskap och Teknik Slide 4 Wilhelm Shickard: 1592 1635 From Tuebingen, Germany. Designed mechanical calculator for addition of six figure numbers. Some issues remain unclear. Limited future influence. Reconstructed. Numeriska berkningar i Naturvetenskap och Teknik 1623 Slide 5 1670 Numeriska berkningar i Naturvetenskap och Teknik Blaise Pascal: 1623-1662 Invented the so called Pascaline around 1645. The purpose was to simplify his fathers work as tax collector in Rouen, France. The machine could add and multiply. Subtractions was complicated and time consuming. 1645 Slide 6 Gottfried Leibniz: 1646-1716 Constructed in 1670 the first machine that could do all the four basic algebraic operations. 1670 Numeriska berkningar i Naturvetenskap och Teknik Slide 7 Charles Xavier Thomas de Colmar: 1785-1870. Based on Leibniz design de Colmar constructs the first commercially successful mechanical calculator, the arithometer. Ca 1500 are made for use by the French civil service. 1670 1820 Numeriska berkningar i Naturvetenskap och Teknik Slide 8 Charles Babbage: 1791-1871 Designed the first programmable calculator (difference engine) with the purpose to reduce the number of errors in mathematical tables. Later designed a mechanical computer, the analytical engine. Neither machine finished during his lifetime. Ada Countess of Lovelace: Known as the first programmer. Wrote program to calculate the so-called Bernoulli numbers using Babbages analytical engine. Numeriska berkningar i Naturvetenskap och Teknik Slide 9 Georg and Edvard Scheutz: 1785-1873 and 1821-1881 Numeriska berkningar i Naturvetenskap och Teknik Slide 10 Alan Turing: 1912-1954 Computer science pioneer. Formalized the algorithm concept and introduced, in 1936, the theoretical background of computers with the Turing machine, defined by a set of instructions, storage space etc. Today a machine of this kind is called a finite-state machine. Konrad Zuse: 1910-1995 Constructed in 1941 the first programmable computer based on telephone relays partly financed by Deutsche Versuchsanstalt fur Luftfarth. 1936 Numeriska berkningar i Naturvetenskap och Teknik Slide 11 John von Neumann: 1903-1957 Born in Budapest. PhD in math and chemical engineer Immigrated to the US and became citizen in 1938 One of the first faculty members at IAS, Princeton together with Einstein, Gdel, Weyl. Made significant contributions in - Mathematics - Physics - Economic theory - Computer science etc Original work on computing at Princeton in relation to ballistic calculations, later simulations for thermonuclear explosions. Numeriska berkningar i Naturvetenskap och Teknik Johnny vN Morgenstern Slide 12 John von Neumann: 1903-1957 Wrote, in 1945, The first draft report on the EDVAC EDVAC (Electronic Discrete Variable Automatic Computer) was the successor of ENIAC (the Electronic Numerical Integrator and Calculator) which in turn was the first large scale programmable digital computer (vacuum tube based). EDVAC, in contrast to ENIAC, could be reprogrammed without physical recabling as the program and data were in memory. This kind of machine, which stores program and data in the same memory unit is the dominating computer architecture today and goes under the name von Neumann architecture. Numeriska berkningar i Naturvetenskap och Teknik Oppie Feynman Ulam CU ALU INOUT MEM CP U Slide 13 SOME BASIC CONCEPTS Numeriska berkningar i Naturvetenskap och Teknik Slide 14 CPU and instruction set Every instruction that the processor (CPU) can execute corresponds to a code, i.e. a number stored electronically in the memory of the machine. ------------------------------------------------------------- Typical instructions contain a so-called opcode that corresponds to a command, and one or several operands that the opcode uses as arguments. ------------------------------------------------------------- All instructions are operations on binary numbers in the computer memory. ------------------------------------------------------------- A processor has a limited number of instructions it can perform. These make up the processors instruction set. Numeriska berkningar i Naturvetenskap och Teknik Slide 15 A typical sequence to add two numbers, a and b, could be based on instructions such as Load and Add etc: 1. Load a in register 1 in memory 2. Load b in register 2 in memory 3. Add register 1 to register 2 4. Store register 2 in the position of b in memory This means that programming became a complex problem in itself. Using machine code is both time consuming and prone to programming errors. ------------------------------------------------------------ Still, this was the way the first computers were programmed and it is still in use under certain circumstances. Numeriska berkningar i Naturvetenskap och Teknik Slide 16 Low level and high level programming In low level programming one uses a programming language which is close to the instruction set of the processor. One such method goes under the name assembler programming. -------------------------------------------------------------- In this case instructions such as addition, subtraction, bit shifts, register access etc are coded using mnemonics. These are translated by a program to the numbers that correspond to a certain instruction in the set, i.e. to machine code. -------------------------------------------------------------- Mnemonics can e.g be: DEC B, (decrease content of register B), ADD A,B (add reg A to reg B) etc. Numeriska berkningar i Naturvetenskap och Teknik Slide 17 Low level and high level programming For the most part modern programmering is done in high level programming languages whose syntaxes are such that they are close to our ordinary language. Several high level languages have been developed over the years. Some well known ones are: FORTRAN (Formula translation) COBOL (Common business language) ADA (in honor of Lady Lovelace) LISP (List processing language) PASCAL (in honor of Blaise P), C (it developped from B) SIMULA (a commonly used training language, weird) C++ (Object oriented extension of C) -------------------------------------------------------------- All these contain similar structures but have slightly different syntaxes. Numeriska berkningar i Naturvetenskap och Teknik Slide 18 Interpreted and compiled programming languages Source code Machine code Compiler Interpreter Performed once Produces an executable file Performed every time program runs BASIC, different scripting languages (Perl, Ruby) FORTRAN, C, C++ Produces executable code line-by-line Rel. slow Quick Java: byte code compiler + Virtual machine -> machine code => Portability (compile once run everywhere) MATLAB Numeriska berkningar i Naturvetenskap och Teknik Slide 19 MATLAB as calculator: >> 2 * 2 ans = 4 >> ans*2 ans =8 The latest answer stored in ans >> pi ans = 3.14159265358793 Command window i MATLAB Numeriska berkningar i Naturvetenskap och Teknik Slide 20 Variable Entity introduced in order to store numerical values In classical physics it can be time, acceleration, position etc... -------------------------------------------------------- It is a very GOOD idea to give names to variables that connect to their use. -------------------------------------------------------- For physics problems, it is good to use notation given by the standard physics notation for the quantity. This is very helpful when programming under all circumstances. Numeriska berkningar i Naturvetenskap och Teknik Slide 21 Look at the trivial example >> A=1 A = 1 >> B=2 B = 2 >> C=A*B C = 2 Numeriska berkningar i Naturvetenskap och Teknik Slide 22 Och jmfr med: >> m=1 m = 1 >> a=2 a = 2 >> F=m*a F = 2 >> Numeriska berkningar i Naturvetenskap och Teknik Slide 23 Variables Variables can be of different types. Depending on type the computer will store the variable using a different number of bits. ---------------------------------------------------------- Types can be: 1. Integers of different lengths, 8, 16, 32, 64 bits etc 2. Floating point numbers of different lengths, i.e. decimal numbers with different precision 3. Vectors/matrices 4. Strings etc... ---------------------------------------------------------- Normally such a program begins with a declaration sequence. Numeriska berkningar i Naturvetenskap och Teknik Slide 24 Variables In MATLAB which, like BASIC, is an interpreted language one does not have to declare the type of the variable (in

Related Documents See more >