Professional Documents
Culture Documents
2018–04–05
Exam duration 8:00–12:00. In order to pass, a minimum of 15 points is
required on the exam. The (preliminary) grade requirements are
grade 3 ≥ 15 p, grade 4 ≥ 21 p and grade 5 ≥ 26 p.
You are allowed to use a pocket calculator, but no other material of any
kind. Please answer the problems in Swedish or English.
Problems
1. Consider the linear system Ax = b, where the matrix A has the LU -
decomposition
1 0 0 1 2 1
A = LU = −2 1 0 0 1 2
3 −1 1 0 0 1
Solve Ax = b, with b = (1, 0, 1)T , by performing one forward and one back-
ward substitution. (2p)
2. Let
1 2 1 −6 1 3
B = −2 −3 0 and B −1 = 4 −1 −2
3 5 2 −1 1 1
b) Your friend has written a code for solving the linear system Bx = b,
with b = (1, 0, 1)T . The code has a bug and 0.001 is added to every
entry in the matrix B. Give a bound of the solution’s relative error
kδxk∞ /kx + δxk∞ caused by the bug. (2p)
x = (x + 3)1/3 , 1 ≤ x ≤ 3.
a) Write down the formula for the fixed point iteration and perform six
iterations with x0 = 2 as starting value. (1p)
1
4. Construct the Lagrange interpolation polynomial that interpolates the
data below. (3p)
x -1 0 1 2
y 2 0 0 -1
5. We would like to fit a straight line y(x) = c0 +c1 x to the data in Problem 4
by using the least squares method.
b) How does the error of the trapezoidal rule decrease as the number of
intervals N tends to infinity? (1p)
2
b) How does the global error of the implicit Euler method decrease as ∆t
tends to zero? (1p)
c) Your friend (again) has a code for approximating the initial value prob-
lem. With C = 0 and ∆t = 1/24, the code produces the graph below.
The full line is the exact solution y(t) and the circles are the approxi-
mations of y(n∆t). Has your friend used the implicit Euler method in
the code? Motivate your answer. (2p)
15
10
0
y
-5
-10
-15
0 0.2 0.4 0.6 0.8 1
t
b = [1 2 1]’
L = [0 0 0; 1 0 0; 1 2 0]
U = [0 0 -1; 0 0 0; 0 0 0]
D = [10 0 0; 0 12 0; 0 0 -9]
x = [0 0 0]’
N = 12
for n = 1:N
x = -inv(D)*(L+U)*x+inv(D)*b
end
x_out = x
Which numerical method is implemented in the code? What does the vector
x_out approximate? (3p)
Lycka till!