Csc349a f2023 Asn3
Csc349a f2023 Asn3
ASSIGNMENT #3 - 20 MARKS
This is a really large class and the logistics of grading assignments are challenging. Me
and the markers require your help in making this process go smoothly. Please ensure that
your assignments conform to the following requirements - any violation will result in getting
a zero for the particular assignment.
The answers to the questions should be in the same order as in the assignment speci-
fication.
Some of the questions of the assignments are recycled from previous years but typically
with small changes in either the description or the numbers. Any submission that
contains numbers from previous years in any questions will be immediately graded
with zero.
Any general assignment related questions can be posted in the Discussion Forum in
Brightspace for the assignment.
Any specific assignment related questions (details about your solution) should be e-
mailed ([email protected]) to me and have a subject line of the form CSC349A Assignment
X, where X is the number of the corresponding assignment.
1
Question #1 - 8 marks.
(a) (3
√ points) Determine the second order (n = 2) Taylor series expansion for f (x) =
x + 1 expanded about a = 3 including the remainder term. Leave your answer in
terms of factors (x − 3) (that is, do not simplify). Show all your work.
(c) (2 points) Determine a good√upper bound for the truncation error of the Taylor
polynomial approximation for 4.08 in (b) by bounding the remainder term in (a).
Give an exact answer. Note: Here x = 3.08 only. The actual absolute error in (b)
should be less than this upper bound.
(d) (1 point) Plot a graph containing f (x) and the polynomial approximation from (a)
over the interval [0, 6], with a step size of 0.02. Include a legend in your plot, denoting
the colour of each of the two curves. You need to include the commands and plot
results in your submitted pdf.
To plot in MATLAB you can use:
>> x = [0:0.02:6];
>> y = function_name(x);
>> plot(x,y)
Question #2 - 6 marks.
Consider the function
ln(x)
g(x) =
x
for x > 0, which is ill-conditioned for values of x close to 1. In parts (a) and (b) below you
will show this by two different methods using x = 1.003.
xg ′ (x)
(a) (3 points) Consider the condition number g(x)
evaluated at x = 1.003 and make a
conclusion about the condition.
2
(b) (3 points) Consider a small perturbation of x = 1.003, namely x̂ = 1.004. Calculate
g(x) and g(x̂) and compare the relative change in x, namely x−x̂
x
, with the relative
change in g(x), namely g(x)−g(x̂)
g(x)
. Report your conclusion based on the definition of
condition, given your calculations here.
Question #3 - 6 Marks
– print a caption for your computed approximations by inserting the following state-
ment just before the while statement:
MATLAB
fprintf( ’ iteration approximation \n’)
Python
print( ’ iteration approximation \n’)
– print each successive computed approximation by inserting the following state-
ment after the computation of xr at the beginning of the while loop:
MATLAB
fprintf( ’ %6.0f %18.8f \n’, i, xr )
Python
print(’{:6.0f} {:18.8f}\n’.format(i,xr))
– print a message to indicate that the algorithm has failed to converge in imax steps
by replacing the last statement in the pseudocode by the following:
MATLAB
fprintf( ’ failed to converge in %g iterations\n’, imax )
Python
print( ’ failed to converge in ’,imax,’ iterations\n’)
Use the function Bisect() to solve the following two problems (parts (b) and (c)). In
each case, you will need to write another function file with header
3
function y = f(x)
(b) (2 points) Use Bisect to solve the following problem, you are designing a spherical
tank to hold water for a small village in a developing country. The volume that it
holds can be computed as
3R − h
V = πh2
3
3
where V is the volume in m , h is the depth of the water in the tank in meters, and R
is the tank radius in meters. If R = 4.1, determine the depth h that the tank must be
filled to in order that the tank holds 45 m3 of water. In Bisect, use an initial interval
of [0, 4.1], eps = 10−4 and imax = 20 (as was done in Handout 8). In MATLAB, 10−4
can be written as 1e-4.
(c) (2 points) Use Bisect to solve the following problem, The velocity v of a falling
parachutist of mass m kg is given by
gm
v= (1 − e−ct/m )
c
, where g = 9.81 meters per second squared. For a parachutist with drag coefficient
c = 13.5 kg/s, compute the mass m so that the velocity is v = 40 meters per second at
time t = 10 seconds. In Bisect, use an initial interval of [1, 100], eps = 10−4 and imax
= 20.