Question

In: Advanced Math

Consider the matrix of Hibert H100 and the system HX = b, where b is a...

Consider the matrix of Hibert H100 and the system HX = b, where b is a column vector from 1 to 100. Solve the system in the following three ways -->

1) X = H-1 b

2) Using the factorization H = LU

3) Using the factorization H = QR

Premultiplica H for each of the three solution vectors and make the comparison with vector b.

What method gives a better solution?

Solutions

Expert Solution

function compar_lu_qr()

H=hilb(100);
b=1:1:100;
b=b';

%Direct inverse method
x_1=inv(H)*b;

% LU decomposition
[L,U]=lu(H);
y=L\b;
x_2=U\y;

% QR decomposition
[Q,R]=qr(H);
y=Q\b;
x_3=R\y;

b_1=H*x_1;
b_2=H*x_2;
b_3=H*x_3;

solution=[b_1,b_2,b_3]

end

Output :

solution =

1.0e+03 *

-5.2502 0.0010 0.0010
-5.0870 0.0020 0.0020
-4.9308 0.0030 0.0030
-4.7819 0.0040 0.0040
-4.6406 0.0050 0.0050
-4.5067 0.0060 0.0060
-4.3800 0.0070 0.0070
-4.2600 0.0080 0.0080
-4.1463 0.0090 0.0090
-4.0385 0.0100 0.0100
-3.9362 0.0110 0.0110
-3.8391 0.0120 0.0120
-3.7467 0.0130 0.0130
-3.6588 0.0140 0.0140
-3.5750 0.0150 0.0150
-3.4950 0.0160 0.0160
-3.4187 0.0170 0.0170
-3.3456 0.0180 0.0180
-3.2758 0.0190 0.0190
-3.2088 0.0200 0.0200
-3.1446 0.0210 0.0210
-3.0829 0.0220 0.0220
-3.0237 0.0230 0.0230
-2.9668 0.0240 0.0240
-2.9119 0.0250 0.0250
-2.8591 0.0260 0.0260
-2.8082 0.0270 0.0270
-2.7591 0.0280 0.0280
-2.7117 0.0290 0.0290
-2.6659 0.0300 0.0300
-2.6216 0.0310 0.0310
-2.5788 0.0320 0.0320
-2.5374 0.0330 0.0330
-2.4972 0.0340 0.0340
-2.4583 0.0350 0.0350
-2.4206 0.0360 0.0360
-2.3839 0.0370 0.0370
-2.3484 0.0380 0.0380
-2.3139 0.0390 0.0390
-2.2803 0.0400 0.0400
-2.2477 0.0410 0.0410
-2.2160 0.0420 0.0420
-2.1852 0.0430 0.0430
-2.1551 0.0440 0.0440
-2.1258 0.0450 0.0450
-2.0973 0.0460 0.0460
-2.0695 0.0470 0.0470
-2.0425 0.0480 0.0480
-2.0160 0.0490 0.0490
-1.9902 0.0500 0.0500
-1.9651 0.0510 0.0510
-1.9405 0.0520 0.0520
-1.9165 0.0530 0.0530
-1.8930 0.0540 0.0540
-1.8701 0.0550 0.0550
-1.8476 0.0560 0.0560
-1.8257 0.0570 0.0570
-1.8042 0.0580 0.0580
-1.7832 0.0590 0.0590
-1.7627 0.0600 0.0600
-1.7425 0.0610 0.0610
-1.7228 0.0620 0.0620
-1.7035 0.0630 0.0630
-1.6845 0.0640 0.0640
-1.6660 0.0650 0.0650
-1.6478 0.0660 0.0660
-1.6299 0.0670 0.0670
-1.6124 0.0680 0.0680
-1.5953 0.0690 0.0690
-1.5784 0.0700 0.0700
-1.5618 0.0710 0.0710
-1.5456 0.0720 0.0720
-1.5296 0.0730 0.0730
-1.5140 0.0740 0.0740
-1.4986 0.0750 0.0750
-1.4834 0.0760 0.0760
-1.4686 0.0770 0.0770
-1.4540 0.0780 0.0780
-1.4396 0.0790 0.0790
-1.4255 0.0800 0.0800
-1.4116 0.0810 0.0810
-1.3979 0.0820 0.0820
-1.3844 0.0830 0.0830
-1.3712 0.0840 0.0840
-1.3582 0.0850 0.0850
-1.3453 0.0860 0.0860
-1.3327 0.0870 0.0870
-1.3203 0.0880 0.0880
-1.3080 0.0890 0.0890
-1.2959 0.0900 0.0900
-1.2841 0.0910 0.0910
-1.2723 0.0920 0.0920
-1.2608 0.0930 0.0930
-1.2494 0.0940 0.0940
-1.2382 0.0950 0.0950
-1.2272 0.0960 0.0960
-1.2163 0.0970 0.0970
-1.2055 0.0980 0.0980
-1.1949 0.0990 0.0990
-1.1844 0.1000 0.1000

QR method gives better solution even though Hilbert matrix is ill conditioned.


Related Solutions

A linear system of equations Ax=b is known, where A is a matrix of m by...
A linear system of equations Ax=b is known, where A is a matrix of m by n size, and the column vectors of A are linearly independent of each other. Please answer the following questions based on this assumption, please explain all questions, thank you~. (1) Please explain why this system has at most one solution. (2) To give an example, Ax=b is no solution. (3) According to the previous question, what kind of inference can be made to the...
Consider the matrix B =          −1 1...
Consider the matrix B =          −1 1 1 2 −1 1 0 3 −2 2 1 −4           (a) Find ||B||F. (b) It can be shown (See Saito, Lecture Notes, 5.7) that the 1-norm of a matrix A ∈ Rm×n can be written as ||A||1 = max 1≤j≤n||aj||1 whereaj is the jth column of A. Find||B||1. (c) Find ||B||2. (d) It can...
Consider the system: A (aq) → B (aq) at 283 K where ΔGoform A = -11.5...
Consider the system: A (aq) → B (aq) at 283 K where ΔGoform A = -11.5 kJ/mol and ΔGoform B = -13.3 kJ/mol. Calculate the concentration of A at equilibrium when 2.01 mol of A and 1.39 mol of B are mixed in water to form exactly one liter of solution.
Consider the system: A (aq) → B (aq) at 251 K where ΔGoform A = -11.7...
Consider the system: A (aq) → B (aq) at 251 K where ΔGoform A = -11.7 kJ/mol and ΔGoform B = -14.1 kJ/mol. Calculate the concentration of A at equilibrium when 1.71 mol of A and 1.35 mol of B are mixed in water to form exactly one liter of solution.
Suppose the system AX = B is consistent and A is a 6x3 matrix. Suppose the...
Suppose the system AX = B is consistent and A is a 6x3 matrix. Suppose the maximum number of linearly independent rows in A is 3. Discuss: Is the solution of the system unique?
Solve the linear system of equations Ax = b, and give the rank of the matrix...
Solve the linear system of equations Ax = b, and give the rank of the matrix A, where A = 1 1 1 -1 0 1 0 2 1 0 1 1 b = 1 2 3
Determine the Kernel of matrix B. Determine the Cokernel of matrix B.
Matrix A 1 2 1 3 1 -1 1 2 2 4 1 3 3 2 1 -1 Matrix B 1 2 3 -2 -1 2 2 -1 2 3 2 -3 3 1 2 -1 3 -5 5 5 5 -7 7 -4 Determine the Kernel of matrix B.Determine the Cokernel of matrix B.Determine the row space of the Cokernel of B.Determine the inverse of matrix A. Perform LU (or PLU) factorization on matrix A and determine the L...
Consider the system of equations 2x-5y=a 3x+4y=b 2x- 4y=c where a, b, c are constants. Because...
Consider the system of equations 2x-5y=a 3x+4y=b 2x- 4y=c where a, b, c are constants. Because there are 3 equations and 3 unknowns, there are no possible values of a, b and c for which the system of equations has a unique solution. True or false?
Consider two containers A and B where A is a rigid container and B is a...
Consider two containers A and B where A is a rigid container and B is a container with a massless, frictionless piston that maintains constant pressure. NH3 (g) is injected into both containers and allowed to come to equilibrium. At equilibrium, 2 atm of Argon gas is injected into each container. Explain any changes (up, down or no change) to the equilibrium concentrations of NH3 , N2 and H2 ? a) do the partial pressures of container A change or...
a.) Find a basis for the row space of matrix B. b.) Find a basis for the column space of matrix B.
For the given matrix B= 1 1 1 3 2 -2 4 3 -1 6 5 1 a.) Find a basis for the row space of matrix B. b.) Find a basis for the column space of matrix B. c.)Find a basis for the null space of matrix B. d.) Find the rank and nullity of the matrix B.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT