Thu Sep 15 10:16:54 2022 eros_test(): Python version: 3.6.9 Test eros(). gauss_test1(): gauss() solves a 3x3 linear system with one right hand side. Matrix A: [[ 2. -1. 0.] [-1. 2. -1.] [ 0. -1. 2.]] Exact solution x: [[2.] [1.] [3.]] Right hand side b: [[ 3.] [-3.] [ 5.]] Augmented matrix Ab, step 0 [[ 2. -1. 0. 3.] [-1. 2. -1. -3.] [ 0. -1. 2. 5.]] Augmented matrix Ab, after step 0 [[ 1. -0.5 0. 1.5] [ 0. 1.5 -1. -1.5] [ 0. -1. 2. 5. ]] Augmented matrix Ab, after step 1 [[ 1. 0. -0.33333333 1. ] [ 0. 1. -0.66666667 -1. ] [ 0. 0. 1.33333333 4. ]] Augmented matrix Ab, after step 2 [[1. 0. 0. 2.] [0. 1. 0. 1.] [0. 0. 1. 3.]] Computed solution x [[2.] [1.] [3.]] gauss_test2(): gauss() solves a 3x3 linear system with two right hand sides. Random matrix A: [[ 1. 3.55742499 -8.23940557] [-12.72913704 -44.28295021 103.21038994] [-18.70442853 -62.47767898 148.32942302]] Exact solution x: [[ 2. 10. ] [ 1. 1.5] [ 3. -2. ]] Right hand side b: [[ -19.16079173 31.81494863] [ 239.88994554 -400.13657558] [ 345.10173303 -577.41964982]] Augmented matrix Ab, step 0 [[ 1. 3.55742499 -8.23940557 -19.16079173 31.81494863] [ -12.72913704 -44.28295021 103.21038994 239.88994554 -400.13657558] [ -18.70442853 -62.47767898 148.32942302 345.10173303 -577.41964982]] Augmented matrix Ab, after step 0 [[ 1. 3.34026131 -7.93017668 -18.45026874 30.87074534] [ 0. -1.76430623 2.2660842 5.03394636 -7.17862774] [ 0. 0.21716368 -0.30922889 -0.71052299 0.9442033 ]] Augmented matrix Ab, after step 1 [[ 1. 0. -3.6399275 -8.91978251 17.27985501] [-0. 1. -1.28440525 -2.85321576 4.06881051] [ 0. 0. -0.03030272 -0.09090815 0.06060544]] Augmented matrix Ab, after step 2 [[ 1. 0. 0. 2. 10. ] [-0. 1. 0. 1. 1.5] [-0. -0. 1. 3. -2. ]] Computed solution x [[ 2. 10. ] [ 1. 1.5] [ 3. -2. ]] 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.661338147750939e-16 np.lingalg.det(A) = 0.0 Matrix A: [[ 1.00000000e+00 -3.44650963e-01 2.12370502e+01 8.26749024e+00 5.82820240e+00] [-1.83309061e+01 7.31776445e+00 -3.83066896e+02 -1.59875369e+02 -8.97552282e+01] [ 3.32319667e+00 -2.49682281e+00 6.31585827e+01 3.11231850e+01 -2.09667518e+01] [-2.25295861e+01 -1.10546154e+01 -6.08789270e+02 7.12166626e+01 -2.30726488e+02] [-1.58444841e+01 7.04463453e+00 -3.14539070e+02 -2.33036177e+02 -2.86332207e+02]] Computed determinant = 1.0000000004778558 np.lingalg.det(A) = 1.00000000043525 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.58333333 0.5 0.08333333] [ 1.66666667 -1. 0.33333333] [-0.25 0.5 -0.25 ]] np.linalg.inv B2 = inv(A): [[-1.58333333 0.5 0.08333333] [ 1.66666667 -1. 0.33333333] [-0.25 0.5 -0.25 ]] Residual norm |A*B-I| = 1.9860273225978185e-15 Error norm |B2-B| = 4.912423251631731e-16 Matrix A: [[ 1. -0.72925405 6.46282218 12.50201085 11.42402528] [ 2.66977417 -0.94694361 10.35863085 23.62081497 26.25690518] [ 2.65222491 -4.858728 38.30773847 64.12910732 51.24776513] [ 2.43533665 3.20243784 -27.9846103 -40.01678752 -87.9456469 ] [ 5.84419882 -4.81826164 46.18653862 84.78523867 179.38161922]] Computed inverse B: [[ 9.16725309e+03 -2.30320787e+03 -9.80047767e+02 -1.15556034e+02 -2.33536342e+01] [ 6.06478757e+04 -1.52324197e+04 -6.48499124e+03 -7.67184115e+02 -1.56180221e+02] [ 1.70033512e+04 -4.27121064e+03 -1.81797677e+03 -2.14907592e+02 -4.36548715e+01] [-5.63362000e+03 1.41535845e+03 6.02309918e+02 7.11399174e+01 1.44111395e+01] [-3.84855688e+02 9.66517797e+01 4.11428642e+01 4.86706255e+00 1.00000000e+00]] MATLAB inverse B2 = inv(A): [[ 9.16725309e+03 -2.30320787e+03 -9.80047767e+02 -1.15556034e+02 -2.33536342e+01] [ 6.06478757e+04 -1.52324197e+04 -6.48499124e+03 -7.67184115e+02 -1.56180221e+02] [ 1.70033512e+04 -4.27121064e+03 -1.81797677e+03 -2.14907592e+02 -4.36548715e+01] [-5.63362000e+03 1.41535845e+03 6.02309918e+02 7.11399174e+01 1.44111395e+01] [-3.84855688e+02 9.66517797e+01 4.11428642e+01 4.86706255e+00 1.00000000e+00]] Residual norm |A*B-I| = 8.856291439376151e-11 Error norm |B2-B| = 1.8131079111473536e-07 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. 1. 0.] [0. 1. 0.] [0. 0. 1.]] Unit lower triangular matrix L: [[1. 0. 0. ] [1. 1. 0. ] [1.75 0. 1. ]] Upper triangular matrix U: [[ 4 5 8] [ 4 5 8] [ 0 0 -5]] Residual norm |A-P*L*U| = 20.846162716432968 Matrix A: [[ 1. -2.42904358 -16.45676112 1.44179072 -9.13742413] [ 5.72898014 -12.9159424 -92.90646004 7.01914098 -79.39539182] [ -11.08581656 25.42014345 181.36493785 -23.32684421 154.57853937] [ -8.71361533 37.50178053 161.22552443 10.71836457 -425.17943612] [ 3.28055604 -12.5489854 -63.63064318 50.89727046 2.79862555]] Permutation matrix P: [[0. 1. 0. 0. 0.] [0. 0. 1. 0. 0.] [0. 0. 1. 0. 0.] [0. 0. 0. 1. 0.] [0. 0. 0. 0. 1.]] Unit lower triangular matrix L: [[ 1. 0. 0. 0. 0. ] [ 1. 1. 0. 0. 0. ] [ -1.93504189 1. 1. 0. 0. ] [ -1.52097147 41.79482694 0. 1. 0. ] [ 0.57262479 -12.06073773 0. 0. 1. ]] Upper triangular matrix U: [[ 5.72898014e+00 -1.29159424e+01 -9.29064600e+01 7.01914098e+00 -7.93953918e+01] [ 0.00000000e+00 4.27253848e-01 1.58704574e+00 -9.74451237e+00 9.45130254e-01] [ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00] [ 0.00000000e+00 0.00000000e+00 -4.64128526e+01 4.28664486e+02 -5.85439117e+02] [ 0.00000000e+00 0.00000000e+00 8.71084131e+00 -7.06480716e+01 5.96613631e+01]] Residual norm |A-P*L*U| = 122.69144913308502 golub_matrix_test(): golub_matrix() evaluates a random Golub matrix of order N. The Golub matrix: [[ 1.00000000e+00 5.18306198e+00 -4.10107914e-01 -1.75011081e+01 1.28080671e+01] [ 2.38067200e+01 1.24391705e+02 -4.99267988e+00 -4.11251092e+02 2.93647477e+02] [ 4.16009151e+00 2.58513805e+01 1.97569647e+01 -5.10481445e+01 -1.91007616e-01] [ 1.47851516e+01 6.99040160e+01 -3.65804811e+01 -2.96214809e+02 2.52560183e+02] [ 5.11238128e+00 1.16212740e+01 -4.95137479e+01 -2.02891044e+02 1.17068163e+02]] ref_test(): ref computes the row echelon form of a matrix. Matrix A: [[ 1. 3. 0. 2. 6. 3. 1.] [-2. -6. 0. -2. -8. 3. 1.] [ 3. 9. 0. 0. 6. 6. 2.] [-1. -3. 0. 1. 0. 9. 3.]] Pseudo-determinat = 48.0 REF(A): [[1. 3. 0. 2. 6. 3. 1. ] [0. 0. 0. 1. 2. 4.5 1.5 ] [0. 0. 0. 0. 0. 1. 0.33333333] [0. 0. 0. 0. 0. 0. 0. ]] rref_test(): rref computes the reduced row echelon form of a matrix. Matrix A: [[ 1. 3. 0. 2. 6. 3. 1.] [-2. -6. 0. -2. -8. 3. 1.] [ 3. 9. 0. 0. 6. 6. 2.] [-1. -3. 0. 1. 0. 9. 3.]] Pseudo-determinant = 48.0 RREF(A): [[1. 3. 0. 0. 2. 0. 0. ] [0. 0. 0. 1. 2. 0. 0. ] [0. 0. 0. 0. 0. 1. 0.33333333] [0. 0. 0. 0. 0. 0. 0. ]] eros_test(): Normal end of execution Thu Sep 15 10:16:55 2022