COMPUTER SCIENCE 349A
ASSIGNMENT #2 – 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.
• All assignments should be submitted electronically through the ConneX course website
and shoud be SINGLE PDF FILES. No other formats will be accepted.. Handwritten answers are ok but they will need to be scanned and merged into a single pdf file
together with any code examples and associated plots.
• The assignment number, student name and student number should be clearly visible
on the top of every page of your assignment submission.
• PLEASE DO NOT COPY THE ASSIGNMENT DESCRIPTION IN YOUR
• The asnwers to the questions should be in the same order as in the assignment specification.
• 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
• Any assignment related email questions should have a subject line of the form CSC349A
Assignment X, where X is the number of the corresponding assignment.
• The total number of points for this assignment is 20.
Question #1 – 8 marks.
Consider a base 5 normalized, floating-point number system. Assume that a hypothetical
computer using this system has the following floating-point representation:
sm f1 f2 f3 f4 se e1 e2
where sm is the sign of the mantissa, se is the sign of the exponent (1 for negative, 0 for
positive), fi are the digits of the mantissa, and ej are the digits of the exponent.
(a) Consider the base 5 number, given using the above representation, 02003004. What
exact decicaml value does it represent?
(b) What decimal value does 11004003 represent?
(c) What is the smallest positive, non-zero, number that can be represented in this system?
Give the answer in the above form (i.e. as 8 base-5 digits.) and in decimal.
(d) What is the size of the gap between any two consecutive numbers in the interval 25(10)
and 125(10) in this floating-point representation system? Your answer should be in
Question #2 – 6 Marks.
The polynomial P(x) = x
2 − 83.12x + 3.123 has two roots, at approximately 0.0375892
and 83.0824. The roots of a quadratic polynomial ax2 + bx + c can be computed by
2 − 4ac
or equivalently (ii)
2 − 4ac
Using floating-point arithmetic, one of these formulas is often much more accurate than
the other. For example, if (−b +
2 − 4ac)/(2a) is used to compute one of the roots of
P(x) = x
2 − 83.12x + 3.123 = 0 with base b = 10 , precision k = 4, idealized chopping
arithmetic, the results are as follows:
) = fl(()6908.9344) = 6908 or 0.6908 × 104
fl(4a) = 4 or 0.4000 × 101
fl(4ac) = fl(4 × 3.123) = fl(12.492) = 12.49
2 − 4ac) = fl(()6908 − 12.49) = fl(()6895.51) = 6895
2 − 4ac) = fl(
6895) = fl(83.036136 · · ·) = 83.03
2 − 4ac) = fl(83.12 + 83.03) = fl(166.15) = 166.1
fl(2a) = 2
2 − 4ac
= 83.05 or 0.8305 × 102
which is very accurate. The relative error is about 0.00039 or 0.039%.
On the other hand, it can be shown (similar to the above) that
2 − 4ac
= 69.40 or 0.6940 × 102
which (using the exact value of 83.0824 · · ·) has a large relative error of 0.165 or 16.5%.
(a) Use base b = 10, precision k = 4, idealized chopping arithmetic and each of the
mathematically equivalent formulas
2 − 4ac
and −b −
2 − 4ac
to compute an approximation to one root of P(x) = 1.2x
2 − 78.99x + 1.234 = 0. As
above, specify each step of the computation. Note that many of the computations for
the two formulas are identical, and need only be done once. Use your calculator to do
this, not MATLAB.
(b) Compute the relative errors of each of the approximations in (a) using the fact that
the exact value of the root is 0.01562594 · · · . Give at least 2 significant digits.
(c) One of the two zeros of a quadratic polynomial ax2 + bx + c can be computed using
either the formula
2 − 4ac
2 − 4ac
For each of the specified polynomials in the table below, place an X in the appropriate
box to indicate which of these formulas is more accurate in precision k = 4 floatingpoint arithmetic. Put exactly one X in each row of the table. (No justification for
your answers is required. It is NOT necessary to do any floating-point computation to
answer this question.)
polynomial (i) is more accurate (ii) is more accurate
2 − 125x + 0.05
2 + 125x + 0.025
Question #3 – 6 Marks
(a) Determine the second order (n = 2) Taylor series expansion for f(x) = √
x + 3 expanded about a = 1 including the remainder term. Leave your answer in terms of
factors (x − 1) (that is, do not simplify). Show all your work.
(b) Use the polynomial approximation in (a) (without the remainder term) to approximate
f(1.12) = √
4.12. Use either hand computation, your calculator or MATLAB. Give an
(c) Determine a good upper bound for the truncation error of the Taylor polynomial
approximation in (a) for all values of x such that 1 ≤ x ≤ 1.2 by bounding the