The matrix form of the equation is
The coefficient matrix is and the augmented matrix isThe matrix form of the equation is
The coefficient matrix is and the augmented matrix isThe matrix form is
Now solve for x_{1} and x_{2} in terms of x_{3}:
Setting x_{3} = t gives the general solution
(AB)C gives the same answer, by the associative law.
DA+DB gives the same answer by the distributive law.
Octave, version 2.0.9 (i586-pc-linux-gnu). Copyright (C) 1996, 1997 John W. Eaton. This is free software with ABSOLUTELY NO WARRANTY. For details, type `warranty'. octave:1> n = 5; octave:2> H = hilb(n); octave:3> B = [1;zeros(n-1,1)]; octave:4> C = rref([H,B]); octave:5> S1 = C(1:n,n+1); octave:6> S2 = H\B; octave:7> [S1,S2]' ans = 25.000 -300.000 1050.000 -1400.000 630.000 25.000 -300.000 1050.000 -1400.000 630.000In the above calculation, C is the row reduced augmented matrix. Input line 5 extracts the last column from C and calls it S1. That's the solution obtained from Gaussian elimination (row reduction). Input line 6 calculates the solution by ``left division'', and labels the result as S2. The last line (the only one that prints its output), puts the two columns S1 and S2 side by side, transposes the result into two rows (that's what the prime does), and prints the two rows.
Notice that the two methods produced exactly the same solution.
octave:8> n = 20; octave:9> H = hilb(n); octave:10> B = [1;zeros(n-1,1)]; octave:11> C = rref([H,B]); octave:12> S1 = C(1:n,n+1); octave:13> S2 = H\B; warning: matrix singular to machine precision, rcond = 2.46047e-19 octave:14> [S1,S2] ans = 0.0000e+00 1.2170e+02 0.0000e+00 -7.3163e+03 0.0000e+00 1.4064e+05 0.0000e+00 -1.2519e+06 0.0000e+00 5.8963e+06 0.0000e+00 -1.5026e+07 0.0000e+00 1.8221e+07 0.0000e+00 -2.3673e+06 0.0000e+00 -1.3221e+07 0.0000e+00 1.7115e+04 0.0000e+00 1.0905e+07 0.0000e+00 6.2444e+06 0.0000e+00 -5.2245e+06 0.0000e+00 -9.9084e+06 0.0000e+00 -3.5317e+06 0.0000e+00 6.7210e+06 0.0000e+00 9.4337e+06 1.0000e+00 -4.1910e+05 0.0000e+00 -1.2279e+07 0.0000e+00 5.6575e+06Notice that this time, the two solution methods gave very different results. If you use Matlab instead of Octave, or if you work on a machine that uses a different precision for floating point calculations, you may get different numbers, but you'll still get different answers. Obviously they can't both be right. This illustrates that you can't always believe the results of numerical calculations. The problem here is that the truncation errors have been compounded by repeated calculations until they accumulated to wildly inaccurate answers.
octave:15> S3 = invhilb(n)*B; octave:16> [S1,S2,S3] ans = 0.0000e+00 1.2170e+02 4.0000e+02 0.0000e+00 -7.3163e+03 -7.9800e+04 0.0000e+00 1.4064e+05 5.2668e+06 0.0000e+00 -1.2519e+06 -1.7161e+08 0.0000e+00 5.8963e+06 3.2949e+09 0.0000e+00 -1.5026e+07 -4.1186e+10 0.0000e+00 1.8221e+07 3.5695e+11 0.0000e+00 -2.3673e+06 -2.2373e+12 0.0000e+00 -1.3221e+07 1.0441e+13 0.0000e+00 1.7115e+04 -3.7007e+13 0.0000e+00 1.0905e+07 1.0093e+14 0.0000e+00 6.2444e+06 -2.1332e+14 0.0000e+00 -5.2245e+06 3.5007e+14 0.0000e+00 -9.9084e+06 -4.4432e+14 0.0000e+00 -3.5317e+06 4.3162e+14 0.0000e+00 6.7210e+06 -3.1473e+14 0.0000e+00 9.4337e+06 1.6662e+14 1.0000e+00 -4.1910e+05 -6.0440e+13 0.0000e+00 -1.2279e+07 1.3431e+13 0.0000e+00 5.6575e+06 -1.3785e+12As you can see, neither of the previous solutions is even close.