You are on page 1of 8

Q.1.

>> A = [314 628 942 1258 157; 628 98596 1 1 1; 942 1 98596 1 1; 1258 1 1 98596 1; 1570 1 1 1 314]

A=

314 628 942 1258 157


628 98596 1 1 1
942 1 98596 1 1
1258 1 1 98596 1
1570 1 1 1 314

a)

>> B = A* (A +A')

B=

1.0e+010 *

0.0006 0.0124 0.0186 0.0249 0.0001


0.0124 1.9443 0.0002 0.0002 0.0001
0.0186 0.0002 1.9444 0.0003 0.0002
0.0249 0.0002 0.0003 1.9446 0.0002
0.0002 0.0002 0.0003 0.0004 0.0003

>> C = inv(A)

C=

-0.0020 0.0000 0.0000 0.0000 0.0010


0.0000 0.0000 -0.0000 -0.0000 -0.0000
0.0000 -0.0000 0.0000 -0.0000 -0.0000
0.0000 -0.0000 -0.0000 0.0000 -0.0000
0.0100 -0.0001 -0.0001 -0.0001 -0.0018
>> D = det(A)

D=

-1.5045e+020

b)

>> E = A+1

E=

315 629 943 1259 158

629 98597 2 2 2

943 2 98597 2 2

1259 2 2 98597 2

1571 2 2 2 315

>> F= 2*A

F=

628 1256 1884 2516 314

1256 197192 2 2 2

1884 2 197192 2 2

2516 2 2 197192 2

3140 2 2 2 628
>> G = [A E; E F]

G=

Columns 1 through 7

314 628 942 1258 157 315 629

628 98596 1 1 1 629 98597

942 1 98596 1 1 943 2

1258 1 1 98596 1 1259 2

1570 1 1 1 314 1571 2

315 629 943 1259 158 628 1256

629 98597 2 2 2 1256 197192

943 2 98597 2 2 1884 2

1259 2 2 98597 2 2516 2

1571 2 2 2 315 3140 2

Columns 8 through 10

943 1259 158

2 2 2

98597 2 2

2 98597 2

2 2 315

1884 2516 314

2 2 2

197192 2 2

2 197192 2

2 2 628
Q.2. The system can be stated as the matrix equation A*x = b Multiplying each side from
the left by the inverse of the matrix A will give,

((inv(A))*A)*x = (inv(A))*b

But a matrix multiplied by its inverse from the right or left gives an identity matrix I with ones
on the diagonal and zeros elsewhere, so that ,

((inv(A))*A)*x = I*x = x

Thus, the simple solution using Matlab is the command

>> b = [1;1;1;1;1]

b=

>> X = (inv(A))*b

X=

-0.0009

0.0000

0.0000

0.0000

0.0079

Z1 = -0.0009 Z2 = 0.0000 Z3 = 0.0000 Z4 = 0.0000

Z5 = 0.0079
Q.3. >> H = hilb(5)

H=

1.0000 0.5000 0.3333 0.2500 0.2000

0.5000 0.3333 0.2500 0.2000 0.1667

0.3333 0.2500 0.2000 0.1667 0.1429

0.2500 0.2000 0.1667 0.1429 0.1250

0.2000 0.1667 0.1429 0.1250 0.1111

Q.4.

a)

>> Q = H*H*H*H*H

Q=

5.5717 3.2346 2.3333 1.8388 1.5224

3.2346 1.8780 1.3547 1.0677 0.8839

2.3333 1.3547 0.9773 0.7702 0.6377

1.8388 1.0677 0.7702 0.6070 0.5026

1.5224 0.8839 0.6377 0.5026 0.4161

>> P = H*H*H*H

P=

3.5561 2.0638 1.4885 1.1730 0.9711

2.0638 1.1985 0.8647 0.6815 0.5643

1.4885 0.8647 0.6239 0.4918 0.4072

1.1730 0.6815 0.4918 0.3877 0.3210

0.9711 0.5643 0.4072 0.3210 0.2658


>> R = H*H*H

R=

2.2721 1.3157 0.9479 0.7464 0.6176

1.3157 0.7654 0.5527 0.4359 0.3610

0.9479 0.5527 0.3996 0.3153 0.2613

0.7464 0.4359 0.3153 0.2490 0.2064

0.6176 0.3610 0.2613 0.2064 0.1711

>> S = H*H

S=

1.4636 0.8333 0.5952 0.4663 0.3844

0.8333 0.4914 0.3571 0.2827 0.2348

0.5952 0.3571 0.2618 0.2083 0.1736

0.4663 0.2827 0.2083 0.1663 0.1389

0.3844 0.2348 0.1736 0.1389 0.1162

>> T = [1 2 2 2 2 ; 0 1 2 2 2; 0 0 1 2 2; 0 0 0 1 2; 0 0 0 0 1]

T=

1 2 2 2 2

0 1 2 2 2

0 0 1 2 2

0 0 0 1 2

0 0 0 0 1

>> Y = T+Q+P+R+S+H
Y=

14.8635 9.9475 7.6982 6.4745 5.6955

7.9475 5.6666 5.3793 4.6678 4.2107

5.6982 3.3793 3.4626 3.9524 3.6227

4.4745 2.6678 1.9524 2.5529 3.2939

3.6955 2.2107 1.6227 1.2939 2.0803

b)
I. >> Y(5,4)

ans =

1.2939

II. >> Y(8,9)

??? Attempted to access Y(8,9); index out of bounds because size(Y)=[5,5].

Q.5.

>> [Q,R] = qr(A)

Q=

-0.1348 0.0312 0.0537 0.1007 -0.9838

-0.2696 -0.9630 -0.0003 -0.0006 0.0063

-0.4043 0.1136 -0.9075 -0.0010 0.0094

-0.5400 0.1517 0.2605 -0.7857 0.0126

-0.6739 0.1893 0.3251 0.6103 0.1786


R=

1.0e+004 *

-0.2330 -2.6663 -3.9994 -5.3410 -0.0234

0 -9.4924 1.1226 1.4992 0.0064

0 0 -8.9423 2.5754 0.0110

0 0 0 -7.7344 0.0207

0 0 0 0 -0.0098

You might also like