FMNF05 Assignment3
FMNF05 Assignment3
FMNF05 Assignment3
February 2020
1 Task 1
Consider the n × n matrix A with entries Aij = 5/(i + 2j − 1).
For some n, let us study the rows and their one-norms. Let us compare the row
ai,∗ to the row ai+1,∗ :
n
X 5
kai,∗ k1 = (2)
i + 2j − 1
j=1
n
X 5
kai+1,∗ k1 = (3)
i + 2j
j=1
As we can see in equations 2 and 3, the denominators of the terms of the sum
are consistently greater in ai+1,∗ , while the numerator is constant in each term
and sum. If the numerator is constants and the denominator is greater, then
the quotient will be lesser. Therefore, the row with the greatest one-norm will
always be the first row, which gives us equation 4.
n n n
X 5 X
5 5 X 1
kAk∞ = = = (4)
1 + 2j − 1 2j 2 j=1 j
j=1 j=1
Now, let us study how the infinity-norm of the n×n-A relates to the n+1×n+1-
A. See equation 5.
n+1 n
5 X 1 5 X 1 5 1
kAn+1×n+1 k∞ = = + =
2 j=1 j 2 j=1 j 2 n+1
(5)
5 1
kAn×n k∞ +
2 n+1
1
Following are the calculations for n ∈ [6, 15]. Note that numerical values have
been truncated to six decimals.
n=6
6
5 X 1 5 1 1 1 1 1 1 5 147
kAk∞ = = + + + + + = ∗ = 6.125 (6)
2 j=1 j 2 1 2 3 4 5 6 2 60
n=7
7
5 X 1 5 1
kAk∞ = = kA6×6 k∞ + ≈ 6.125 + 0.357142 ≈ 6.482142 (7)
2 j=1 j 2 7
n=8
8
5 X 1 5 1
kAk∞ = = kA7×7 k∞ + ≈ 6.482142 + 0.3125 ≈ 6.794642 (8)
2 j=1 j 2 8
n=9
9
5 X 1 5 1
kAk∞ = = kA8×8 k∞ + ≈ 6.794642 + 0.277777 ≈ 7.0724206 (9)
2 j=1 j 2 9
n = 10
10
5 X 1 5 1
kAk∞ = = kA9×9 k∞ + ≈ 7.0724206 + 0.25 ≈ 7.322420 (10)
2 j=1 j 2 10
n = 11
11
5 X 1 5 1
kAk∞ = = kA10×10 k∞ + ≈ 7.322420 + 0.227272 ≈ 7.549693
2 j=1 j 2 11
(11)
2
n = 12
12
5 X 1 5 1
kAk∞ = = kA11×11 k∞ + ≈ 7.549693 + 0.208333 ≈ 7.758026
2 j=1 j 2 12
(12)
n = 13
13
5 X 1 5 1
kAk∞ = = kA12×12 k∞ + ≈ 7.758026 + 0.192307 ≈ 7.950334
2 j=1 j 2 13
(13)
n = 14
14
5 X 1 5 1
kAk∞ = = kA13×13 k∞ + ≈ 7.950334 + 0.178571 ≈ 8.128905
2 j=1 j 2 14
(14)
n = 15
15
5 X 1 5 1
kAk∞ = = kA14×14 k∞ + ≈ 8.128905 + 0.166666 ≈ 8.295572
2 j=1 j 2 15
(15)
1.2 Swamping
The approximations of x can be found in listing 9 in the appendix.
In figure 1, we can see that for smaller n, the condition number of A grows
exponentially.
3
100
1015
κ(A)
η
10−5
1010
10−10
10 15 10 15
n n
Figure 1: To the left are the condition numbers of A for n ∈ [6, 15] in task 1.
To the right are the relative errors of the solutions to Ax = b for n ∈ [6, 15] in
task 1.
When η = 10−1 , the error may be of the same order of magnitude as the
approximation, meaning that all significant digits could be wrong. This happens
when n = 12. With that order of magnitude, all modern computers should
produce the same result.
As a note, our results diverged as early as n = 11. I do not consider 0.999104
have all digits incorrect, since 0.999 · · · ≡ 1.
4
1
v1
0
−1
−1 0 1
v2
2 Task 2
A vector v is a unit vector if kvk = 1.
2.1 One-norm
One-norm is defined in equation 18 below.
n
X
kxk1 = |xi | (18)
i=1
Let us start with the one-norm unit vectors. Since we are working in R2 , our
unit vectors have two elements, so
2.2 Two-norm
v
u n
uX
kxk2 = t x2i (20)
i=1
5
v1 1 1
v1
0 0
−1 −1
−1 0 1 −1 0 1
v2 v2
Figure 3: To the left, all two-norm unit vectors v and to the right, all infinity
norm unit vectors v.
p
This is the equation
p of a circle with a radius of one. Let us plot x1 = 1 − x22
and x1 = − 1 − x22 . See figure 3.
2.4 Code
No code except LATEX with the pgfplots package was used. See listings 1, 2, and
3.
Listing 1: Code for producing the plot with one-norm unit vectors in task 2.
\ begin { t i k z p i c t u r e }
\ begin { axis }[
width =5.9cm ,
h e i g h t =5.9cm ,
x l a b e l=$v 2$ ,
y l a b e l=$v 1$ ,
domain = −1:1 ,
6
minor t i c k num=4,
g r i d=both ,
g r i d s t y l e ={ l i n e width =.1 pt , draw=gray ! 1 0 } ,
major g r i d s t y l e ={ l i n e width =.1 pt , draw=gray ! 5 0 }
]
\ a d d p l o t [ red , s a m p l e s =100]{1 − abs ( x ) } ;
\ a d d p l o t [ blue , s a m p l e s =100]{−1 + abs ( x ) } ;
\ end { a x i s }
\ end { t i k z p i c t u r e }
Listing 2: Code for producing the plot with two-norm unit vectors in task 2.
\ begin { t i k z p i c t u r e }
\ begin { axis }[
width =5.9cm ,
h e i g h t =5.9cm ,
x l a b e l=$v 2$ ,
y l a b e l=$v 1$ ,
%domain = −1:1 ,
minor t i c k num=4,
g r i d=both ,
g r i d s t y l e ={ l i n e width =.1 pt , draw=gray ! 1 0 } ,
major g r i d s t y l e ={ l i n e width =.1 pt , draw=gray ! 5 0 }
]
\ a d d p l o t [ red , s a m p l e s =1001]{ s q r t (1−x ˆ 2 ) } ;
\ a d d p l o t [ blue , s a m p l e s =1001]{− s q r t (1−x ˆ 2 ) } ;
\ end { a x i s }
\ end { t i k z p i c t u r e }
Listing 3: Code for producing the plot with intfy-norm unit vectors in task 2.
\ begin { t i k z p i c t u r e }
\ begin { axis }[
width =5.9cm ,
h e i g h t =5.9cm ,
x l a b e l=$v 2$ ,
y l a b e l=$v 1$ ,
%domain = −1:1 ,
minor t i c k num=4,
g r i d=both ,
g r i d s t y l e ={ l i n e width =.1 pt , draw=gray ! 1 0 } ,
major g r i d s t y l e ={ l i n e width =.1 pt , draw=gray ! 5 0 }
]
\ a d d p l o t +[mark=none ] c o o r d i n a t e s {
( −1 , −1) ( −1 ,1) ( 1 , 1 ) (1 , −1) ( −1 , −1)
};
\ end { a x i s }
7
\ end { t i k z p i c t u r e }
8
3 Task 3
1 2 1 4 1 1
A1 = , A2 = , A3 = (22)
2 1 −4 1 1 1
In the figure below we have plotted the norms in cyan, and the A * norm
in magenta. Then there is the code for calculating and plotting the different
graphs. Code part 2 is repeated for all A’s and norms.
9
Figure 4: The plots
10
Figure 6: Code part 2
4 Task 4
Consider the matrices A1 and A2 as given in equation 22 in task 3.
11
To find the eigenvector u, set (A1 − λI)x = 0. Start with λ1 = 3.
1−3 2 x1 0
=
2 1−3 x2 0
⇐⇒
(
−2x1 + 2x2 =0 1
⇔ x1 = x2 ⇔ u1 = k
2x1 − 2x2 =0 1
Where k is some constant scalar. Repeat for A2 . Set det (A2 − λI) = 0.
1 − λ 4
−4 = 0 ⇐⇒ (1 − λ)(1 − λ) − 4 ∗ (−4) = 0
1 − λ
⇐⇒ (1 − λ)(1 − λ) + 16 = 0
⇐⇒ (1 − λ)2 = −16
√
⇐⇒ (1 − λ) ± −16 (23)
(
1 − λ1 = 4i
⇐⇒
1 − λ2 = −4i
(
λ1 = 1 − 4i
⇐⇒
λ2 = 1 + 4i
12
Where k is some constant scalar. Then, for λ2 = 1 + 4i.
1 − (1 + 4i) 4 x1 0
=
4 1 − (1 + 4i) x2 0
⇐⇒
(
−4ix1 + 4x2 =0 i
⇔ x1 = −ix2 ⇔ u2 = k
4x1 + −4ix2 =0 −1
We continue with A2 . This matrix in not symmetric, but we can still use the
following: q
kAk2 = ρ(AT A) (24)
13
ρ(A) = max |λ| (25)
We first calculate AT2 A2 .
1 −4 1 4 17 0
AT2 A2 = =
4 1 −4 1 0 17
Let A−1 T
2 = B. We now calculate B B.
1
T 1 1 4 1 −4 1 17 0 0
B B= 2 = 2 = 17 1
17 −4 1 4 1 17 0 17 0 17
√
r
1
κ(A2 ) = kA2 k2 · kA−1
2 k2 = 17 ∗ =1
17
14
however, the same starting guess did not converge to the correct result, even in
1000 iterations. Instead, it converged to λmax = 1 and λmin = 17. In fact, it
converged to those values for several different real x0 .
Different complex x0 produced different results, even with 1000 iterations.
For example, x0 = (−17 + 5i, 11 + 19i) produced λmax ≈ 1.00000 − 3.79899
and λmin ≈ 1.10158 − 4.18490. Others produced wildly incorrect results. The
program was able to converge to correct results in very few (two) iterations
when x0 = (1.1i + 0.1, −1.1 + 0.1i), but would only produce the same eigen
vector as both maximum and minimum. See listings 4, 5, 6, 7.
15
Listing 4: Implementation of the Power Method.
1 % Based on the pseudo code in lecture 10
2 function lambda = power_method (A , x0 , iterations )
3 n = length ( A ) ;
4 x = zeros ( iterations , n ) ;
5 x (1 ,:) = x0 ;
6 u = zeros (n , iterations ) ;
7 l = zeros ( iterations , 1) ;
8 for j = 2: iterations
9 % normalize
10 u (: ,j -1) = x (j -1 ,:) / norm ( x (j -1 ,:) ,2) ;
11 % Power iteration for eigen vector
12 x (j ,:) = A * u (: ,j -1) ;
13 % Rayleigh quotient for eigen value
14 l(j) = u (: ,j -1) ' * A * u (: ,j -1) ;
15 end
16 % u (: , j ) = x (j ,:) / norm ( x (j ,:) ,2) ;
17 % A * u (: , j ) - l ( j ) * u (: , j )
18 lambda = l ( j ) ;
16
16 l_min = i n v e r s e _ p o w e r _ m e t h o d (A , x0 , 1000)
17
18 x0 = [1.1 i +0.1 -1.1+0.1 i ]
19 l_max = power_method (A , x0 , 2)
20 l_min = i n v e r s e _ p o w e r _ m e t h o d (A , x0 , 2)
21 diary off
17
38
39 l_min =
40
41 17
42
43
44 x0 =
45
46 Column 1
47
48 -17.000000000000000 + 5. 000000 000000 000 i
49
50 Column 2
51
52 11 .0 00 00 00 00 00 00 00 + 1 9 .0 0 0 00 0 0 00 0 0 00 0 0 i
53
54
55 l_max =
56
57 1.0 000000 000000 00 - 3.7 989949 748743 71 i
58
59
60 l_min =
61
62 1.1 015811 511985 01 - 4.1 849012 578194 37 i
63
64
65 x0 =
66
67 Column 1
68
69 0.1 000000 000000 00 + 1.1 000000 000000 00 i
70
71 Column 2
72
73 -1.100000000000000 + 0. 100000 000000 000 i
74
75
76 l_max =
77
78 1.0 000000 000000 00 + 3.9 999999 999999 99 i
79
80
81 l_min =
82
83 1.0 000000 000000 00 + 4.0 000000 000000 01 i
18
Appendix
19
38 fprintf ( '% d \ t %.6 e \ n ' , n , es ( n ) ) ;
39 end
40 diary off
20
27 x = (1.000000 , 1.000000 , 1.000001 , 1.000225 ,
0.993468 , 1.079399 , 0.466333 , 3.203143 ,
-4.870579 , 11.289551 , -10.783271 , 9.482357 ,
-2.482158 , 1.621531)
28 n = 15
29 infinity - norm = 8.295572
30 x = (1.000000 , 0.999989 , 1.000699 , 0.983112 ,
1.198485 , -0.305062 , 6.168525 , -11.722375 ,
20.284258 , -15.629808 , 6.699288 , 2.995919 ,
-0.750621 , 0.805904 , 1.271691)
21