Tue May 20 21:35:43 2025 eros_test(): python version: 3.10.12 numpy version: 1.26.4 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. 11.92219834 -21.35642785] [ -6.86389643 -80.83273466 157.01675805] [ -2.36689199 -15.08260372 188.53596669]] Exact solution x: [[ 2. 10. ] [ 1. 1.5] [ 3. -2. ]] Right hand side b: [[ -50.1470852 70.59615321] [ 376.48974663 -503.92158239] [ 545.79151237 -423.36475888]] Augmented matrix Ab, step 0 [[ 1. 11.92219834 -21.35642785 -50.1470852 70.59615321] [ -6.86389643 -80.83273466 157.01675805 376.48974663 -503.92158239] [ -2.36689199 -15.08260372 188.53596669 545.79151237 -423.36475888]] Augmented matrix Ab, after step 0 [[ 1.00000000e+00 1.17765085e+01 -2.28757470e+01 -5.48507324e+01 7.34162567e+01] [ 0.00000000e+00 1.45689844e-01 1.51931913e+00 4.70364724e+00 -2.82010350e+00] [ 0.00000000e+00 1.27911200e+01 1.34391544e+02 4.15965753e+02 -2.49596409e+02]] Augmented matrix Ab, after step 1 [[ 1.00000000e+00 0.00000000e+00 -1.46607146e+02 -4.37821437e+02 3.03214292e+02] [ 0.00000000e+00 1.00000000e+00 1.05066284e+01 3.25198852e+01 -1.95132568e+01] [ 0.00000000e+00 0.00000000e+00 -1.13899209e-02 -3.41697626e-02 2.27798417e-02]] 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. 3.85700384 -3.5724414 -6.50559357 5.25975529] [ -19.20831537 -73.08654611 78.27763146 125.15097531 -102.99516678] [ 13.08087127 54.61823007 -5.50652673 -93.54335708 59.93510554] [ -7.4142013 -15.55239487 156.6378719 13.08520409 -61.84841436] [ -2.20411027 -6.79393676 17.78957877 69.60780161 -41.80570277]] Computed determinant = 0.9999999999953871 np.lingalg.det(A) = 0.9999999999941664 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. 9.6129623 -10.7093957 -16.48396196 3.66455576] [ -4.8398292 -45.5250956 41.39681365 90.42184446 -23.7731996 ] [ -1.81920895 3.16311834 -195.00819322 247.04529911 -125.9702184 ] [ 3.33175309 36.7537754 -85.18988137 -3.09414284 -19.28783714] [ 3.62249769 33.23229532 -5.51765711 -110.61198199 91.83195558]] Computed inverse B: [[ 4.06160394e+05 8.38845477e+04 -3.54809213e+03 -2.18657962e+03 1.81618182e+02] [-3.67688045e+04 -7.59081642e+03 3.20232577e+02 2.01637535e+02 -1.62006779e+01] [-6.14881765e+02 -1.25759254e+02 4.98023572e+00 4.78693946e+00 -1.82291997e-01] [ 4.07617977e+03 8.42907184e+02 -3.59338782e+01 -2.06936933e+01 1.91085550e+00] [ 2.15696482e+03 4.45709886e+02 -1.89078657e+01 -1.13528696e+01 1.00000000e+00]] numpy linalg inverse: B2 = np.linalg.inv(A): [[ 4.06160394e+05 8.38845477e+04 -3.54809213e+03 -2.18657962e+03 1.81618182e+02] [-3.67688045e+04 -7.59081642e+03 3.20232577e+02 2.01637535e+02 -1.62006779e+01] [-6.14881765e+02 -1.25759254e+02 4.98023572e+00 4.78693946e+00 -1.82291997e-01] [ 4.07617977e+03 8.42907184e+02 -3.59338782e+01 -2.06936933e+01 1.91085550e+00] [ 2.15696482e+03 4.45709886e+02 -1.89078657e+01 -1.13528696e+01 1.00000000e+00]] Residual norm |A*B-I| = 2.0805241385276654e-10 Error norm |B2-B| = 3.7275117260438e-06 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.00000000e+00 1.16258366e+01 7.53434015e+00 -2.53905600e-01 -5.35233320e+00] [-1.48844567e+01 -1.72044262e+02 -9.60004779e+01 3.32181786e+00 7.62870650e+01] [-2.42079760e+00 -3.32033218e+01 -9.89204909e+01 -9.16555982e-01 1.77764687e+01] [ 4.10743164e+00 2.98828207e+01 -2.77700637e+02 8.56604594e+01 2.75820156e+02] [-1.33793521e+01 -1.53316275e+02 -6.24817550e+01 6.03603453e+00 -9.11629120e+01]] Permutation matrix P: [[1. 0. 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. ] [-14.88445672 1. 0. 0. 0. ] [ -2.4207976 1. 1. 0. 0. ] [ 4.10743164 3.53185531 0. 1. 0. ] [-13.37935213 -0.44073047 0. 0. 1. ]] Upper triangular matrix U: [[ 1.00000000e+00 1.16258366e+01 7.53434015e+00 -2.53905600e-01 -5.35233320e+00] [ 0.00000000e+00 -5.05952448e+00 -8.06813783e+01 -1.53121005e+00 4.81955333e+00] [ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00] [ 0.00000000e+00 0.00000000e+00 -2.36924699e+01 9.21113716e+01 2.80782533e+02] [ 0.00000000e+00 0.00000000e+00 2.76409327e+00 1.96409118e+00 -1.60649539e+02]] Residual norm |A-P*L*U| = 348.0444292991318 golub_matrix_test(): golub_matrix() evaluates a random Golub matrix of order N. The Golub matrix: [[ 1. 4.86530271 -0.87780425 1.60935562 -4.91656983] [ -14.81904411 -71.09913555 9.79403928 -32.2300236 68.64518509] [ -5.4891665 -20.86969504 -12.94199229 -71.63015496 -6.22781995] [ 2.63612459 11.30974097 4.51595468 -9.226807 -42.46001703] [ -20.6513423 -118.89305945 73.30382202 193.24147817 -94.68651407]] 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 Tue May 20 21:35:43 2025