CS计算机代考程序代写 matlab algorithm CS-SE-4X03

CS-SE-4X03

CS/SE Eng 4X03

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.

Page 3 of 11

CS/SE Eng 4X03

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 ?

Page 4 of 11

CS/SE Eng 4X03

Problem 3 [4 points] Suppose cosx is approximated by an interpolating polynomial of degree n using (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.

Page 5 of 11

CS/SE Eng 4X03

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.

Page 6 of 11

CS/SE Eng 4X03

Problem 5 [5 points]

Suppose that r is a double root of f (x), f 2 R ! R. That is f (r) = f 0(r) = 0 and f 00(r) 6= 0. For example
f (x) = (x�2)2 has a double root x = 2.
Suppose f , f 0, f 00 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 ⇡
1
2

en

Page 7 of 11

CS/SE Eng 4X03

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.

Page 8 of 11

CS/SE Eng 4X03

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

2

4
1 0 0
2 3 0
4 5 6

3

5

(b) (2 points) Derive a formula for the number of arithmetic operations to solve this system.

Page 9 of 11

CS/SE Eng 4X03

Problem 8 [5 points]

Consider the ODE y0 =�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.

Page 10 of 11

CS/SE Eng 4X03

Problem 9 [3 points]

What is the smallest number of points that are needed to compute
R 1

0 e
x dx with accuracy 10�8 using Simpson’s

composite rule with equally spaced points.

THE END. Page 11 of 11