Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Some doctests modifs to mitigate numerical noise.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Pierre Flori committed Oct 28, 2014
1 parent cad29f8 commit 9c30abb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions src/sage/matrix/matrix2.pyx
Expand Up @@ -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...]
Expand Down Expand Up @@ -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()
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 @@ -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
Expand Down Expand Up @@ -5610,9 +5610,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

0 comments on commit 9c30abb

Please sign in to comment.