You are on page 1of 6

MATH 2070U

Midterm examination

Page 3 of 8

1. Assume the variables A, B, C, and D have been dened in a M ATLAB session as follows. A = [0,1;1,-3] C = [-1,3;1,-2;-3,4] B = [4,-3;-5,4] D = [1,-4,5;-1,5,-3] With these values, what results do the following M ATLAB commands produce. If the statement fails to evaluate, write ERROR with a short comment explaining why. (a) [3 marks] 2 * A ./ B .^2

(a) (b) [3 marks] D * C(:,2) + 1

(b)

MATH 2070U

Midterm examination

Page 4 of 8

2. For each task that follows, provide a few lines of M ATLAB code to illustrate how you would use M ATLAB in an interactive session to produce the desired result. Write your nal answer in the boxes below; use the back side for scratch work. (a) [21/2 marks] Generate a plot of the function f dened by f ( x ) = x3 ln( x ) over the range 1 x 4.

(b) [21/2 marks] Find a solution of the nonlinear equation

1 2

1 = et/3 cos(2t) near t = 4 .

(c) [21/2 marks] Determine a solution {x} = [ x1 , x2 , x3 , x4 ] T of the linear system of equations

9x1 + x2 + 8x3 + 10x4 7x1 + 8x2 x3 7x1 + 2x2 + 2x3 6x4 10x1 6x2 5x3 + 3x4

= 3, = 5, = 8, = 3.

(d) [21/2 marks] Compute the sum of the reciprocals of all the positive odd integers from 1 to 1000, i.e., 1 1 1 1 1 + + ++ + . 1 3 5 997 999

MATH 2070U

Midterm examination

Page 5 of 8

3. [4 marks] Consider the nonlinear equation 3x3 = x 1. ( )

Starting from the initial iterate x0 = 1, use Newtons method to nd the next two iterates x1 and x2 approximating a solution of the equation ( ). Write your nal answer in the boxes and show your calculations in the space below (use the back side for scratch work and extra space). x1 =

-0.87500

x2 =

-0.85212

MATH 2070U

Midterm examination

Page 6 of 8

4. [4 marks] Let the matrix [ A] be given by 4 6 3 [ A ] = 8 3 3 . 1 7 8 Compute the LU factorisation [ A] = [ L][U ] where [ L] is unit lower triangular, and [U ] is upper triangular. Do not use pivoting, i.e., do not interchange rows. Write your nal answer in the boxes and show your calculations in the space below (use the back side for extra space).

[ L] =

[U ] =

MATH 2070U

Midterm examination

Page 7 of 8

5. Consider the following M ATLAB code segment. f = @(x) sin(x) deltax = 0.1 x0 = 1.0 f0 = f(x0) df0 = ( f(x0+deltax) - f0 )/deltax (a) [1/2 mark] What is the value stored in f0 after executing this code?

(a) (b) [1 mark] What is the value stored in df0 after executing this code?

(b) (c) [1 mark] The value df0 is a nite-difference approximation of the true value of f ( x0 ), the derivative of the function f as dened above evaluated at x0 = 1. Assuming your calculator evaluates trigonometric functions exactly, what is the true value of f ( x0 )?

(c) (d) [1/2 mark] Based on your computations in parts (b) and (c), how well does df0 approximate f ( x0 ), i.e., what is the absolute value of the error | Et | associated with this approximation?

(d)

MATH 2070U

Midterm examination

Page 8 of 8

6. Identify the answer that best applies in the blank provided. Choose only one answer in each case; if more than one is written in the blank, the least accurate answer will be graded. (a) [1/2 mark] In M ATLAB, the number 6.2e-7 represents (A) (6.2 e) 7 (where e 2.718281828) (B) 6.2 e7 (where e 2.718281828) (C) 6.2 107 (D) 6.2 (e 7) (where e 2.718281828) [1/2

(a) (b) mark] The matrix 2000 2000 [ A] is known to be tridiagonal. Assuming a sparse storage format is used, the nonzero entries of [ A] can be stored using (A) 4000000 oating-point numbers; (B) 6000 oating-point numbers; (C) 5998 oating-point numbers; or (D) 4998 oating-point numbers.

(b) 1 mark] The sum 1000 1/k3 can be computed in (at least) two ways: (c) [ /2 k =1 1 1 1 1 1 1 1 1 + 3 +... + and S2 = + +... 3 + 3. 13 2 9993 10003 10003 9993 2 1 Assuming a single-precision oating-point arithmetic is used: (A) S1 is more accurate (B) S2 is more accurate (C) S1 and S2 are identical S1 =

(c) (d) [1/2 mark] Solving a linear system of equations [ A]{x} = {b} when the coefcient matrix has known LU factorisation [ A] = [ L][U ] is equivalent to the following procedure: (A) solving [ L]{y} = {b} for {y}, then [U ]{x} = {y} for {x} (B) solving [U ]{y} = {b} for {y}, then [ L]{x} = {y} for {x} (C) solving [ L]{b} = {y} for {y}, then [U ]{y} = {x} for {x} (D) solving [U ]{b} = {y} for {y}, then [ L]{y} = {x} for {x} (d) (e) [1/2 mark] (16.4)8 in base 10 is (A) (16.4)10 (B) (14.5)10 (C) (14.4)10 (D) (16.5)10 (e)
(0) (0)

(f) [1/2 mark] Assuming the initial bracket [ x , xu ] = [3/4, 7/8] surrounds a zero of the function g( x ) = 2x3 + x 2, three steps of interval bisection yields a bracket of width 1 (A) 128 1 (B) 64 1 (C) 32 1 (D) 16

(f)

You might also like