0% found this document useful (0 votes)
15 views8 pages

Exam TANA09 2022 January

The document outlines an exam for the course TANA09 on computational mathematics at Linköping University, detailing the allowed materials, exam date, and contact information for the examiner. It includes a series of problems related to numerical methods, error analysis, interpolation, and least squares, along with specific questions and required calculations. The exam consists of multiple parts, each with varying point values, and emphasizes the importance of accuracy and error bounds in computational tasks.

Uploaded by

farmous
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)
15 views8 pages

Exam TANA09 2022 January

The document outlines an exam for the course TANA09 on computational mathematics at Linköping University, detailing the allowed materials, exam date, and contact information for the examiner. It includes a series of problems related to numerical methods, error analysis, interpolation, and least squares, along with specific questions and required calculations. The exam consists of multiple parts, each with varying point values, and emphasizes the importance of accuracy and error bounds in computational tasks.

Uploaded by

farmous
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/ 8

TEKNISKA HÖGSKOLAN I LINKÖPING

Matematiska institutionen
Beräkningsmatematik/Fredrik Berntsson

Exam TANA09 Datatekniska beräkningar

Date: 14-18, 15th of January, 2022.

Allowed:

1. Pocket calculator

Examiner: Fredrik Berntsson

Marks: 25 points total and 10 points to pass.

Jour: Fredrik Berntsson - (telefon 013 28 28 60)

Good luck!
2
(5p) 1: a) Let a = 0.008755661 be an exact value. Round the value a to 5 correct decimals
to obtain an approximate value ā. Also give a bound for the relative error in
ā.
b) We want to store the number x = 117.2277634 on a computer using the floating
point system (10, 5, −10, 10). What approximate number x̄ would actually be
stored on the machine?

c) Explain why the formula y = 1 + x − 1 can give poor accuracy when evalua-
ted, for small x, on a computer. Also propose an alternative formula that can
be expected to work better.
d) Let y = e−2x , where x = 0.95 ± 0.02. Compute the approximate value ȳ and
give an error bound.

(3p) 2: Let the table,

x 0.6 0.8 1.0


f (x) 1.3 1.1 1.2

of correctly rounded function values, be given. Do the following

a) Use Lagrange interpolation formula to write an explicit expression for the


polynomial that interpolates the above table.
b) Suppose the value f (0.6) = 1.3 has an error and we actually have f (0.6) =
1.3 ± 0.03. Find the maximum error in the interpolating polynomial, for the
interval 0.6 < x < 1.0, due to the error in the function value f (0.6).

(2p) 3: We compute the function


f (x) = ex − 3x
for small x values on a computer with unit round off µ = 1.11 · 10−16 . Preform an
analysis of the computational errors to obtain a bound for the relative error in the
computed results f (x). For the analysis you may assume that all computations are
performed with a relative error at most µ. Also, use the obtained bound to argue
if cancellation occurs during the computations. In case of cancellation also suggest
an alternative formula that can be expected to give better accuracy.

3
(3p) 4: A quadratic Beziér curve is given by the expression

p(t) = (1 − t)2 P1 + 2(1 − t)tP2 + t2 P3 , 0 < t < 1,

where P1 , P2 and P3 are control points. Suppose we want to combine two quadratic
Beziér curves to one single corve. For this purpose we chose five control points as
follows
P2

P3

P1
P4

P5

The point P3 is common for both curves. We have chosen P2 = (2 , 6)T , P3 = (3 , 5)T
and P5 = (6 , 1). Find coordinates for the point P4 such that the tangent direction
of the combined curve is continuous at the point P3 and that the tangent is vertical
at the endpoint P5 . Motivate your choice for P4 carefully.

(3p) 5: Do the following

a) A computer program has computed the decomposition P A = LU and the


output is
     
1 0 0 1.7 −2.3 −1.4 1 0 0
L = −0.7 1 0
  U=  0 1.2 −0.5  P= 0 0
 1 .
0.3 1.8 1 0 0 3.1 0 1 0

Determine if pivoting was used correctly during the computations. Motivate


your answer!
b) Find a Gauss transformation M such that
   
2 2
 3   3 
M 0.6  = 
  .
0 
−1.8 0

c) Explain what is ment by a matrix norm beeing induced from a vector norm.
Also show that if A and B are matrices then for an induced norm kABk ≤
kAkkBk.

4
(4p) 6: Suppose A ∈ Rm×n , m > n. The least squares method can be used to minimize

kAx − bk2 .

Do the following:

a) Suppose we have a set of measurements (xk , yk ) for k = 1, . . . , m. We want to


adapt a function of the type

yk ≈ c1 + c2 e−xk + c3 sin(πxk ) + c4 xk sin(πxk )

to the measurements by using the least squares method. Clearly show what
the matrix A and the right hand side b is for this particular case.
b) Let A be an m × n, m > n, matrix, and let A = Q1 R be the reduced QR
decomposition. Give the dimensions for Q1 and R. Also give a formula for
computing the solution to the least squares problem Ax = b using the reduced
QR decomposition. Finally estimate the amount of arithmetic work required to
compute the least squares solution (not counting the work needed to compute
the QR decomposition itself).
c) Show that if k · k is an induced norm and Q is orhogonal then kAQk = kAk.

(2p) 7: A numerical method, depends on a discretization parameter h, and has a truncation


error that can be described as RT ≈ Chp . We use the method to compute a few
approximations T (h) of the exact result T (0) and obtain

h 0.4 0.2 0.1


T(h) 4.0272 3.9240 3.8970

Use the table to determine C and p. Also estimate the value of h needed for the
error to be of magnitude 10−3.

(3p) 8: a) Suppose the n × n matrix A has rank k < n and that the linear system
of equations Ax = b has a solution. Use the singular valur decomposition
A = UΣV T to give a general formula for all solutions x of the system Ax = b.
Clealy motivate your answer.
b) Let A be an m × n matrix, m > n. Show how the singular value decomposition
A = UΣV T can be used for solving the minimization problem

min kAxk2 .
kxk2 =1

Give both the minmizer x and the minimum in terms of singular values and
singular vectors.

5
Answers

(5p) 1: For a) we obtain the approximate value ā = 0.00876 which has 5 correct decimal
digits. The absolute error is at most |∆a| ≤ 0.5 · 10−5 and thus the relative error is
bounded by ∆a|/|a| ≤ 0.5 · 10−5/0.00876 ≤ 0.58 · 10−3 .
In b) we rewrite the number as x = 1.172277634 · 102 to see that x̄ = 1.17228 · 102
is actually stored on the computer.

p c) Since 1 + x ≈ 1, for small x, we catastrophic cancellation will occur when
For
1 + x) − 1 is computed resulting in a large relative error in the result. A better
formula would be
p p
p ( 1 + x) − 1)( 1 + x) + 1) x
1 + x) − 1 = p =p
1 + x) + 1 1 + x) + 1

where the cancellation is removed.


For d) The approximate value is ȳ = e−2x̄ = exp(−2 · 0.95) = 0.15 with |RB | ≤
0.5 · 10−2 . The error propagation formula gives
∂y
|∆y| . | ||∆x| = | − 2 · exp(−2 · 0.95)||∆a| < 0.006.
∂x
The total error is |RT OT | ≤ 0.006 + 0.5 · 10−2 < 0.011. Thus y = 0.15 ± 0.02.

(3p) 2: For a) the polynomial is

(x − 0.8)(x − 1.0) (x − 0.6)(x − 1.0) (x − 0.6)(x − 0.8)


p2 (x) = 1.3 +1.1 +1.2 .
(0.6 − 0.8)(0.6 − 1.0) (0.8 − 0.6)(0.8 − 1.0) (1.0 − 0.6)(1.0 − 0.8)

There is no reason to simplify the expression further.


For b) we note that if the function value f (0.6) = f1 = 1.3 has en error then the
Lagrange polynomial changes as

(x − 0.8)(x − 1.0)
p̄2 (x) = p2 (x) + ∆f1 .
(0.6 − 0.8)(0.6 − 1.0)

The function |(x − 0.8)(x − 1.0)| has a local maximum for x = 0.9 and also a local
maximum at x = 0.6. The largest absolute value is achived for x = 0.6 which means
that
(0.6 − 0.8)(0.6 − 1.0)
|p̄2 (x) − p2 (x)| ≤ |∆f1 | = |∆f1 | ≤ 0.03.
(0.6 − 0.8)(0.6 − 1.0)

(2p) 3: The computational order is

f (x) = ex − 3x = a − 3x = a − b = c

6
The error propagation formula gives us
∂f ∂f ∂f
|∆f | . | ||∆a| + | ||∆b| + | ||∆c| = |1||∆a| + |1||∆b| + |1||∆c| .
∂a ∂b ∂c
µ(|a| + |b| + |c|) ≈ µ(|1| + |3x| + |1|) ≈ 2µ,
where we have used ex ≈ 1, f (x) = c ≈ 1 since x is small. There is no cancellation
present in these calculations. Everything turns out fine and both the absolute and
relative errors are bounded by 2µ (since the function value f (x) ≈ 1).

(3p) 4: We note that for the tangent to be vertical at P5 the x–coordinate need to be the
same at P4 and P5 . Thus P4 = (6, , α)T for some real number α. In order to get
a continuous tangent direction at P3 we need the vectors P3 − P2 = (1 , −1)T to
be parallell with P4 − P3 = (3 , α − 5)T which only works out if α = 2. Thus
P4 = (6 , 2)T .

(3p) 5: For a) we just observe that one of the multipliers (i.e. ℓ32 = 1.8) is larger than one.
Thus pivoting wasn’t used correctly.
For b) The multipliers are m3 = 0.6/3 = 0.2 and m4 = −1.8/3 = −0.6. Therefore
the Gauss transformation is
 
1 0 0 0
 0 1 0 0 
M = 0 0.2
.
1 0 
0 −0.6 0 1

For c) A matrix norm is induced if its definition is based on a vector norm, i.e.

kAxk
kAk = max
x6=0 kxk

For such norms we have


  
kABxk kABxk kBxk kABxk kBxk kAyk
kABk = max = max ≤ max max ≤ max kBk ≤ kAkk
x6=0 kxk x6=0 kBxk kxk x6=0 kBxk x6=0 kxk y6=0 kyk

(4p) 6: For a) we note that each data point (xi , yi ) gives one row of the over determined
system Ax = b. The model is y = c1 + c2 e−x + c3 sin(πx) + c4 x sin(πx). Thus the
system Ax = b is
    
1 e−x1 sin(πx1 ) x1 sin(πx1 ) c1 y 1
 1 e−x2 sin(πx2 ) x2 sin(πx2 )    y2 
  c2 
 .. .. .. .. =  ..  .
   
 . . . .  c3  . 
  
1 e −xm
sin(πxm ) xm sin(πxm ) c 4 ym

7
For b) The dimensions are m × n for Q1 and n × n for R. The formula is x =
R−1 (QT1 b) and the matrix vector multiply y = QT1 b requires approimately mn mul-
tiplications and additions. Since R is triangular computing R−1 y by backwards
substitution requires n2 /2 multiplications and additions. So the operation count is
2mn + n2 ≈ 2mn if m >> n.
Finnally, for c) we have
kAQxk kAyk
kAQk = max = { set y = Qx and note kQxk = kyk} = max = kAk
x6=0 kxk y6=0 kyk

(2p) 7: Since T (h) = T (0) + Chp we get


T (4h) − T (2h) (4p − 2p )Chp
≈ p = 2p
T (2h) − T (h) (2 − 1p )Chp
Insert numbers from the table we obtain
4.0272 − 3.9240
2p = = 3.8224
3.9240 − 3.8970
Which fits resonably well with p = 2. In order to determine C we use the last
equation T (2h) − Tp(h) = (22 − 12 )Ch2 and insert h = 0.1 to obtain C = 0.9. Finally
RT = 10−3 if h = 10−3 /0.9 = 0.035. Thus h < 0.035 is required.

(3p) 8: For a) we note that if rank(A) = k then {vk+1, . . . , vn } is a basis for null(A) and
{v1 , . . . , vk } is a basis for its orthogonal complement (null(A))⊥ . Thus for evey x
we can write
Xk n
X
x = x1 + x2 = ( ci vi ) + ( ci vi ).
i=1 i=k+1
In order to determine x1 we compute
k
X n
X
Ax = A(x1 + x2 ) = Ax1 + 0 = ci σi ui = b = (uTi b)ui .
i=1 i=1

Where (uTi b) = 0, for i = k + 1, . . . , n, since it is said that the solution exists. Thus
k n
X uT b i
X
x1 = vi and x2 = ci vi ,
i=1
σi i=k+1

where ci , i = k + 1, . . . , n, are undetermined parameters.


For b) we use the singular value decomposition to write kAxk2 = kUΣV T xk2 =
kΣyk2 , where y = V T x. Since V is orthogonal kxk2 = kyk2. Thus the minimization
problem is equivalent to
n
X n
X
min kΣyk22 = . min σi2 yi2 ≥ σn2 yi2 = σn2 ,
kyk2 =1 kyk2 =1
i=1 i=1

since σn is the smallest singular value, with equality if y = en which means that
x = V T en = vn .

You might also like