From 71ac8a788f502bc78dd10b4760e41618c2238b91 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 18 Sep 2024 14:25:56 -0400 Subject: [PATCH 1/3] src/sage/matrix/matrix_double_dense.pyx: loosen two test tolerances Change 1r-14 to 5e-14 in the following two examples. This is likely required because expm() in scipy was rewritten in C. Example 1: File "src/sage/matrix/matrix_double_dense.pyx", line 3666, in sage.matrix.matrix_double_dense.Matrix_double_dense.exp Failed example: A.exp() # tol 1e-14 Expected: [51.968956198705044 74.73656456700327] [112.10484685050491 164.07380304920997] Got: [51.968956198707595 74.736564567007] [112.10484685051048 164.07380304921807] Tolerance exceeded in 4 of 4: 51.968956198705044 vs 51.968956198707595, tolerance 5e-14 > 1e-14 74.73656456700327 vs 74.736564567007, tolerance 5e-14 > 1e-14 112.10484685050491 vs 112.10484685051048, tolerance 5e-14 > 1e-14 164.07380304920997 vs 164.07380304921807, tolerance 5e-14 > 1e-14 Example 2: File "src/sage/matrix/matrix_double_dense.pyx", line 3679, in sage.matrix.matrix_double_dense.Matrix_double_dense.exp Failed example: A.exp() # tol 1e-14 Expected: [51.968956198705044 74.73656456700327] [112.10484685050491 164.07380304920997] Got: [51.968956198707595 74.736564567007] [112.10484685051048 164.07380304921807] Tolerance exceeded in 4 of 4: 51.968956198705044 vs 51.968956198707595, tolerance 5e-14 > 1e-14 74.73656456700327 vs 74.736564567007, tolerance 5e-14 > 1e-14 112.10484685050491 vs 112.10484685051048, tolerance 5e-14 > 1e-14 164.07380304920997 vs 164.07380304921807, tolerance 5e-14 > 1e-14 --- src/sage/matrix/matrix_double_dense.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/matrix/matrix_double_dense.pyx b/src/sage/matrix/matrix_double_dense.pyx index fa3f391194a..b5158d4deb2 100644 --- a/src/sage/matrix/matrix_double_dense.pyx +++ b/src/sage/matrix/matrix_double_dense.pyx @@ -3663,7 +3663,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): sage: A = matrix(RDF, 2, [1,2,3,4]); A [1.0 2.0] [3.0 4.0] - sage: A.exp() # tol 1e-14 + sage: A.exp() # tol 5e-14 [51.968956198705044 74.73656456700327] [112.10484685050491 164.07380304920997] sage: A = matrix(CDF, 2, [1,2+I,3*I,4]); A # needs sage.symbolic @@ -3676,7 +3676,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): TESTS:: sage: A = matrix(RDF, 2, [1,2,3,4]) - sage: A.exp() # tol 1e-14 + sage: A.exp() # tol 5e-14 [51.968956198705044 74.73656456700327] [112.10484685050491 164.07380304920997] From 13969c334e85204a159fcd3ef52baa89ea42b968 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 18 Sep 2024 14:28:03 -0400 Subject: [PATCH 2/3] src/sage/matrix/matrix2.pyx: loosen a test tolerance Change 1e-14 to 6e-14 in the following example. This is likely necessary because expm() in scipy was rewritten in C. File "src/sage/matrix/matrix2.pyx", line 15903, in sage.matrix.matrix2.Matrix.exp Failed example: a.change_ring(RDF).exp() # rel tol 1e-14 Expected: [42748127.31532951 7368259.244159399] [234538976.1381042 40426191.45156228] Got: [ 42748127.31533201 7368259.244159831] [234538976.13811788 40426191.45156465] Tolerance exceeded in 4 of 4: 42748127.31532951 vs 42748127.31533201, tolerance 6e-14 > 1e-14 7368259.244159399 vs 7368259.244159831, tolerance 6e-14 > 1e-14 234538976.1381042 vs 234538976.13811788, tolerance 6e-14 > 1e-14 40426191.45156228 vs 40426191.45156465, tolerance 6e-14 > 1e-14 --- src/sage/matrix/matrix2.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index f5f0eac7ea8..d0c1550aa1f 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -15900,7 +15900,7 @@ cdef class Matrix(Matrix1): sage: a.exp() # needs sage.symbolic [ 1/11882424341266*((11*sqrt(227345670387496707609) + 5941212170633)*e^(3/1275529100*sqrt(227345670387496707609)) - 11*sqrt(227345670387496707609) + 5941212170633)*e^(-3/2551058200*sqrt(227345670387496707609) + 101/200) 445243650/75781890129165569203*(sqrt(227345670387496707609)*e^(3/1275529100*sqrt(227345670387496707609)) - sqrt(227345670387496707609))*e^(-3/2551058200*sqrt(227345670387496707609) + 101/200)] [ 10000/53470909535697*(sqrt(227345670387496707609)*e^(3/1275529100*sqrt(227345670387496707609)) - sqrt(227345670387496707609))*e^(-3/2551058200*sqrt(227345670387496707609) + 101/200) -1/11882424341266*((11*sqrt(227345670387496707609) - 5941212170633)*e^(3/1275529100*sqrt(227345670387496707609)) - 11*sqrt(227345670387496707609) - 5941212170633)*e^(-3/2551058200*sqrt(227345670387496707609) + 101/200)] - sage: a.change_ring(RDF).exp() # rel tol 1e-14 # needs sage.symbolic + sage: a.change_ring(RDF).exp() # rel tol 6e-14 # needs sage.symbolic [42748127.31532951 7368259.244159399] [234538976.1381042 40426191.45156228] From 4a9647306cd428b04259a2ac01a5a2384d1b1be6 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 18 Sep 2024 14:18:30 -0400 Subject: [PATCH 3/3] src/sage/symbolic/constants_c_impl.pxi: loosen a test tolerance In the following example, we now use 5e-14 instead of 1e-14. This is likely due to scipy's expm() being rewritten in C: File "src/sage/symbolic/constants_c_impl.pxi", line 162, in sage.symbolic.constants_c_impl.pxi.E.__pow__ Failed example: e^A # rel tol 1e-14 Expected: [51.968956198705044 74.73656456700327] [112.10484685050491 164.07380304920997] Got: [51.968956198707595 74.736564567007] [112.10484685051048 164.07380304921807] Tolerance exceeded in 4 of 4: 51.968956198705044 vs 51.968956198707595, tolerance 5e-14 > 1e-14 74.73656456700327 vs 74.736564567007, tolerance 5e-14 > 1e-14 112.10484685050491 vs 112.10484685051048, tolerance 5e-14 > 1e-14 164.07380304920997 vs 164.07380304921807, tolerance 5e-14 > 1e-14 --- src/sage/symbolic/constants_c_impl.pxi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/symbolic/constants_c_impl.pxi b/src/sage/symbolic/constants_c_impl.pxi index 63a90c71fd9..0ebd28e8aa3 100644 --- a/src/sage/symbolic/constants_c_impl.pxi +++ b/src/sage/symbolic/constants_c_impl.pxi @@ -159,7 +159,7 @@ cdef class E(Expression): [e 0] [0 e] sage: A = matrix(RDF, [[1,2],[3,4]]) - sage: e^A # rel tol 1e-14 + sage: e^A # rel tol 5e-14 [51.968956198705044 74.73656456700327] [112.10484685050491 164.07380304920997] """