Exam-TANA09-2025-January
Exam-TANA09-2025-January
Matematiska institutionen
Beräkningsmatematik/Fredrik Berntsson
Allowed:
1. Pocket calculator
Good luck!
2
(5p) 1: a) Let a = 712.6623 be an exact value. Round the value a to 6 significant digits
to obtain an approximate value ā. Also give a bound for the absolute error in
ā.
b) Let x = 37.119875. Write x in normalized form and give a bound for the
relative error when x is stored on a computer using the floating point system
(10, 5, −10, 10).
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.
p
d) Let y = 1 + a/2, where a = 1.27 ± 0.02. Compute the approximate value ȳ
and give an error bound.
with correctly rounded function values. Use linear interpolation to approximate the
function value f (1.18). Also give a complete error estimate.
3
(4p) 4: The non-linear equation f (x) = 1 − x2 + cos(x/2) = 0 has a root x∗ ≈ 1.34. Do the
following:
4
(4p) 6: Let A ∈ Rm×n be a matrix and A = UΣV T be the singular value decomposition.
Do the following:
a) Suppose m = n and rank(A) = n. Show that the formula
n
X uT bi
x= vi
i=1
σi
where the accuracy depends on the step size h used. The truncation error of the
method can be described as RT ≈ Chp . We compute a few approximations T (h) of
the exact integral I and obtain
Use the table to determine C and p. Also estimate the step size h needed for the
error to be of magnitude 10−4. Present your calculations.
5
Answers
(5p) 1: For a) we obtain the approximate value ā = 712.662 which has 6 significant digits.
The absolute error is at most |∆a| ≤ 0.5 · 10−3 .
In b) the x = 3.7119875 · 101 in normalized form and the unit round off for the
floating point system is µ = 0.5 · 10−5. This is an upper bound for the relative error
when a number is stored on the computer.
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) − 1 sin2 (x)
cos(x) − 1 = = = ,
cos(x) + 1) cos(x) + 1) cos2 (x) + 1
where the cancellation is removed.
p √
For d) The approximate value is ȳ = 1 + ā/2 = 1.635 = 1.28 with |RB | ≤
0.5 · 10−2 . The error propagation formula gives
∂y 1 1
|∆y| . | ||∆a| = | p ||∆a| < 0.004.
∂a 2 1 + a/2 2
The total error is |RT OT | ≤ 0.004 + 0.5 · 10−2 < 0.009 < 0.01. Thus y = 1.27 ± 0.01.
(2p) 2: We use Newtons interpolation formula and the ansatz p(x) = p1 (x) + RT (x) =
c0 + c1 (x − 1.0) + c2 (x − 1.0)(x − 1.3), where the last term will be used to estimate
the truncation error. Inserting the function values from the table leads to p(1.0) =
c0 = 1.284 and p(1.3) = c0 + c1 (0.3) = 1.413 which means c1 = 0.43. The last
equation is p(0.9) = c0 + c1 (0.5) + c2 (0.5)(0.2) = 1.475 which gives c2 = −0.24.
Thus
p1 (x) = 1.284 + 0.43(x − 1.0) and RT (x) = −0.24(x − 1.0)(x − 1.3).
We obtain f (1.18) ≈ p1 (1.18) = 1.361 with |RB | < 0.5 · 10−3 and RT ≤ | −
0.24(1.18 − 1.0)(1.18 − 1.3)| < 0.52 · 10−2. The errors in the function values used
also gives an error RXF < 0.5·10−3 in the result. Thus f (1.18) = 1.361±0.62·10−2 =
1.361 ± 0.7 · 10−2 .
6
(4p) 4: For a) we write the Newton-Raphson method as
f (xn )
xn+1 = xn − ,
f ′ (xn )
where f (x) is given in the exercise and f ′ (x) = −2x − sin(x/2)/2. There is no need
to simplify anything. Just inserting into the formula gives
For c) we state that the sequence {xn } has quadratic convergence (to x∗ ) if
|xn−1 − x∗ |
lim = C.
n→∞ |xn−1 − x∗ |2
where C is a constant. The same limit also cannot exist for p = 3 or we would have
cubic convergence. For the Newton-Raphson method ϕ(x) = x − f (x)/f ′ (x). Thus,
(3p) 5: For a) we just observe that one of the multipliers (i.e. ℓ21 = −1.7) is larger than
one in magnitude. Thus pivoting wasn’t used correctly.
For b) the Gauss transformation matrix should have the structure
1 0 0
M1 = −m1 1 0 ,
−m2 0 1
7
For b) we write the decomposition A = UΣV T as
n
X
A= σi ui viT ,
i=1
with equality for y = e1 . Thus kAk2 = σ1 . If A−1 exists then A−1 = V Σ−1 U T and
kA−1 k2 = kΣ−1 k2 . Since the diagonal elements of Σ−1 are 1/σi the largest diagonal
element is 1/σn and kA−1 k2 = 1/σn .
to obtain c2 = 1.8.
8
For b) the sketch is
P2 P3
P4
P1
The convex hull is the area enclosed by the dashed lines. Important features of the
Beziér curve is that since both P1 /P2 and P3 /P4 have the same x-coordinate the
tangent direction of the curve is vertical at both the starting and ending points.
In c) the identity 1 = (1 − t + t)3 = (1 − t)3 + 3(1 − t)2 t + 3(1 − t)t2 + t3 gives us
the weights for the control points. The cubic Beziér curve is thus
where the control points P1 , P2 , P3 , P4 are vectors in the plane R2 . The sketch should
clearly show that if you have two cubic Beziér segments then you need a total of
n = 7 control points.