151lecture2 12 14
151lecture2 12 14
Main routine
Constants
Global
variables
Subroutine 1
Operations
Subroutine 2
Subroutine 3
Outputs
Chemical Engineering Department
Rates of Convergence
If we have a sequence of numbers 1, 2, . . .
that converges to some number , we say it
converges with O(1/n) if:
K
1
n n1 is O n n large
n
n
We can say a similar thing for a function that
converges to L as h goes to zero:
f h is O h
f h L Kh
as h 0
x
x
x
sin x x sin x
3! 5! 6!
Converges with O(h) in the limit as h
approaches zero. Give EXPLICIT values for L
and K, not a range of values. Work in groups
of two and raise your hand if youre stuck.
Chemical Engineering Department
f h sin h , 1
3
h h h
h h h
sin h h sin h h
3! 5! 6!
3! 5! 6!
3
5
6
h h h
lim sin h lim h h
h 0
h 0
3! 5! 6!
h3 h5 h 6
lim sin h L lim h 0 h
h 0
h 0
3! 5! 6!
sin h is O h
...
K 1,
L 0
Programming Languages
What are some programming languages you
have used?
What are examples of what they are used for?
What is the difference between languages?
What is a subroutine?
What is a special-purpose algorithm?
What is a general-purpose algorithm?
For more info: Sources and Development of
Mathematical Software by Cowell (see text)
Chemical Engineering Department
f
f
2
1
0.5Re
3.2 227
2500
ln
0.5Re 0.436 2
f
0.5Re
f
f
1
0.5 Re
f x 3.2 227
2500
ln
0.5 Re 0.436 2
0.5 Re
Whats x?
Whats f? Whats the other f?
Why did I rearrange it into this form?
Chemical Engineering Department
2
f
f C a, b , K : f a K f b
c a, b : f c K
For K = 0 and c = p:
if :
then :
f C a, b , f a 0, and f b 0,
p a, b exists such that f p 0
f
f
1
0.5 Re
f x 3.2 227
2500
ln
0.5 Re 0.436 2
0.5 Re
2
f
x 2 f :
227
f x 3.2
ln 0.5 Re
1 x
0.436
0.5 Re
2500 2 1
2
ln
x
x
3 ln x 0
0
1
2
2
0.25 Re
0.436
Bisection in Pseudocode
Set TOL
Set a
Set b
While (a - b) > TOL
Find f(a)
Find f(b)
If (f(a)*f(b) < 0 )
p = (a + b)/2;
Find f(p)
If ( f(a)*f(p) < 0)
Set b =p
Else
Set a = p
End while