You are on page 1of 2
MATH 20720 Midterm examination Page 2of 3 1. Consider the nonlinear equation This equation has a unique solution x" < [2,3] (2) [10 marks] Find x" with an error less than (.05 using bisection. For every iteration, list the left boundary, the right boundary and an upper bound for the error. (©) [10 marks] Starting from the initial guess x10) ~ 3, use Newton's method to find x" with a residual Jess than 10 *. For every iteration, list the approximation +, the step size |r; —x;| and the residual. (©) [5 marks} For each of the following statements, indicate if they are true or false: 1. Newton iteration converges to x" only when starting from one, unique, initial point in The fact that the equation has a unique solution in (2, 3) isa necessary condition for bisection to 3. Newton iteration takes fewer FLOPS than bisection to compute x" up to 15 significant digits when starting the former from x! — 3 and the latter from 2,3) 4 If you start Newton iteration from some initial point in [2,3], all iterates (Le. all consecutive approximate solstions) will be in 2.3 5. If bisection converges, the error is reduced by the same factor in cach iteration. [10 marks} Let the matrix A be given by Compute the factorisation PA = LU using partial pivoting, where P is a permutation matrix, L is unit Iower triangular. and LI is upper triangular. Write down the matrices P, Land LJ at all intermediate steps 3. Consider the following linear s [12 30 10 [$2000 Ax=b, where A=|—29 59 —20] and b= |—11.800! ea] ~ [aa] Using a numerical method, you find the approximate solution to be [.0999603ss | —1.990068351 | =1.0000182 | (a) (10 marks} Whatis the maximal relative error of your approximate solution? (©) [Smarks] Assuming that you know the matrix entries exactly, Bt you know only five digits of the MATH 20720, Midterm examination Page 3 of 3 4. A special property of lower triangular, square matrices is that the product of two lower triangular matrices is also lower triangular. To be precise, if Aj; = 0 for j > iand By = 0 for j > ithanC = AB satisfies Cy = 0 for j >i (@) [15marks] Write a pseudo-code for a function that computes the product of two lower triangular matrices. Initialize the product as a zero matrix and compute only the elements on and below the diagonal (b) [15 marks] Compute the number of FLOPS it takes to: complete the function on part (a) asa func- tion of the number of rows 1 of the input matrices. (©) [10 marks] Implement the pseudo-code of part (a) in a function called triangular_prod py. It should take as input two # x m arrays with zeros above their diagonal and output their matrix product as an n x m array with zeros above its diagonal. (d) (10 marks] Write a script test prod py that 1. generates two random lower triangular matrices for some 1 > 1, 2. uses the function of part (c) to find their product and 3. verifies the result by comparing it to the output of scipy:matmul or scipy.dot. (©) [0 marks (bonus)] Your function for triangular matrix-matrix multiplication can be at most 6 times faster than regular matrix-matrix multiplication (asymptotically for large n). Is your code 6 times faster? Then the 10 bonus marks are yours. If not, find a way to make your function more efficient until itis 6 times faster. You can either compare the number of FLOPs in your code to that in regular matrix-matrix multiplication or demonstrate the difference in speed by measuring the wall time of both.

You might also like