From 9c30abbaf19bd1f4edf1bd1b7caffade00f94239 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Flori Date: Tue, 28 Oct 2014 06:09:15 -0700 Subject: [PATCH] Some doctests modifs to mitigate numerical noise. --- src/sage/matrix/matrix2.pyx | 12 ++++++------ src/sage/rings/complex_double.pyx | 4 ++-- src/sage/rings/polynomial/polynomial_element.pyx | 8 ++++---- src/sage/rings/polynomial/real_roots.pyx | 2 +- src/sage/stats/hmm/chmm.pyx | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index daad073af1c..00aea836939 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -4939,9 +4939,9 @@ cdef class Matrix(matrix1.Matrix): 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] + [13.348469228349... 0.0 0.0] + [ 0.0 -1.348469228349... 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...] @@ -5598,9 +5598,9 @@ 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] + [13.348469228349... 0.0 0.0] + [ 0.0 -1.348469228349... 0.0] + [ 0.0 0.0 0.0] sage: evectors = em[1]; sage: for i in range(3): ....: scale = evectors[i,0].sign() diff --git a/src/sage/rings/complex_double.pyx b/src/sage/rings/complex_double.pyx index 86f14ae0b7b..5164c088fd3 100644 --- a/src/sage/rings/complex_double.pyx +++ b/src/sage/rings/complex_double.pyx @@ -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:: diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 4115736683b..87bc62aa961 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -5357,8 +5357,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 + [6.586578339425543e-15, 9.252438285348772e-16, 9.984360324875084e-16] sage: f = i*x^3 + 2; f I*x^3 + 2.0 sage: f.roots() # abs tol 1e-14 @@ -5610,9 +5610,9 @@ cdef class Polynomial(CommutativeAlgebraElement): sage: R. = 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:: diff --git a/src/sage/rings/polynomial/real_roots.pyx b/src/sage/rings/polynomial/real_roots.pyx index edf1c14c1a8..aa6df969b3c 100644 --- a/src/sage/rings/polynomial/real_roots.pyx +++ b/src/sage/rings/polynomial/real_roots.pyx @@ -1573,7 +1573,7 @@ cdef class interval_bernstein_polynomial_float(interval_bernstein_polynomial): sage: bp2 sage: bp1, bp2, ok = bp.de_casteljau(ctx, 2/3) - sage: bp1 + sage: bp1 # rel tol 2e-16 sage: bp2 # rel tol 3e-15 diff --git a/src/sage/stats/hmm/chmm.pyx b/src/sage/stats/hmm/chmm.pyx index 5245128f221..f060cd24c4b 100644 --- a/src/sage/stats/hmm/chmm.pyx +++ b/src/sage/stats/hmm/chmm.pyx @@ -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]