07-Jan-2022 19:16:33 eros_test(): MATLAB/Octave version 9.8.0.1380330 (R2020a) Update 2 Test eros(). gauss_test1(): gauss() solves a 3x3 linear system with one right hand side. Matrix A: 0.8147 0.9134 0.2785 0.9058 0.6324 0.5469 0.1270 0.0975 0.9575 Exact solution x: 2 1 3 Right hand side b: 3.3783 4.0846 3.2240 Augmented matrix Ab, step 0 0.8147 0.9134 0.2785 3.3783 0.9058 0.6324 0.5469 4.0846 0.1270 0.0975 0.9575 3.2240 Augmented matrix Ab, after step 1 1.0000 0.6981 0.6038 4.5094 0 0.3446 -0.2134 -0.2956 0 0.0089 0.8808 2.6514 Augmented matrix Ab, after step 2 1.0000 0 1.0361 5.1083 0 1.0000 -0.6193 -0.8578 0 0 0.8863 2.6590 Augmented matrix Ab, after step 3 1.0000 0 0 2.0000 0 1.0000 0 1.0000 0 0 1.0000 3.0000 Computed solution x 2.0000 1.0000 3.0000 gauss_test2(): gauss solves a random 3x3 linear system with two right hand sides. Matrix A: 0.9649 0.9572 0.1419 0.1576 0.4854 0.4218 0.9706 0.8003 0.9157 Exact solution x: 2.0000 10.0000 1.0000 1.5000 3.0000 -2.0000 Right hand side b: 3.3126 10.8009 2.0659 1.4607 5.4887 9.0749 Augmented matrix Ab, step 0 0.9649 0.9572 0.1419 3.3126 10.8009 0.1576 0.4854 0.4218 2.0659 1.4607 0.9706 0.8003 0.9157 5.4887 9.0749 Augmented matrix Ab, after step 1 1.0000 0.8245 0.9435 5.6550 9.3498 0 0.3554 0.2731 1.1746 -0.0130 0 0.1616 -0.7685 -2.1438 1.7793 Augmented matrix Ab, after step 2 1.0000 0 0.3100 2.9301 9.3800 0 1.0000 0.7683 3.3048 -0.0365 0 0 -0.8926 -2.6778 1.7852 Augmented matrix Ab, after step 3 1.0000 0 0 2.0000 10.0000 0 1.0000 0 1.0000 1.5000 0 0 1.0000 3.0000 -2.0000 Computed solution x 2.0000 10.0000 1.0000 1.5000 3.0000 -2.0000 gauss_det_test(): gauss_det() uses Gauss elimination to find the determinant of a matrix. Matrix A: 1 2 3 4 5 6 7 8 9 Computed determinant = 6.66134e-16: MATLAB det(A) = -9.5162e-16: Matrix A: 1.0000 2.9387 -7.8728 8.8840 -11.4707 14.0903 42.4075 -121.6196 117.0830 -191.0690 14.1719 48.3622 -182.3475 85.9290 -357.0178 -12.0749 -28.3122 34.7022 70.1568 -27.2038 4.8889 24.7141 -141.8162 61.1942 -313.1773 Computed determinant = 1: MATLAB det(A) = 1: gauss_inverse_test(): gauss_inverse() uses Gauss elimination to find the inverse of a matrix. Matrix A: 1 2 3 4 5 8 7 8 9 Computed inverse B: -1.5833 0.5000 0.0833 1.6667 -1.0000 0.3333 -0.2500 0.5000 -0.2500 MATLAB inverse B2 = inv(A): -1.5833 0.5000 0.0833 1.6667 -1.0000 0.3333 -0.2500 0.5000 -0.2500 Residual norm ||A*B-I|| = 2.56332e-15: Error norm ||B2-B|| = 4.51342e-16: Matrix A: 1.0000 10.9327 11.0927 -8.6365 0.7736 13.7030 150.8100 139.8624 -129.4812 10.5320 -17.1152 -188.1366 -176.4405 174.5266 -20.8668 -2.4145 -23.2045 -62.4099 34.2586 -22.4523 -8.6488 -94.8549 -93.9390 59.0490 30.3318 Computed inverse B: 1.0e+06 * 2.0204 -0.3872 -0.1956 0.0578 -0.0089 -0.1692 0.0324 0.0164 -0.0048 0.0007 -0.0147 0.0028 0.0014 -0.0004 0.0001 0.0009 -0.0002 -0.0001 0.0000 -0.0000 -0.0002 0.0000 0.0000 -0.0000 0.0000 MATLAB inverse B2 = inv(A): 1.0e+06 * 2.0204 -0.3872 -0.1956 0.0578 -0.0089 -0.1692 0.0324 0.0164 -0.0048 0.0007 -0.0147 0.0028 0.0014 -0.0004 0.0001 0.0009 -0.0002 -0.0001 0.0000 -0.0000 -0.0002 0.0000 0.0000 -0.0000 0.0000 Residual norm ||A*B-I|| = 8.34717e-10: Error norm ||B2-B|| = 0.000132005: gauss_plu_test(): gauss_plu() uses Gauss elimination to find the PLU factors of a matrix. Matrix A: 1 2 3 4 5 8 7 8 9 Permutation matrix P: 0 0 1 1 0 0 0 1 0 Unit lower triangular matrix L: 1.0000 0 0 0.1429 1.0000 0 0.5714 0.5000 1.0000 Upper triangular matrix U: 7.0000 8.0000 9.0000 0 0.8571 1.7143 0 0 2.0000 Residual norm ||A-P'*L*U|| = 0: Matrix A: 1.0000 -10.6158 23.5046 -6.1560 7.4808 -2.2558 24.9476 -54.9468 22.7731 -24.5239 11.1736 -129.5071 284.5854 -179.5827 152.6601 0.3256 2.0690 8.0270 -106.2413 -191.4906 15.4421 -163.0714 346.3910 114.3120 285.8680 Permutation matrix P: 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 Unit lower triangular matrix L: 1.0000 0 0 0 0 0.7236 1.0000 0 0 0 0.0211 -0.4784 1.0000 0 0 -0.1461 -0.0978 -0.0605 1.0000 0 0.0648 0.0048 0.0536 -0.7640 1.0000 Upper triangular matrix U: 15.4421 -163.0714 346.3910 114.3120 285.8680 0 -11.5124 33.9448 -262.2963 -54.1874 0 0 16.9619 -234.1250 -223.4392 0 0 0 -0.3339 -1.5769 0 0 0 0 -0.0010 Residual norm ||A-P'*L*U|| = 2.84806e-14: eros_test(): Normal end of execution 07-Jan-2022 19:16:33