0% found this document useful (0 votes)
40 views

Csc349a f2023 Asn3

This document provides the assignment specifications for Computer Science 349A, Fall 2023 Assignment #3. It outlines: - The due date and point value of the assignment - Requirements for electronic submission through Brightspace and Crowdmark - Instructions to not copy the assignment description and to answer questions in order - Warnings that previous year's solutions will receive zero points - Instructions to post general questions to the discussion forum and email specific questions It then provides 3 questions worth 12 marks total, involving Taylor series approximations, condition numbers, and using the bisection method to solve equations.

Uploaded by

milesktickner
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Csc349a f2023 Asn3

This document provides the assignment specifications for Computer Science 349A, Fall 2023 Assignment #3. It outlines: - The due date and point value of the assignment - Requirements for electronic submission through Brightspace and Crowdmark - Instructions to not copy the assignment description and to answer questions in order - Warnings that previous year's solutions will receive zero points - Instructions to post general questions to the discussion forum and email specific questions It then provides 3 questions worth 12 marks total, involving Taylor series approximations, condition numbers, and using the bisection method to solve equations.

Uploaded by

milesktickner
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

COMPUTER SCIENCE 349A, FALL 2023

ASSIGNMENT #3 - 20 MARKS

DUE WEDNESDAY OCTOBER 25, 2023 (11:30 p.m. PST)

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.

ˆ All assignments should be submitted electronically through the Brightspace course


website using the Crowdmark tool. Each question will be submitted separately in
Crowdmark. You may be asked to provide files for any functions (.m or .py). No other
formats will be accepted.

ˆ PLEASE DO NOT COPY THE ASSIGNMENT DESCRIPTION IN YOUR


SUBMISSION

ˆ 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.

(b) (2 point) Use the polynomial


√ approximation in (a) (without the remainder term)
to approximate f (3.08)
√ = 4.08. To 9 correct significant digits, calculate the exact
value of f (3.08) = 4.08 and use it to compute the absolute error of your computed
approximation.

(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)

In Python you can use:

>> import numpy as np


>> import matplotlib.pyplot as plt
>> x = np.arange(0.0,6.0,0.02)
>> y = function_name(x)
>> plt.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

(a) (2 points) Write a MATLAB or Python function

Bisect ( xl , xu , eps , imax, f )

that returns an approximation to a root of function f , in interval [xl , xu ], corresponding


to the pseudocode given in Handout #8 for the Bisection method (in xl it is an “ell”
not a “one”).
The only differences from that given algorithm are the following:

– 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)

corresponding to the function of which you are computing a zero.

(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.

You might also like