Skip to content

Commit

Permalink
Trac #17238: Increase Precision in Failing Doctests
Browse files Browse the repository at this point in the history
Certain doctests may now fail due to precision issues. This is
apparently a consequence of #16858. For reference see

https://groups.google.com/forum/#!topic/sage-release/jdhuVBY7rLU

URL: http://trac.sagemath.org/17238
Reported by: strogdon
Ticket author(s): Steven Trogdon, Jean-Pierre Flori
Reviewer(s): Jeroen Demeyer
  • Loading branch information
Release Manager authored and vbraun committed Oct 29, 2014
2 parents ba493df + ec64d52 commit 3f8b3d0
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/doc/de/tutorial/tour_linalg.rst
Expand Up @@ -114,10 +114,10 @@ standardmässig die Körper ``RR`` oder ``CC`` verwendet, welche allerdings nich
alle der folgenden Berechnungen unterstützen::

sage: ARDF = matrix(RDF, [[1.2, 2], [2, 3]])
sage: ARDF.eigenvalues()
sage: ARDF.eigenvalues() # rel tol 8e-16
[-0.09317121994613098, 4.293171219946131]
sage: ACDF = matrix(CDF, [[1.2, I], [2, 3]])
sage: ACDF.eigenvectors_right() # rel tol 1e-15
sage: ACDF.eigenvectors_right() # rel tol 2e-15
[(0.8818456983293743 - 0.8209140653434135*I, [(0.7505608183809549, -0.616145932704589 + 0.2387941530333261*I)], 1),
(3.3181543016706256 + 0.8209140653434133*I, [(0.14559469829270957 + 0.3756690858502104*I, 0.9152458258662108)], 1)]

Expand Down
4 changes: 2 additions & 2 deletions src/doc/en/tutorial/tour_linalg.rst
Expand Up @@ -111,10 +111,10 @@ by default the matrix is defined over the ``RR`` or ``CC`` fields,
respectively, which do not support these computations for all the cases::

sage: ARDF = matrix(RDF, [[1.2, 2], [2, 3]])
sage: ARDF.eigenvalues()
sage: ARDF.eigenvalues() # rel tol 8e-16
[-0.09317121994613098, 4.293171219946131]
sage: ACDF = matrix(CDF, [[1.2, I], [2, 3]])
sage: ACDF.eigenvectors_right() # rel tol 1e-15
sage: ACDF.eigenvectors_right() # rel tol 2e-15
[(0.8818456983293743 - 0.8209140653434135*I, [(0.7505608183809549, -0.616145932704589 + 0.2387941530333261*I)], 1),
(3.3181543016706256 + 0.8209140653434133*I, [(0.14559469829270957 + 0.3756690858502104*I, 0.9152458258662108)], 1)]

Expand Down
4 changes: 2 additions & 2 deletions src/doc/fr/tutorial/tour_linalg.rst
Expand Up @@ -112,10 +112,10 @@ ce ne sont pas ``RDF`` ou ``CDF`` qui sont utilisés par défaut, mais ``RR`` et
``CC``, sur lesquels ces calculs ne sont pas implémentés dans tous les cas::

sage: ARDF = matrix(RDF, [[1.2, 2], [2, 3]])
sage: ARDF.eigenvalues()
sage: ARDF.eigenvalues() # rel tol 8e-16
[-0.09317121994613098, 4.293171219946131]
sage: ACDF = matrix(CDF, [[1.2, I], [2, 3]])
sage: ACDF.eigenvectors_right() # rel tol 1e-15
sage: ACDF.eigenvectors_right() # rel tol 2e-15
[(0.8818456983293743 - 0.8209140653434135*I, [(0.7505608183809549, -0.616145932704589 + 0.2387941530333261*I)], 1),
(3.3181543016706256 + 0.8209140653434133*I, [(0.14559469829270957 + 0.3756690858502104*I, 0.9152458258662108)], 1)]

Expand Down
4 changes: 2 additions & 2 deletions src/doc/ru/tutorial/tour_linalg.rst
Expand Up @@ -106,10 +106,10 @@ Sage может находить собственное число и собст
соответственно::

sage: ARDF = matrix(RDF, [[1.2, 2], [2, 3]])
sage: ARDF.eigenvalues()
sage: ARDF.eigenvalues() # rel tol 8e-16
[-0.09317121994613098, 4.293171219946131]
sage: ACDF = matrix(CDF, [[1.2, I], [2, 3]])
sage: ACDF.eigenvectors_right() # rel tol 1e-15
sage: ACDF.eigenvectors_right() # rel tol 2e-15
[(0.8818456983293743 - 0.8209140653434135*I, [(0.7505608183809549, -0.616145932704589 + 0.2387941530333261*I)], 1),
(3.3181543016706256 + 0.8209140653434133*I, [(0.14559469829270957 + 0.3756690858502104*I, 0.9152458258662108)], 1)]

Expand Down
18 changes: 9 additions & 9 deletions src/sage/matrix/matrix2.pyx
Expand Up @@ -4938,10 +4938,10 @@ cdef class Matrix(matrix1.Matrix):
consult numerical or symbolic matrix classes for other options

sage: em = A.change_ring(RDF).eigenmatrix_left()
sage: eigenvalues = em[0]; eigenvalues.dense_matrix().zero_at(2e-15)
[ 13.348469228349... 0.0 0.0]
[ 0.0 -1.348469228349... 0.0]
[ 0.0 0.0 0.0]
sage: eigenvalues = em[0]; eigenvalues.dense_matrix() # abs tol 1e-13
[13.348469228349522 0.0 0.0]
[ 0.0 -1.348469228349534 0.0]
[ 0.0 0.0 0.0]
sage: eigenvectors = em[1]; eigenvectors # not tested
[ 0.440242867... 0.567868371... 0.695493875...]
[ 0.897878732... 0.278434036... -0.341010658...]
Expand Down Expand Up @@ -5206,7 +5206,7 @@ cdef class Matrix(matrix1.Matrix):
consult numerical or symbolic matrix classes for other options

sage: em = B.change_ring(RDF).eigenmatrix_right()
sage: eigenvalues = em[0]; eigenvalues.dense_matrix() # abs tol 1e-13
sage: eigenvalues = em[0]; eigenvalues.dense_matrix() # abs tol 1e-13
[13.348469228349522 0.0 0.0]
[ 0.0 -1.348469228349534 0.0]
[ 0.0 0.0 0.0]
Expand Down Expand Up @@ -5597,10 +5597,10 @@ cdef class Matrix(matrix1.Matrix):

sage: A = matrix(QQ, 3, 3, range(9))
sage: em = A.change_ring(RDF).eigenmatrix_left()
sage: evalues = em[0]; evalues.dense_matrix().zero_at(2e-15)
[ 13.348469228349... 0.0 0.0]
[ 0.0 -1.348469228349... 0.0]
[ 0.0 0.0 0.0]
sage: evalues = em[0]; evalues.dense_matrix() # abs tol 1e-13
[13.348469228349522 0.0 0.0]
[ 0.0 -1.348469228349534 0.0]
[ 0.0 0.0 0.0]
sage: evectors = em[1];
sage: for i in range(3):
....: scale = evectors[i,0].sign()
Expand Down
8 changes: 4 additions & 4 deletions src/sage/matrix/matrix_double_dense.pyx
Expand Up @@ -1009,11 +1009,11 @@ cdef class Matrix_double_dense(matrix_dense.Matrix_dense):
sage: A.condition() > 1.6e16 or A.condition()
True
sage: A.singular_values(eps=None) # abs tol 2e-16
sage: A.singular_values(eps=None) # abs tol 5e-16
[1.7953720595619975, 0.38027524595503703, 0.04473854875218107, 0.0037223122378911614, 0.0002330890890217751, 1.116335748323284e-05, 4.082376110397296e-07, 1.1228610675717613e-08, 2.2519645713496478e-10, 3.1113486853814003e-12, 2.6500422260778388e-14, 9.87312834948426e-17]
sage: A.singular_values(eps='auto') # abs tol 2e-16
sage: A.singular_values(eps='auto') # abs tol 5e-16
[1.7953720595619975, 0.38027524595503703, 0.04473854875218107, 0.0037223122378911614, 0.0002330890890217751, 1.116335748323284e-05, 4.082376110397296e-07, 1.1228610675717613e-08, 2.2519645713496478e-10, 3.1113486853814003e-12, 2.6500422260778388e-14, 0.0]
sage: A.singular_values(eps=1e-4) # abs tol 2e-16
sage: A.singular_values(eps=1e-4) # abs tol 5e-16
[1.7953720595619975, 0.38027524595503703, 0.04473854875218107, 0.0037223122378911614, 0.0002330890890217751, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
With Sage's "verbose" facility, you can compactly see the cutoff
Expand Down Expand Up @@ -1135,7 +1135,7 @@ cdef class Matrix_double_dense(matrix_dense.Matrix_dense):
[ 0.0 1.0 2.0 3.0]
[ 8.0 9.0 10.0 11.0]
[ 4.0 5.0 6.0 7.0]
sage: L*U
sage: L*U # rel tol 2e-16
[12.0 13.0 14.0 15.0]
[ 0.0 1.0 2.0 3.0]
[ 8.0 9.0 10.0 11.0]
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/complex_double.pyx
Expand Up @@ -1629,8 +1629,8 @@ cdef class ComplexDoubleElement(FieldElement):
sage: a = CDF(1,1); b = CDF(2,3)
sage: c = a^b; c # indirect doctest
-0.163450932107355 + 0.09600498360894891*I
sage: c^(1/b)
1.0000000000000002 + 1.0*I
sage: c^(1/b) # rel tol 2e-16
1.0 + 1.0*I
We compute the cube root of `-1` then cube it and observe a
rounding error::
Expand Down
8 changes: 4 additions & 4 deletions src/sage/rings/polynomial/polynomial_element.pyx
Expand Up @@ -5361,8 +5361,8 @@ cdef class Polynomial(CommutativeAlgebraElement):
[(-1.0911236359717227 - 0.6299605249474374*I, 1), (3.885780586188048e-16 + 1.2599210498948734*I, 1), (1.0911236359717211 - 0.6299605249474363*I, 1)]
sage: f.roots(multiplicities=False) # abs tol 1e-14
[-1.0911236359717227 - 0.6299605249474374*I, 3.885780586188048e-16 + 1.2599210498948734*I, 1.0911236359717211 - 0.6299605249474363*I]
sage: [f(z) for z in f.roots(multiplicities=False)] # abs tol 1e-12
[1.3704315460216776e-15 + 3.3306690738754696e-15*I, 5.287107591627866e-16 + 1.9984014443252818e-15*I, 2.0616104309811867e-16 + 1.7763568394002505e-15*I]
sage: [abs(f(z)) for z in f.roots(multiplicities=False)] # abs tol 1e-14
[8.95090418262362e-16, 8.728374398092689e-16, 1.0235750533041806e-15]
sage: f = i*x^3 + 2; f
I*x^3 + 2.0
sage: f.roots() # abs tol 1e-14
Expand Down Expand Up @@ -5614,9 +5614,9 @@ cdef class Polynomial(CommutativeAlgebraElement):
sage: R.<u> = QQ[]
sage: g = -27*u^14 - 32*u^9
sage: g.roots(CDF, multiplicities=False) # abs tol 1e-15
sage: g.roots(CDF, multiplicities=False) # abs tol 2e-15
[-1.0345637159435719, 0.0, -0.3196977699902601 - 0.9839285635706636*I, -0.3196977699902601 + 0.9839285635706636*I, 0.8369796279620465 - 0.6081012947885318*I, 0.8369796279620465 + 0.6081012947885318*I]
sage: g.roots(CDF) # abs tol 1e-15
sage: g.roots(CDF) # abs tol 2e-15
[(-1.0345637159435719, 1), (0.0, 9), (-0.3196977699902601 - 0.9839285635706636*I, 1), (-0.3196977699902601 + 0.9839285635706636*I, 1), (0.8369796279620465 - 0.6081012947885318*I, 1), (0.8369796279620465 + 0.6081012947885318*I, 1)]
This shows that the issue at :trac:`2418` is fixed::
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/polynomial/real_roots.pyx
Expand Up @@ -1573,7 +1573,7 @@ cdef class interval_bernstein_polynomial_float(interval_bernstein_polynomial):
sage: bp2
<IBP: (-0.369375, -0.45125, -0.3275, 0.14500000000000002, 0.99) + [-0.1 .. 0.01] over [1/2 .. 1]>
sage: bp1, bp2, ok = bp.de_casteljau(ctx, 2/3)
sage: bp1
sage: bp1 # rel tol 2e-16
<IBP: (0.5, 0.30000000000000004, -0.2555555555555555, -0.5444444444444444, -0.32172839506172846) + [-0.1 .. 0.01] over [0 .. 2/3]>
sage: bp2 # rel tol 3e-15
<IBP: (-0.32172839506172846, -0.21037037037037046, 0.028888888888888797, 0.4266666666666666, 0.99) + [-0.1 .. 0.01] over [2/3 .. 1]>
Expand Down
2 changes: 1 addition & 1 deletion src/sage/stats/hmm/chmm.pyx
Expand Up @@ -1337,7 +1337,7 @@ cdef class GaussianMixtureHiddenMarkovModel(GaussianHiddenMarkovModel):
(2.18905068682..., 15)
sage: m.log_likelihood(v)
2.18905068682...
sage: m # rel tol 3e-14
sage: m # rel tol 6e-14
Gaussian Mixture Hidden Markov Model with 2 States
Transition matrix:
[ 0.8746363339773399 0.12536366602266016]
Expand Down
2 changes: 1 addition & 1 deletion src/sage/tests/french_book/mpoly.py
Expand Up @@ -361,7 +361,7 @@
Sage example in ./mpoly.tex, line 1119 (edited manually)::
sage: ys = CDF['y'](Jy.0).roots(); ys
sage: ys = CDF['y'](Jy.0).roots(); ys # abs tol 3e-16
[(-0.8000000000000002, 1), (0.0, 1), (0.8, 1)]
sage: [CDF['x'](p(y=ys[0][0])).roots() for p in J.gens()] # abs tol 1e-14
[[(-0.5999999999999999 - 1.306289919090511e-16*I, 1), (0.6000000000000001 + 1.3062899190905113e-16*I, 1)], [(0.6000000000000001 - 3.135095805817224e-16*I, 1), (2.600000000000001 + 3.1350958058172237e-16*I, 1)]]
Expand Down

0 comments on commit 3f8b3d0

Please sign in to comment.