You are on page 1of 5

ECE 204 Numerical Methods for Computer Engineers

ECE 204
Numerical Methods for Computer Engineers
MIDTERM EXAMINATION
2007-10-23/8:00-9:30

The examination is out of 67 marks.

Instructions:
No aides.
Write your name and student ID number on each booklet.
Turn off all electronic media and store them under your desk.
Write all your answers in your booklets.
Answer the questions order in which they appear on the examination. If you need
to write your answer to a question elsewhere as a result of space considerations,
please indicate where the answer may be found.
You may ask only two questions during the examination:

1. May I go to the washroom?


2. May I have another booklet?

At the end of the exam, place this exam paper and any additional booklets into the
first booklet.
Do not leave during the first 30 minutes of the examination.
Do not leave during the last 15 minutes of the examination.
Do not stand up until all exams have been picked up.
You must stop writing when you are told that the examination is finished. No
exceptions, not even fo r your name. (-5 mark penalty. )
Attention:
The questions are in the order of the course material, not in order of
difficulty.

I have read and understood all of these instructions and accept a 0 if I fail to follow them:

Name: _________________________________________________

Signature: ______________________________________________

0 0000 8 1000
1 0001 9 1001
2 0010 A 1010
3 0011 B 1011
4 0100 C 1100
5 0101 D 1101
6 0110 E 1110
7 0111 F 1111

Page 1 of 5
ECE 204 Numerical Methods for Computer Engineers

Error Analysis and Numeric Representation

1. [3] Write the three numbers


52345
2.5455
0.0007821499999
using our decimal-digit floating-point representation of real numbers using the
appropriate rounding where the representation of +1 is 0491000 and 1 is 1491000.

2. [3] Write the number 51310 as a double-precision floating-point number using


hexadecimal numbers. Recall that the double-precision floating-point representation of 1
is 3FF0000000000000.

3. [4] Add the following to double-precision floating-point numbers, giving your answer
in the same format:
401 3A00000000000
3FD B100000000000
(Hint: just convert to the appropriate binary, dont try to convert to decimal.)

Linear Algebra

5. [7] Find the three matrices PT , L, and U of the PLU-decomposition of the matrix

0.9 7.5 3.8 1



1.8 4.2 9 3.4
M =
9 5 2 0

2.7 2.5 2.8 7.3

6. [4] Use the PT , L, and U decomposition of the matrix M to solve the system Mx = b
where:
0 1 0 1 0 0 3 0 5 6

P = 0 0
T
1 , L = 0 1 0 , U = 0 2 0 , b = 2
1 0 0 0 0.5 1 0 4 4
0

7. [3] Suppose a matrix M is symmetric, diagonally dominant, and has positive entries on
the diagonal. Calculating the 1-norm of the matrix is an O(n2 ) operation. Come up with
an O(n) operation which uses the given properties to find an upper bound on the 1-norm
of M. (An upper bound is a value which is guaranteed to be equal to or larger than the
required value, in this case, the 1-norm of M.)

Bonus [2]: give a single Matlab statement which returns your value.

Page 2 of 5
ECE 204 Numerical Methods for Computer Engineers

8. [3] Use Matlab commands and operators to create a symmetric matrix R which has
random entries between 0 and 2. Then, assuming all the diagonal entries of R are non-
zero, use this matrix R to create a diagonally-dominant matrix D by adding the sum of
each row (including the diagonal) onto the diagonal entry of that row.

8 4 8

9. [4] What are the 1 and infinity norms of the matrix M = 2 10 5 ?
0 9
3

10. [4] For applying one step of the Jacobi method to solve the system Mx = b given an
initial approximation vector x 0 , which of the following is more efficient, and explain
why. Full marks are awarded for using Landau symbols (big- O).

>> D = diag(diag(M));
>> Moff = M D;
>> Dinv = D^-1;
>> x = Dinv * (b Moff*x0);

>> d = diag(M);
>> Moff = M diag(d);
>> dinv = d.^-1;
>> x = dinv .* (b Moff*x0);

Interpolation

11. [2] Write down the Vandermonde matrix which is used to find the interpolating
polynomial through the points (0, 0.5), (1, 2.3), (2, 5.4), and (3, 4.7).

12. [4] Suppose that the Vandermonde matrix you found in the previous question is
assigned to the variable V and y = [0.5 2.3 5.4 4.7]. Write down the Matlab
code which would solve the system of linear equations (by the easiest means possible)
and (without actually solving the system of linear equations) associate the entries of the
solution vector with the coefficients of the appropriate basis functions x 3 , x 2 , x, and 1.

13. [3] Write a polynomial in x which passes through the (x, y)-point (5.1, 7.2) and is zero
at the x-values 3.8, 6.1, 8.9, and 10.5.

Page 3 of 5
ECE 204 Numerical Methods for Computer Engineers

14. [4] The Newton polynomial which passes through the points (1, -1), (3, 11), (4, 5),
and (6, -1) is found by calculating the following divided difference table:

1 -1
6
3 11 -4
-6 1
4 5 1
-3
6 -1

Show how we can use this to find the Newton polynomial which passes through the
points (3, 11), (4, 5), (6, -1), (8, 1) in linear time (and write down the Newton
polynomial).

15. [4] Given the initial Matlab code


>> x = [1 3 4 6];
>> c = [-1 6 -4 1];
>> x0 = 9;
>> y0 = c(4);
write a for-loop which evaluates the Newton polynomial which passes through the points
(1, -1), (3, 11), (4, 5), and (6, -1) (given in the previous question) using Horners rule at
the point x 0 = 9 and assigns the result to y0 .

Least Squares Regression

16. [3] Write down the matrix V which is used to find the best- fitting straight line passing
through the points (2, 0.1), (1, 0.2), (0, 0.5), (1, 1.1), (2, 1.9).

17. [2] Suppose you were given data points (x 1 , y1 ), ..., (x n , yn ) which either came from a
system of the form aebx or axb where a, b > 0, what would you look for to determine
which model to use. Short answers, but you may uses diagrams to support your answer.

18. [4] Describe how you could find a best fitting curve to data which is know to be of
the form y(x) = ax b ecx. You may either describe it mathematically or use Matlab code.

Page 4 of 5
ECE 204 Numerical Methods for Computer Engineers

19. [3] The following points come from data which follows the curve described in the
previous question. What would yo u suspect are the signs (positive or negative) of the
three coefficients a, b, and c?

Matlab

20. [3] What does the following function estimate?

function a = h( M )
B = M*M;
c = random( length( M ), 1 );
d = norm(c);

for e = 1:100
f = B * (c/d);
g = norm( f );

if ( abs( d - g ) < 1e-10 )


a = sqrt( g );
break;
end

c = f;
d = g;
end

error( 'the system did not converge' );


end

Some Matlab commands:

random ones zeros


sum mean product max
diag
det norm cond eig trace

Page 5 of 5

You might also like