CS/SE 4X03 Final Examination
DAY CLASS
DURATION OF EXAMINATION: 2 hours MCMASTER UNIVERSITY FINAL EXAMINATION
Special Instructions:
1. You must not communicate with anybody during this exam.
2. You must not use the Internet.
3. You can use Matlab or a calculator.
4. Textbooks are allowed.
5. Write your solutions in the space provided in this PDF.
Dr. N. Nedialkov 26 April, 2021, 19:30-21:30
6. If you cannot print it, write on blank paper. Sign the next page electronically and you must submit it.
7. If you prefer to type your solutions, type them in a separate document using your favourite tool (e.g. LaTeX, Word). When submitting, make sure you include the next page of this document.
8. Submit your PDF to Avenue by 21:45.
9. If you have a SAS accommodation, there will be a separate folder. Submit within the time indicated in your SAS letter + 15min.
10. I will not accept exams submitted by email.
COURSE: CS/SE4X03
EXAM DATE: 26 April 2021
McMaster University Statement on Academic Integrity:
You are expected to exhibit honesty and use ethical behaviour in all aspects of the learning process. Academic credentials you earn are rooted in principles of honesty and academic integrity.
Academic dishonesty is to knowingly act or fail to act in a way that results or could result in unearned academic credit or advantage. This behaviour can result in serious consequences, e.g. the grade of zero on an assignment, loss of credit with a notation on the transcript (notation reads: “Grade of F assigned for academic dishonesty”) and/or suspension of expulsion from the university.
“By signing this document I agree to follow the McMaster University Policy on Academic Integrity. My signature below confirms that the work submitted for this exam is my own and did not involve the use of unauthorized aids.”
STUDENT NAME: STUDENT ID: STUDENT SIGNATURE:
CS/SE Eng 4X03
Do Not Share this document
Problem 1 [5 points] Suppose you enter two numbers x and y from the keyboard on your computer, store them in double precision variables, and compute x*y*y. Assuming that this expression is evaluated in double precision, calculate a bound for the error in the computed result.
Do Not Share this document
Page 3 of 11
CS/SE Eng 4X03
Do Not Share this document
Problem 2 [4 points] For this problem, do not use a calculator or a computer. Consider f (x) = (e2x − 1)/(2x). Let x = 1e−10 and assume double precision.
(a) When evaluated in double precision, exp(2*x) is 1.000000000200000. Without using the exp function, how would you obtain this value?
(b) Describe an approach for computing f (x) = (e2x − 1)/(2x) such that loss of significance is avoided when x is near zero.
(c) Using your approach, what would you obtain with x = 1e−10 ?
Do Not Share this document
Page 4 of 11
CS/SE Eng 4X03
Do Not Share this document
Problem3[4points] Supposecosxisapproximatedbyaninterpolatingpolynomialofdegreenusing(n+1) equally spaced points in the interval [0, 1].
(a) How accurate is this approximation in terms of n.
(b) What is the minimum number of points needed to achieve error less than 10−6.
Do Not Share this document
Page 5 of 11
CS/SE Eng 4X03
Do Not Share this document
Problem 4 [3 points] Given an a > 0, you wish to compute a1/3, that is, the cubic root of a. You have available only the operations addition, subtraction, multiplication and division.
(a) (2 points) Describe how you can compute it.
(b) (1 points) Then compute 31/3 up to 4 accurate digits after the decimal point. Show all the steps in your calculation.
Do Not Share this document
Page 6 of 11
CS/SE Eng 4X03
Do Not Share this document
Problem 5 [5 points]
Suppose that r is a double root of f(x), f ∈R→R. That is f(r)= f′(r)=0 and f′′(r)̸=0. For example f(x) = (x−2)2 has a double root x = 2.
Suppose f , f ′, f ′′ are continuous in a neighborhood of r.
Assume that you apply Newton’s method to find this root of f . Denote en = r − xn and assume xn is near r. Show that
en+1 ≈ 21en
Do Not Share this document
Page 7 of 11
CS/SE Eng 4X03
Do Not Share this document
Problem 6 [3 points] You are given the data points xi 1 2 3
yi 2 3 5
Suppose we want to find the coefficients a and b in the function f (x) = ax + bex that fits these data in a least squares sense.
Describe how you would setup a least squares problem in Matlab and how you can compute these coefficients. You don’t have to compute them.
Do Not Share this document
Page 8 of 11
CS/SE Eng 4X03
Do Not Share this document
Problem 7 [4 points]
(a) (2 points) Let A be nonsingular, n × n lower-triangular matrix. Write an algorithm in pseudo-code for solving the system Ax = b, where b is an n column vector. For example, the following is a lower-triangular matrix
1 0 0 2 3 0 456
(b) (2 points) Derive a formula for the number of arithmetic operations to solve this system.
Do Not Share this document
Page 9 of 11
CS/SE Eng 4X03
Do Not Share this document
Problem 8 [5 points]
Consider the ODE y′ = −5y with y(0) = 1. Suppose you solve this ODE with constant stepsize h = 0.5. Provide sufficient detail when answering the following questions.
(a) Is the solution to this ODE stable?
(b) Is the forward Euler method stable for this ODE using this stepsize?
(c) Is the backward Euler method stable for this ODE using this stepsize?
(d) Compute the numerical value for the approximate solution at t = 0.5 by the forward Euler method. (e) Compute the numerical value for the approximate solution at t = 0.5 by the backward Euler method.
Do Not Share this document
Page 10 of 11
CS/SE Eng 4X03
Do Not Share this document
Problem 9 [3 points]
What is the smallest number of points that are needed to compute 01 ex dx with accuracy 10−8 using Simpson’s composite rule with equally spaced points.
Do Not Share this document
THE END. Page 11 of 11