Numerical Analysis, lecture 1: Introduction • Course info • What is numerical analysis? (textbook §1.1-2) function example2 [t,Y] = ode45(@rocket,[0 40],[0 0]); plot(t,Y(:,1),'linewidth',3) xlabel('t'), ylabel('h','rot',0), box off function dy = rocket(t,y) v = y(2); m = max(180-10*t,0); M = 120+m; dy = [v ((5000+10*v)*(t<=18)-0.1*v*abs(v))/M - 9.81]; 0 5 10 15 20 25 30 35 40 0 500 1000 1500 2000 2500 3000 t h
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Numerical Analysis, lecture 1: Introduction
• Course info
• What is numerical analysis? (textbook §1.1-2)
function example2[t,Y] = ode45(@rocket,[0 40],[0 0]);plot(t,Y(:,1),'linewidth',3)xlabel('t'), ylabel('h','rot',0), box off function dy = rocket(t,y)v = y(2); m = max(180-10*t,0);M = 120+m;dy = [v ((5000+10*v)*(t<=18)-0.1*v*abs(v))/M - 9.81];
0 5 10 15 20 25 30 35 400
500
1000
1500
2000
2500
3000
t
h
Numerical Analysis, lecture 1, slide ! 2
Operational info for course MAT-31102/31107
Lecturer
Lectures (in Finnish)
Textbook (read it!)
Tutorials
Bring your laptop with Matlab or Octave to the tutorials
Lars Eldén, Linde Wittmeyer-Koch, Hans Bruun Nielsen: Introduction to Numerical Computation, Analysis and Matlab Illustrations, Studentlitteratur, 2004.
Perehdytään tieteellisen ja teknillisen laskennan perusmenetelmien teoriaaan ja käyttöön. Theory and practical application of essential numerical methods for scientific and engineering problem solving.
Opettajat
luennoitsija/lecturer Robert Piché, assari/teaching assistant Jari Niemi
Lars Eldén, Linde Wittmeyer-Koch, Hans Bruun Nielsen: Introduction to Numerical Computation, Analysis and Matlab Illustrations, Studentlitteratur, 2004. [errata]
Pikakokeet / Quizzes
Harjoitustunnilla annetaan pikakokeet, josta saa bonuspisteitä. The weekly tutorial sessions include quizzes that give you bonus points.
Tentti / Exam
Tavallinen tai graafinen/ohjelmoitava laskin ja yksi A4 kaksipuolinen sivu käsinkirjoitetut muistiinpanot sallittu. MallikysymyksiäOrdinary or graphing/programmable calculator and one A4 two-sided page of handwritten notes allowed. Model exam
Numerical Analysis, lecture 1, slide !
Exercise sets & PC labs
4
theory problems
problems from the textbook
Matlab/Octave questions (bring your laptop!)
modelling problems
answers! (complete solutions are posted after one week)
Numerical Analysis, Exercises for lectures 1–2 [§1.1–2, 2.1–3]1 a. Determine the absolute error and the relative error of 106/39 as an approximation of
the natural logarithm base e.b. How many correct decimals does x̄ = 0.9951 have as an approximation of x =
0.9949? How many significant digits?c. Some books say that x̄ has t correct decimals if x̄ rounded to t decimals is equal
to x rounded to t decimals. By this definition, how many correct decimals doesx̄ = 0.9951 have as an approximation of x = 0.9949?
2 How accurately do we need to know π in order to compute√
π with 4 correct decimals?[textbook page 37 exercise E1]
3 Derive the error propagation formula ∆ff � α1
∆x1x1
+ α2∆x2x2
+ α3∆x3x3
for the functionf(x1, x2, x3) = xα1
1 xα22 xα3
3 . [page 38 exercise E3]
4 Reformulate or approximate the following Matlab/Octave expressions to avoid cancellationfor x � 0, and compute their values for the specified x value. [page 38 exercise E5]
a. exp(x)-exp(-x), x = 10−5
b. 1-cos(x), x = 10−5
c. 1/(sqrt(1+x^2)-sqrt(1-x^2)), x = 10−2
5 For any x0 > −1, the sequence recursively defined by the formula
xn+1 = 2n+1��
1 + 2−nxn − 1�
converges to ln(1 + x0 + 14x2
0). However, computing the sequence for x0 = 4 in Mat-lab/Octave gives completely incorrect results. Try it:
x=4; for n=1:100, x=2^(n+1)*(sqrt(1+x/2^n)-1); end; x
Explain the problem, and fix it.
6 A gas exerts a pressure of 0.892 atm (all decimals correct) in a 5.00 L container (all decimalscorrect) at 15± 1 degrees Celsius. How much gas is there? (Hint: look up the ideal gaslaw.)
7 The following code computes the zeros of the quadratic polynomial ax2 + bx + c using thewell-known formula:
d = sqrt(b^2-4*a*c);r1 = -(b-d)/(2*a);r2 = -(b+d)/(2*a);
Try it with the polynomial x2 − 109x + 1, which has 2 positive real zeros. Which zerois not computed accurately, and why? Try again, but with the last two lines replacedby:
Solution: We can determine the elements of the first column of the Romberg tablewith the trapezoidal rule for a corresponding step length. With the step length h = 1we need values of function f(x) = e−x2
at f(0) = f0 = 1.0000 and f(1) = f1 = 0.3679.Now
T1(1) = h
�f0
2+
f1
2
�= 1 ·
�1.0000
2+
0.3679
2
�= 0.68394
The recursive formula T (h) = 12T (2h)+h(f1 + f3 + f5 · · ·+ fm−1) presented on page 172
Solution: We can determine the elements of the first column of the Romberg tablewith the trapezoidal rule for a corresponding step length. With the step length h = 1we need values of function f(x) = e−x2
at f(0) = f0 = 1.0000 and f(1) = f1 = 0.3679.Now
T1(1) = h
�f0
2+
f1
2
�= 1 ·
�1.0000
2+
0.3679
2
�= 0.68394
The recursive formula T (h) = 12T (2h)+h(f1 + f3 + f5 · · ·+ fm−1) presented on page 172
• study the model questions beforehand!• closed-book quiz, one question per week• grading: zero or one• total bonus 0-6 points (exam is 30 points)
Numerical Analysis, lecture 1, slide !
What previous students say about this course
6
Luennoitsijalle palautetta: vaikka opiskelijat ovatkin huonoja nauramaan luennoilla, älä anna tämän hämätä sinua: heitit luennoilla hyvää läppää, jatka samaan malliin! Tämän takia ajattelin hiukan positiivisemmin "aikaista" kouluunlähtöä.
Harjoitukset tukivat hyvin luentoja ja asiat aukesi oikeastaan harkkojen myötä vasta kunnolla. Hyödyllinen kurssi, olisi kannattanut jo aikaisemmin käydä.
Opetus oli hyvää mutta aihe niin kuivaa että kurkku on vieläkin kipeänä
Ihan hyvä kokonaisuus. Enemmän laskuesimerkkejä luennoilla, jos mahdollista.
Tässä kurssissa oli mielestäni järjestelyt ja muut systeemit kohdallaan.
Palautettahan ei pitäisi antaa, enne kun näkee arvosanansa, että voi sitten sopivalla kitkeryydellä asennoitua tämän palautteen kirjottamiseen.
do y! have any questions?
Numerical Analysis, lecture 1, slide ! 7
Numerical simulations are important in engineering & natural sciences…
Numerical Analysis, lecture 1, slide ! 8
“The objective of numerical analysis is to construct and analyse methods to solve practical computational problems”
• computational problems
- 2 small examples
• NA topics
• issues
• history
Numerical Analysis, lecture 1, slide ! 9
a computational problem is solved in 4 stages
• collect data and formulate a mathematical model
get(x) x > 0? disp(x)
x = -(x+1)^2
• find an algorithm (method)
• compute
5
1
25
10= 20
0
efficiencyratio
00
• look at results
Numerical Analysis, lecture 1, slide ! 10
A small example: how high does a thrown ball go? (page 2)
Model & data
Algorithm
Computation & Result>> v0 = 25; >> g = 9.81; >> h = (v0^2)/2/g
h =
31.8552
12mv0
2 = mgh, g = 9.81m ! s"2 , v0 = 25m ! s"1
h = v02
2g
Numerical Analysis, lecture 1, slide ! 11
Another example:how high does a rocket go? (p. 2)
Model & data
Algorithm
Computation & Resultfunction example2[t,Y] = ode45(@rocket,[0 40],[0 0]);plot(t,Y(:,1)) function dy = rocket(t,y)v = y(2); m = (180-10*t)*(t<=18);M = 120+m;Mp =-10*(t<=18);T = 5000*(t<=18);d = 0.1*v*abs(v);dy = [ v (T-9.81*M-d-Mp*v)/M ];
Use an adaptive Runge-Kutta method to solve the ODE IVP
!v =T " Mg " d " !M v
M, !h = v, v(0) = 0, h(0) = 0
0 5 10 15 20 25 30 35 400
500
1000
1500
2000
2500
3000
t
h
fuel mass m = 180 !10t, thrust T = 5000 (0 " t " 18), rocket mass M = 120 + m, drag d = 0.1v v , Newton's law (Mv #) = T ! Mg ! d
Numerical Analysis, lecture 1, slide ! 12
This course will introduce most of the main topics of numerical analysis