Exam TANA09 2022 Mars
Exam TANA09 2022 Mars
Matematiska institutionen
Beräkningsmatematik/Fredrik Berntsson
Allowed:
1. Pocket calculator
Good luck!
2
(5p) 1: a) Let a = 0.0390267 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) Let x = 13.245 and y = 7.8802 be two numbers that belong to the floating
point system (10, 4, −9, 9). What would be the result of z = x + y if the
computations where carried out on a computer using the floating point system
(10, 4, −9, 9)?
c) Explain why the formula y = cos(x)−1 can give poor accuracy when evaluated,
for small x, on a computer. Also propose an alternative formula that can be
expected to work better.
√
d) Let y = 2x, where x = 0.35 ± 0.02. Compute the approximate value ȳ and
give an error bound.
for small x values on a computer with unit round off µ = 1.11 · 10−16 . We find that
the results are quite poor and that the relative error in the result tends to grow as
x → 0. Explain the poor accuracy by performing an analysis of the computational
errors and give a bound for the relative error in the computed result f (x). For the
analysis you may assume that all computations are performed with a relative error
at most µ.
3
(3p) 4: A cubic Beziér curve is given by an expression
where P1 , P2 P3 and P4 are control points, and ci (t), i = 1, 2, 3, 4 are the weights.
a) Use the identity 1 = (1 − t + t)3 to dervie the weights ci (t) for the cubic Beziér
curve.
b) Suppose we want to combine two cubic Beziér curves to one single curve. The
combined curve should start in the point (0, 3), pass through the point (1, 1)
and end in the point (2, 0). The curves tanget should be horizontal at start
and end points and also vertical at the interpolation point (1, 1). Answer the
following queastions: Are these requirements enough to make the curve unique?
Provide a set of control points and clearly argue that all the requirements are
satisfied. Finally draw a sketch illustrating the two curve segments.
4
(4p) 6: Consider the cubic polynomial f (x) = x3 − 9x2 + 24x − 20. We want to use Newton-
Raphsons method for finding a root. Do the following
a) Formulate the Newton-Raphson method and derive the resulting iteration for-
mula when the method is applied to the above cubic polynomial.
b) When Newton-Raphson’s method is applied to the function f (x) above with
the starting guess x0 = 1.8 we obtain the following table
k xk |xk − x∗ |
0 1.8000 0.2000
1 1.8970 0.1030
2 1.9476 0.0524
3 1.9736 0.0264
4 1.9867 0.0133
State the definition of order of convergence p for an iterative method. Also
use the table to determine the order of convergence when Newton-Raphson’s
method is applied to this specific function f (x).
c) Use the results from b) and known properties of Newton-Raphson’s method
to determine if x∗ = 2 is a double or single root. Explain briefly why you reach
the conclusion.
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 m × n matrix A, with m > n, has rank n, and that the linear
system Ax = b has a solution. Use the singular value decomposition A =
UΣV T to give the a formula for the solution x of the system Ax = b. Is the
solution unique? Clealy motivate your answers.
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.03903 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.03903 ≤ 0.128 · 10−3 .
In b) we first compute the exact result z = 13.245+7.8802 = 21.1252 and round the
result to fit the number system (10, 4, −9, 9). to obtain z̄ = 21.125 = 2.1125 · 101 .
For c) Since cos(x) ≈ 1, for small x, we catastrophic cancellation will occur when
cos(x) − 1 is computed resulting in a large relative error in the result. A better
formula would be
cos(x) − 1)(cos(x) + 1) cos2 (x) − 12 − sin2 (x)
cos(x) − 1 = = = ,
cos(x) + 1 cos(x) + 1 cos(x) + 1
where the cancellation is removed.
√ √
For d) The approximate value is ȳ = 2x̄ = 2 · 0.35 = 0.84 with |RB | ≤ 0.5·10−2.
The error propagation formula gives
∂y
|∆y| . | ||∆x| = |(2 · 0.35)−1/2 |0.02| < 0.024.
∂x
The total error is |RT OT | ≤ 0.024 + 0.5 · 10−2 < 0.03. Thus y = 0.84 ± 0.03.
(3p) 2: First we note that the closest points to x = 1.57 in the table are x1 = 1.5, x2 = 1.6,
and x3 = 1.7.
Making the anzatz p1 (x) = c0 + c1 (x − 1.5) + c2 (x − 1.5)(x − 1.6), where the last
term will be used to estimate the truncation error RT , we obtain
So p1 (x) = 1.183 − 0.54 · (x − 1.5) and RT (x) = −0.95(x − 1.5)(x − 1.6). Thus
we obtain p1 (1.57) = 1.145, RB ≤ 0.5 · 10−3 , |RT (1.57)| ≤ 2 · 10−3 . We also have
to remember the errors in the table giving RXF ≤ 0.5 · 10−3 . Thus f (1.57) =
1.145 ± (0.5 · 10−3 + 2 · 10−3 + 0.5 · 10−3 ) = 1.145 ± 3 · 10−3 .
The relative errors in the intermediate results, e.g. |∆a|/|a|, are boudned by µ. The
error propagation formula gives
1 1
|∆f | . | √ ||∆a| + | √ ||∆b| + |∆c| + |∆d| + |∆e|.
2 a 2 b
6
In order to simplify the result we use a ≈ b ≈ c ≈ d ≈ 1 for small x. Also
√ √ √ √
( 1 + x − 1 − x)( 1 + x + 1 − x) 2x
f (x) = √ √ =√ √ ≈ x,
1+x− 1−x 1+x− 1−x
for small x. We obtain
1 1
|∆f | . µ( + + 1 + 1 + |x|) ≈ 3µ.
2 2
Since f (x) ≈ x for small x the bound for the relative error is |∆f |/|f | ≤ 3|x|−1 µ.
(3p) 4: For a) we compute (1 − t + t)3 = (1 − t)3 + 3(1 − t)2 t + 3(1 − t)t2 + t3 = c1 (t) +
c2 (t) + c3 (t) + c4 (t).
For b) we recall that the tangent on a Beziér cubic curve satisfies s′ (0) = 3(P2 −P1 )
and s′ (1) = 3(P4 −P3 ). Thus the curve is horizontal at the start point if P1 and P2 has
the same y-coordinate. This does not put any requirements on the x-coordinate of
P2 . Thus we can pick points P1 = (0, 3), P2 = (0.5, 3), P3 = (1, 1.5), and P4 = (1, 1)
for the first curve segment. The curve will have a vertical tangent at the end point
since P3 and P4 has the same x-coordinate. The y-coordinate can be chosen freely.
Similarily the second curve segment is determined by the control points p4 = (1, 1),
P5 = (1, 0.5), P6 = (1.5, 0) and P7 = (2, 0). As explained above the curve is not
unique.
(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) we note that the largest row-sum is given by the last row so kLk∞ =
0.3 + 1.8 + 1 = 3.1.
In c) we note the solution with the noisy b vector can be written A(x + ∆x) =
b + ∆b and thus A(∆x) = ∆b, or k∆xk = kA−1 ∆bk ≤ kA−1 kk∆bk. We also have
kbk = kAxk ≤ kAkkxk. Thus
k∆xk kA−1 kk∆bk k∆bk
≤ = kAkkA−1 k ,
kxk kbk/kAk kbk
where κ(A) = kAkkA−1 k is the condition number.
7
C = 0.2/1.03 = 1.9417, k = 2 gives C = 0.1030/0.0524 = 1.9656, etc. This means
that p = 1 and we have linear convergence.
In c) we recall that Newtons method is supposed to have quadratic convergence if
the root x∗ is a single root. Also the convergence is linear for double roots. Thus
the function f (x) the root x∗ = 2 is a double root.
(3p) 8: For a) we note that if rank(A) = n then the matrix only has the trivial null space.
Thus any solution we find is unique. Thus the solution can be written as
n
X
x= ci vi ,
i=1
Where (uTi b) = 0, for i = n + 1, . . . , m, since it is said that the solution exists. Thus
n
X uT b i
x= vi ,
i=1
σi
since σn is the smallest singular value, with equality if y = en which means that
x = V T en = vn .