• 沒有找到結果。

Numerical Methods

N/A
N/A
Protected

Academic year: 2022

Share "Numerical Methods"

Copied!
7
0
0

加載中.... (立即查看全文)

全文

(1)

Numerical Methods

Midterm 1 March 18, 2014

• Please give details of your calculation. A direct answer without explanation is not counted.

• Your answers must be in English.

Problem 1 (15%)

Give the double binary representation of the number −32.6

Soluiton

Because

32 = (100000)2, 0.6 = (1001)2, we can know that

32.6 = 100000.1001 = 1.000001001 × 25. (a) The sign bit: 1.

(b) The exponent part: 5 + 1023 = 1028 ⇒ 10000000100.

(c) The mantissa part: 0000010011001100110011001100110011001100110011001100.

Problem 2 (15%)

Consider the following 4 × 4 matrix

3 1 3 5 6 4 2 1 6 1 9 2 3 4 5 6

 .

Calculate the LU factorization.

(2)

Soluiton

Because we want to do a LU factorization with no pivoting, we can assume that

3 1 3 5 6 4 2 1 6 1 9 2 3 4 5 6

=

1 0 0 0

l21 1 0 0 l31 l32 1 0 l41 l42 l43 1

u11 u12 u13 u14 0 u22 u23 u24 0 0 u33 u34 0 0 0 u44

 .

(a) We can know that

u11 = 3, u12= 1, u13 = 3, u14= 5, l21= 2, l31 = 2, l41 = 1.

(b)

4 2 1 1 9 2 4 5 6

−

 2 2 1

1 3 5 =

1 0 0

l32 1 0 l42 l43 1

u22 u23 u24 0 u33 u34

0 0 u44

2 −4 −9

−1 3 −8

3 2 1

=

1 0 0

l32 1 0 l42 l43 1

u22 u23 u24 0 u33 u34

0 0 u44

 Then, we can get

u22= 2, u23 = −4, u24= −9, l32= −1/2, l42= 3/2.

(c)

3 −8 2 1



−−1/2 3/2



−4 −9 = 1 0 l43 1

 u33 u34 0 u44



1 −25/2 8 29/2



= 1 0 l43 1

 u33 u34 0 u44



Then, we can get

u33= 1, u34= −25/2, l43= 8, u44 = 229/2.

Finally, the conclusion is

3 1 3 5 6 4 2 1 6 1 9 2 3 4 5 6

=

1 0 0 0

2 1 0 0

2 −1/2 1 0 1 3/2 8 1

3 1 3 5

0 2 −4 −9

0 0 1 −25/2 0 0 0 229/2

 .

Problem 3 (15%)

Conduct LU factorization with pivoting to solve the following linear system

2 4 1

4 −10 2

1 2 4

 x1 x2 x3

=

 5

−8 13

.

(3)

Soluiton

Since we want to use a LU decomposition with pivoting, the left hand side need to first transfer to the form P Ax = LU where

A =

2 4 1

4 −10 2

1 2 4

 and we define

b =

 5

−8 13

. (a) Let us first find U , L and P .

P1A =

0 1 0 1 0 0 0 0 1

2 4 1

4 −10 2

1 2 4

=

4 −10 2

2 4 1

1 2 4

L1(P1A) =

1 0 0

−1/2 1 0

−1/4 0 1

4 −10 2

2 4 1

1 2 4

=

4 −10 2

0 9 0

0 9/2 7/2

P2(L1P1A) =

1 0 0 0 1 0 0 0 1

4 −10 2

0 9 0

0 9/2 7/2

=

4 −10 2

0 9 0

0 9/2 7/2

L2(P2L1P1A)

1 0 0

0 1 0

0 −1/2 1

4 −10 2

0 9 0

0 9/2 7/2

=

4 −10 2

0 9 0

0 0 7/2

So, we can get

U =

4 −10 2

0 9 0

0 0 7/2

 ,

L = L−11 L−12 =

1 0 0 1/2 1 0 1/4 0 1

1 0 0

0 1 0

0 1/2 1

=

1 0 0

1/2 1 0 1/4 1/2 1

 and

P = P2P1 =

1 0 0 0 1 0 0 0 1

0 1 0 1 0 0 0 0 1

=

0 1 0 1 0 0 0 0 1

. (b) Then, we can solve this linear system.

(4)

(a) Solve Ly = P b.

y = L2L1P b

=

1 0 0

0 1 0

0 −1/2 1

1 0 0

−1/2 1 0

−1/4 0 1

0 1 0 1 0 0 0 0 1

 5

−8 13

=

−8 9 21/2

.

(b) Solve U x = y using back substitution. The linear system is as follows:

4 −10 2

0 9 0

0 0 7/2

 x1 x2 x3

=

−8 9 21/2

.

Finally, we can easily get

x3 = 3 ⇒ x2 = 1 ⇒ x1 = −1.

Problem 4 (20%)

Recall that we prove by using p + 1 digits for x − y, then the relative rounding error < 2.

Consider β = 10 and p = 3.

(a) For Case 1 and Case 2 in the proof, give an example achieving the largest possible relative error. The purpose of this problem is to check if you understand the proof. Note that you need to give an example for Case 1 and an example for Case 2.

(b) For examples that you used in (a), what is the relative error if we use p + 2 digits?

(c) Same as (b) but using p + 3 digits.

(d) Same as (b) but using p + 4 digits.

Soluiton

(a) Case 1:

We set x = 1.01 and y = 0.00599. Then, ¯y = 0.005 and

x − y = 1.00401, x − ¯y + δ = 1.005 ≈ 1.01.

Therefore, the relative error is

|1.00401 − 1.01|

1.00401 ≈ 5.97 × 10−3.

(5)

The upper bound in the proof is (β

2 + 1) × β−p = 6 × 10−3. Case 2:

We set x = 1.00 and y = 0.00999. Then, ¯y = 0.009 and

x − y = 0.99001, x − ¯y + δ = 0.991.

Therefore, the relative error is

|0.99001 − 0.991|

0.99001 ≈ 10−3. The upper bound in the proof is

β−p = 10−3. (b) Case 1:

We set x = 1.01 and y = 0.00599. Then, ¯y = 0.0059 and

x − y = 1.00401, x − ¯y + δ = 1.0041 ≈ 1.00.

Therefore, the relative error is

|1.00401 − 1.00|

1.00401 ≈ 3.99 × 10−3. Case 2:

We set x = 1.00 and y = 0.00999. Then, ¯y = 0.0099 and

x − y = 0.99001, x − ¯y + δ = 0.9901 ≈ 0.990.

Therefore, the relative error is

|0.99001 − 0.990|

0.99001 ≈ 1.01 × 10−5. (c) Case 1:

We set x = 1.01 and y = 0.00599. Then, ¯y = 0.00599 and

x − y = 1.00401, x − ¯y + δ = 1.00401 ≈ 1.00.

Therefore, the relative error is

|1.00401 − 1.00|

1.00401 ≈ 3.99 × 10−3.

(6)

Case 2:

We set x = 1.00 and y = 0.00999. Then, ¯y = 0.00999 and

x − y = 0.99001, x − ¯y + δ = 0.99001 ≈ 0.990.

Therefore, the relative error is

|0.99001 − 0.990|

0.99001 ≈ 1.01 × 10−5. (d) The same as (c).

Problem 5 (20%)

Assume β = 10 and p = 3. Consider

x2− y2 versus (x + y)(x − y).

Give an example so that the relative error of the former is at least four times that of the latter.

We assume exactly rounded operations are conducted using the rounding even scheme. Note that do not find the relative error of the latter which can equal to zero.

Soluiton

We set x = 1 and y = 0.982. The exactly solution is

12− 0.9822 = (1 + 0.982)(1 − 0.982) = 0.035676.

(a) For x2− y2:

1 ⊗ 1 = 1.00, 0.982 ⊗ 0.982 = 0.964 ⇒ 1 0.964 = 0.036.

(b) For (x + y)(x − y):

1 ⊕ 0.982 = 1.98, 1 0.982 = 0.018 ⇒ 1.98 ⊗ 0.018 = 0.0356.

So, the ratio of these two relative errors is

|0.036 − 0.035676|

|0.0356 − 0.035676| = 0.000324 0.000076 > 4.

(7)

Problem 6 (15%)

Consider the following 4 × 4 symmetrix matrix

2 2 1 4 2 8 7 9 1 7 4 6 4 9 6 4

 .

(a) Use the procedure taught in the class to do Cholesky factorization.

(b) Can you finish the procedure? If not, why?

Soluiton

(a) Let us define

L =

a 0 0 0 e b 0 0 f g c 0 h i j d

 .

The procedure of Cholesky factorization is:

(1)

a =√

2, e = 2/√

2, f = 1/2, h = 4/√ 2.

(2)

8 7 9 7 4 6 9 6 4

−

 2/√

2 1/√

2 4/√

2

2/√

2 1/√

2 4/√ 2

=

6 6 5

6 7/2 4

5 4 −4

So, we can derive b =√

6, g = 6/√

6, i = 5/√ 6.

(3)

7/2 4 4 −4



−6/√ 6 5/√

6



6/√

6 5/√ 6

=−5/2 −1

−1 −49/6

 . Therefore, we failed at this step.

(b) The reason is that this matrix is a non-positive-definite matrix.

參考文獻

相關文件

it so that the corner point touch the upper edge as shown in the figure.. Find x such that the area A

By the similar reasoning of pumping lemma, if some non-S variable appears at least twice in a path from root, then the looping part between the two occurrences can be repeated as

An open-top box with a square base and two perpendicular dividers, as shown in the diagram, is to have a volume of 288 cubic inches7. Use Lagrange multipliers to find the

Determine how much money the company should spend on newspaper advertising and on television advertising per month to maximize its monthly

• To the right of the Draw mode buttons you find push buttons through which you can access all the functions that you need to define and solve the PDE problem: define

(12%) Among all planes that are tangent to the surface x 2 yz = 1, are there the ones that are nearest or farthest from the origin?. Find such tangent planes if

[r]

The goal (maybe just a hope) of this note is helping you to understand what the calculus(as verb) is in calculus (as word).. But the only way to achieve that is doing the calculus