Changeset 7516:b16ab227cdad


Ignore:
Timestamp:
12/02/07 14:03:01 (6 years ago)
Author:
mabshoff@…
Branch:
default
Message:

Fix numerical doctest failures (#1376)

Location:
sage
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sage/calculus/calculus.py

    r7512 r7516  
    19721972        Computing to higher precision we see the truth: 
    19731973            sage: f.n(200) 
    1974             -0.00000000000074992740280181431112064614366622348652078895136533593355718 
     1974            -7.4992740280181431112064614366622348652078895136533593355718e-13 
    19751975            sage: f.n(300) 
    1976             -0.000000000000749927402801814311120646143662663009137292462589621789352095066181709095575681963967103004 
     1976            -7.49927402801814311120646143662663009137292462589621789352095066181709095575681963967103004e-13 
    19771977 
    19781978        Now numerically integrating, we see why the answer is wrong: 
  • sage/rings/polynomial/complex_roots.py

    r7504 r7516  
    287287        (-1)*x^4 + (im - 1)*x^3 + im*x^2 + (-im - 1)*x + 1 
    288288        sage: rts = complex_roots(p); type(rts[0][0]), rts 
    289         (<type 'sage.rings.complex_interval.ComplexIntervalFieldElement'>, [([-0.000000000000000085405681994008930 .. 0.00000000000000018852810564551411] + [1.6180339887498944 .. 1.6180339887498952]*I, 1), ([-1.6180339887498952 .. -1.6180339887498944] + [-0.00000000000000018852810564551411 .. 0.000000000000000085405681994008930]*I, 1), ([0.61803398874989468 .. 0.61803398874989502] + [-0.00000000000000011497311295586537 .. 0.000000000000000052767663576832497]*I, 1), ([-0.000000000000000054022849329007172 .. 0.00000000000000011371792720369062] - [0.61803398874989468 .. 0.61803398874989502]*I, 1)]) 
     289        (<type 'sage.rings.complex_interval.ComplexIntervalFieldElement'>, [([-2.8836212165089293e-16 .. 4.7404441675278100e-17] + [1.6180339887498946 .. 1.6180339887498952]*I, 1), ([-1.6180339887498952 .. -1.6180339887498944] + [-1.8852810564551411e-16 .. 8.5405681994008930e-17]*I, 1), ([0.61803398874989468 .. 0.61803398874989502] + [-1.1236596864560003e-16 .. 5.5374807887097754e-17]*I, 1), ([-5.4022849329007172e-17 .. 1.1371792720369062e-16] - [0.61803398874989468 .. 0.61803398874989502]*I, 1)]) 
    290290        sage: rts = complex_roots(p, retval='algebraic'); type(rts[0][0]), rts 
    291         (<class 'sage.rings.qqbar.AlgebraicNumber'>, [([-3.7249532943328317e-20 .. 3.7095114777437122e-20] + [1.6180339887498946 .. 1.6180339887498950]*I, 1), ([-1.6180339887498950 .. -1.6180339887498946] + [-3.7095114777437122e-20 .. 3.7249532943328317e-20]*I, 1), ([0.61803398874989479 .. 0.61803398874989491] + [-1.8145161579843782e-20 .. 3.1750950176743468e-20]*I, 1), ([-2.5399597786669076e-20 .. 2.0313092838036301e-20] - [0.61803398874989479 .. 0.61803398874989491]*I, 1)]) 
     291        (<class 'sage.rings.qqbar.AlgebraicNumber'>, [([-2.5297186544008181e-20 .. 4.5178375837717923e-20] + [1.6180339887498946 .. 1.6180339887498950]*I, 1), ([-1.6180339887498950 .. -1.6180339887498946] + [-3.7095114777437122e-20 .. 3.7249532943328317e-20]*I, 1), ([0.61803398874989479 .. 0.61803398874989491] + [-1.5445351834529870e-20 .. 3.2940467984864619e-20]*I, 1), ([-2.5399597786669076e-20 .. 2.0313092838036301e-20] - [0.61803398874989479 .. 0.61803398874989491]*I, 1)]) 
    292292        sage: rts = complex_roots(p, retval='algebraic_real'); type(rts[0][0]), rts 
    293293        (<class 'sage.rings.qqbar.AlgebraicReal'>, [([-1.6180339887498950 .. -1.6180339887498946], 1), ([0.61803398874989479 .. 0.61803398874989491], 1)]) 
  • sage/rings/polynomial/polynomial_element.pyx

    r7514 r7516  
    26312631            sage: p = (x - rts[1][0])^2 * (x^2 + x + 1) 
    26322632            sage: p.roots(ring=QQbar) 
    2633             [([-0.50000000000000012 .. -0.49999999999999994] + [0.86602540378443859 .. 0.86602540378443871]*I, 1), ([-0.50000000000000000 .. -0.50000000000000000] - [0.86602540378443859 .. 0.86602540378443871]*I, 1), ([0.18123244446987538 .. 0.18123244446987541] + [1.0839541013177105 .. 1.0839541013177108]*I, 2)] 
     2633            [([-0.50000000000000012 .. -0.49999999999999994] + [0.86602540378443859 .. 0.86602540378443871]*I, 1), ([-0.500000000000000... .. -0...] - [0.86602540378443859 .. 0.86602540378443871]*I, 1), ([0.18123244446987538 .. 0.18123244446987541] + [1.0839541013177105 .. 1.0839541013177108]*I, 2)] 
    26342634            sage: p.roots(ring=CIF) 
    2635             [([-0.50000000000000012 .. -0.49999999999999994] + [0.86602540378443859 .. 0.86602540378443871]*I, 1), ([-0.50000000000000000 .. -0.50000000000000000] - [0.86602540378443859 .. 0.86602540378443871]*I, 1), ([0.18123244446987538 .. 0.18123244446987541] + [1.0839541013177105 .. 1.0839541013177108]*I, 2)] 
     2635            [([-0.50000000000000... .. -0...] + [0.86602540378443859 .. 0.86602540378443871]*I, 1), ([-0.500000000000000... .. -0...] - [0.86602540378443859 .. 0.86602540378443871]*I, 1), ([0.18123244446987538 .. 0.18123244446987541] + [1.0839541013177105 .. 1.0839541013177108]*I, 2)] 
    26362636 
    26372637        Note that coefficients in a number field with defining polynomial 
     
    26462646            sage: p = p^2 * (y^2 - 2) 
    26472647            sage: p.roots(ring=CIF) 
    2648             [([-1.4142135623730952 .. -1.4142135623730949], 1), ([1.4142135623730949 .. 1.4142135623730952], 1), ([-1.2146389322441827 .. -1.2146389322441821] - [0.1414250525823937... .. 0.1414250525823939...]*I, 2), ([-0.14142505258239399 .. -0.14142505258239376] + [1.2146389322441821 .. 1.2146389322441827]*I, 2), ([0.14142505258239376 .. 0.14142505258239399] - [1.2146389322441821 .. 1.2146389322441827]*I, 2), ([1.2146389322441821 .. 1.2146389322441827] + [0.14142505258239376 .. 0.14142505258239399]*I, 2)] 
     2648            [([-1.4142135623730952 .. -1.4142135623730949], 1), ([1.4142135623730949 .. 1.4142135623730952], 1), ([-1.2146389322441827 .. -1.2146389322441821] - [0.1414250525823937... .. 0.1414250525823939...]*I, 2), ([-0.141425052582393... .. -0.14142505258239376] + [1.2146389322441821 .. 1.2146389322441827]*I, 2), ([0.141425052582393... .. 0.141425052582393...] - [1.2146389322441821 .. 1.2146389322441827]*I, 2), ([1.2146389322441821 .. 1.2146389322441827] + [0.14142505258239376 .. 0.14142505258239399]*I, 2)] 
    26492649 
    26502650        There are many combinations of floating-point input and output 
Note: See TracChangeset for help on using the changeset viewer.