Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
Summary 2 1 exam, 1project and some exercises
Target 3 Solve problems with numerical methods
In this slide Why numerical methods? –differences between human and computer –a very simple numerical method What is algorithm? –definition and components –three problems and three algorithms Convergence –compare rate of convergence 4
Why such methods? 5 Computer is stupid
x-2=0 6 Human says, x=2, easy!
{ x-2=0; } 7 Computer says, compilation error!
What is the difference? 8
9 Human is logical (thinking)
10 Can do inference
11 Computer is procedural (executing)
An example (((x+3)-2)+6)=0 –Human requires only the rules (in this case, arithmetic), –and can inference the steps for the solution 12
Computer (((x+3)-2)+6)=0 –Requires the exact procedure (steps) { x0=0–6; } { x1=x0+2; } { x=x1–3; } –These steps is numerical method 13
14 Does computer have any advantage?
15 It is fast
So, why numerical methods? Computer is stupid Computer is fast (and works hard) Sometimes, stupid methods can solve difficult problems 16
17
18
19
We know that 20
21 rubbish =.=
A systematic procedure 22
23 Bisection method
Bisection method 24
And very accurate 25 Actually, it is getting accurate after every trial
26 Computer works hard, so it could happen
Any Questions? 27
Algorithm 28 The heart of numerical analysis
Algorithm Definition –A precisely defined sequence of steps In this course –design; –implement; and –examine the performance 29
30 How to implement?
By hand 31 too painful (but you might need to)
With computer 32 in other words, do programming
Programming 33 Even scared!
34 Algorithm could be simple
An example from statistics 35
36
In action 37
38
It is also an algorithm 39 (a precisely defined sequence of steps)
Not 40 A difficult sequence of steps
Any Questions? 41
Another example 42 Definite integral using trapezoidal rule
43
44
45
In action 46
47
Error 48
49
Observations of the errors 50
Any Questions? 51
The third example 52
53
Stopping condition 54
In action 55
56
So far 57 a statistics problem, the integral problem, and the square root problem
Any Questions? 58
59 What is the differences among them? (hint: the concepts of the output)
Type of methods The statistics algorithm –generates an exact (analytic) solution The integral algorithm –generates an approximate (numerical) solution –many numerical methods work in much the same way The square root algorithm –generates a sequence of approximations which converge to the solution –another typical class of numerical methods 60
Poll 61 Programming ability
Learnt 62 C/C++ (??/24) Java (??/24) Other (??/24)
Learnt 63 Data structure (??/24) Algorithm (??/24)
Language vs. algorithm Two languages –The same concept, different patterns –e.g., Chinese and English –, feel sleepy English vs. C –Increase i by 1 –{ ++i; } Language is/defines the pattern Algorithm is/describes the concept 64
Pseudo-code 65 Not any real programming language
A pseudo-code example 66
Can You 67 Read/write pseudo-code?
Convergence 68 When several numerical methods are available, choose the fastest one
69
Rate of convergence 70
71
72
73
74
Any Questions? 75
Which Is Better? 76
Using L'Hôpital's rule ( ) 77
78
Rate of Convergence 79 There is another definition for function
Another definition of rate of convergence for function 80
81
Rate of convergence 82
Order of Convergence A different measure of convergence speed than rate of convergence Examines the relationship between successive error values 83
Order of Convergence Iterative Method 84
85 Note the dramatic difference between 1 and 2, and the slight difference between 2 and 3
86