Docsity

Computational Methods Mid Term Exam: CMSC/AMSC/MAPL 460 - Prof. Ramani Duraiswami, Exams of Computer Science

Toggle sidebar
bg1
Mid Term exam: CMSC/AMSC/MAPL 460 Computational Methods 03/15/2007
1. Write down true or false: (2 points/ each)
a. Solving a least-squares problem via the normal equations rather than the QR
decomposition leads to a better conditioned algorithm False
b. The matrix that results on rearranging the rows of an identity matrix is called a
permutation matrix. True
c. The spacing between floating point numbers is uniform False
2. Write brief descriptions of the following. In each case provide any pertinent details such as
formulae, but be brief:
a. Why is solving a system of equations by computing the inverse and then multiplying
it by the right hand side usually a bad idea? (4 points)
Costlier, and more prone to error.
b. A cubic spline requires four pieces of information over every piece over which the
function is approximated. Write down what these are for i) an internal section and, ii) an
end section for the natural cubic spline (6 points)
i) value at the two endpoints, continuity of 1st and 2nd derivatives at end points
ii) value at the two endpoints, continuity of 1st and 2nd derivatives at interior point, and
specified 2nd derivative (=0) at end point
3. Assume you have a base 2 computer that stores floating point numbers using 10 bits, which are
divided into a sign bit, a 5 bit normalized mantissa (1.xxxxx), and a 4 bit exponent the 1st bit of
which is used for a sign. Assume that all numbers are chopped rather than rounded.
a) Draw a small representation of the numbers and what the values of each field can be. Give the
machine representation and a base 10 representation for machine epsilon, the smallest nonzero
positive number which, added to 1, gives a number different from 1. Also provide the largest
number that can be stored in this representation in decimal is represe nted
(20 points)
A representation could be as [s|eeee|fffff], or as (-1)s ×1.xxxxx×2(-1)xxx
s can take value 0 or 1 |
e can take value from -111 to 111 or (-7 to 7 in decimal)
f can take value from 00000 to 11111 (0 to ½+1/4+1/8+1/16+1/32
machine epsilon is 1/32 (or ½ that 0.03125 or 0.015625)
b) Which machine number is closest to π? (π=3.1415926535897…)
11.00100 =1.10010×2+1 = 2(1+1/2+1/16)=3.125 is the right answer
(5 points)
4. Consider the data points (xi,yi) given by (−3, 1), (−1,−1), (1, 1), (3,4). We wish to approximate
it using the parabola
y = a+bx+cx2
and must determine the coefficients a, b and c.
pf3

Partial preview of the text

Download Computational Methods Mid Term Exam: CMSC/AMSC/MAPL 460 - Prof. Ramani Duraiswami and more Exams Computer Science in PDF only on Docsity!

Mid Term exam: CMSC/AMSC/MAPL 460 Computational Methods 03/15/

  1. Write down true or false: (2 points/ each) a. Solving a least-squares problem via the normal equations rather than the QR decomposition leads to a better conditioned algorithm False b. The matrix that results on rearranging the rows of an identity matrix is called a permutation matrix. True c. The spacing between floating point numbers is uniform False
  2. Write brief descriptions of the following. In each case provide any pertinent details such as formulae, but be brief: a. Why is solving a system of equations by computing the inverse and then multiplying it by the right hand side usually a bad idea? (4 points) Costlier, and more prone to error. b. A cubic spline requires four pieces of information over every piece over which the function is approximated. Write down what these are for i) an internal section and, ii) an end section for the natural cubic spline (6 points) i) value at the two endpoints, continuity of 1st^ and 2 nd^ derivatives at end points ii) value at the two endpoints, continuity of 1st^ and 2 nd^ derivatives at interior point, and specified 2nd^ derivative (=0) at end point
  3. Assume you have a base 2 computer that stores floating point numbers using 10 bits, which are divided into a sign bit, a 5 bit normalized mantissa (1.xxxxx), and a 4 bit exponent the 1st^ bit of which is used for a sign. Assume that all numbers are chopped rather than rounded. a) Draw a small representation of the numbers and what the values of each field can be. Give the machine representation and a base 10 representation for machine epsilon, the smallest nonzero positive number which, added to 1, gives a number different from 1. Also provide the largest number that can be stored in this representation in decimal is represe nted (20 points)

A representation could be as [s|eeee|fffff], or as (-1) s^ ×1.xxxxx× 2 (-1)xxx

s can take value 0 or 1 | e can take value from -111 to 111 or (-7 to 7 in decimal) f can take value from 00000 to 11111 (0 to ½+1/4+1/8+1/16+1/ machine epsilon is 1/32 (or ½ that 0.03125 or 0.015625) b) Which machine number is closest to π? (π=3.1415926535897…) 11.00100 =1.10010× 2 +1^ = 2(1+1/2+1/16)=3.125 is the right answer (5 points)

  1. Consider the data points ( x (^) i ,y (^) i ) given by (−3, 1), (−1,−1), (1, 1), (3,4). We wish to approximate it using the parabola y = a+bx+cx^2 and must determine the coefficients a, b and c.

1 1 1 1 1 3 9 1 1 1 1 1 3 1 1 3 1 1 1 3 1 1 3 1 9 1 1 9 1 1 1 9 1 1 9 1 1 3 9 4 4 0 20 5 0 20 0 11 20 0 164 45

So we need to solve the above system v

a b c a b c ⎡ ⎤ ⎡ − ⎤ (^) ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎢ (^) − − ⎥ ⎢ (^) − ⎥ (^) ⎢ ⎥ ⎢ (^) − − ⎥ ⎢ (^) −⎥ ⎢ ⎥ ⎢ ⎥ (^) ⎢ ⎥=⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ (^) ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢⎣ ⎥ ⎢⎦ ⎣ ⎥⎦ ⎣ ⎦ ⎢⎣ ⎥ ⎢⎦ ⎣ ⎥⎦ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎢ ⎥ ⎢ ⎥ (^) =⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢⎣ ⎥ ⎢⎦ ⎣ ⎥⎦ ⎢⎣ ⎥⎦

ia LU decomposition. We could do this with pivoting or without. For this example let us do it without.

Eliminate the 20 in the first column by subtracting 5 times 1st row. 4 0 20 0 20 0 0 0 64

a b c

⎡ ⎤ ⎡ ⎢ ⎥ ⎢ ⎢ ⎥ ⎢ ⎢⎣ ⎥ ⎢⎦ ⎣

2

5 11 20 and we are done! 20 / 64 11/ 20 (5 20 20 / 64) / 4 5 25 / 4 0 20 0 20 0 0 0 64

1 0 0 0 1 0 5 0 1

So the fit function is 45 /16 11 / 20 20 / 64

c b a

U

L

Check LU A

y x x

⎤ ⎡ ⎤ ⎥ (^) =⎢ ⎥ ⎥ ⎢ ⎥ ⎥⎦ ⎢⎣ ⎥⎦

= = = − × = − ⎡ ⎤ = ⎢^ ⎥ ⎢ ⎥ ⎢⎣ ⎥⎦

⎡ ⎤ = ⎢^ ⎥ ⎢ ⎥ ⎢⎣ ⎥⎦

=

= + +

a. Write down the normal equations for solving this problem via least squares

2 (^1 1 ) 2 2 2 2 (^23) 3 3 (^2 ) 4 4

Our equation for the coefficients can be written as 1 1 1 1 Substituting for ( , ) 1 3 9 1 1 1 1 1 1 1 1 1 1 3 9 4

i i

x x (^) y a x x y b x x y c x x y x y

a b c

⎢ − ⎥ ⎡^ ⎤ ⎢−

⎢ ⎥ ⎢^ ⎥=⎢

⎢ ⎥ ⎢^ ⎥ ⎢

⎢ ⎥ ⎢⎣^ ⎥⎦ ⎢

This equation has the form Ax = b. The normal equations are A t Ax = A t b b. Solve the resulting system of equations via LU decomposition