Vous êtes sur la page 1sur 2

Numerical Analysis I.

Tutorial and Laboratory 1

1. TUTORIAL PROBLEMS

1. Let |h| < 1. Which of the following functions are O(h)? Explain why.
(a) 2h, (b) −4h, (c) h+h2 , (d) −3h+h3 , (e) |h|1/2 , (f) |h|1/2 +h3 , (g) h+sin h,
(h) h + cos h.

2. Suppose that 0 < q < p and that αn = α + O(n−p ). Show that


αn = α + O(n−q ) (n denotes a positive integer).

3. Suppose that 0 < q < p and that F (h) = L + O(hp ) when h → 0


(h > 0). Show that F (h) = L + O(hq ).

4. Suppose that as x > 0 approaches zero,

F1 (x) = L1 + O(xα ), F2 (x) = L2 + O(xβ ).

Let c1 and c2 be constants, and define

F (x) = c1 F1 (x) + c2 F2 (x), G(x) = F1 (c1 x) + F2 (c2 x).

Show that if γ = min(α, β), then as x approaches zero


(a) F (x) = c1 L1 + c2 L2 + O(xγ ).
(b) G(x) = L1 + L2 + O(xγ ).

5. Find the rates of convergence of the following sequences as n → ∞.


1 1
(a) lim sin = 0, (b) lim sin = 0,
n→∞ n n→∞ n2
 1 2
(c) lim sin = 0, (d) lim [ln(n + 1) − ln n] = 0.
n→∞ n n→∞

6. Find the rates of convergence of the following functions as h → 0.


sin h 1 − cos h
(a) lim = 1, (b) lim = 0,
h→0 h h→0 h
sin h − h cos h 1 − eh
(c) lim = 0, (d) lim = −1.
h→0 h h→0 h

2. MATLAB PROGRAMMING

The purpose of this part is to warm up basic Matlab programming.


The Fibonacci sequence is defined as

F0 = 1, F1 = 1, Fk+2 = Fk+1 + Fk , k ≥ 1.

1
The following Matlab function produces the first n Fibonacci numbers
function f=fibonacci(n) % Fibonacci sequence
% f=fibonacci(n) generates the first n Fibonacci numbers
f=zeros(n,1); % assign an n-by-1 zero vector to f
f(1)=1;
f(2)=1;
for k=3:n
f(k)=f(k-1)+f(k-2);
end;

Task 1. Make a file called fibonacci.m and store this code in that file.
Then call the function
f=fibonacci(20)
to print the first 20 Fibonacci numbers.
Task 2. Modify the code to compute the ratio Fk+1 /Fk and print this
ratio on the screen for k = 3, 4, . . . , n. Note that

Fk+1 1+ 5
lim = .
k→∞ Fk 2
Task 3. (Do if you have time) Modify the code to compute the first n
Fibonacci numbers using the while loop instead.

Vous aimerez peut-être aussi