Changeset 7516:b16ab227cdad
- Timestamp:
- 12/02/07 14:03:01 (6 years ago)
- Branch:
- default
- Location:
- sage
- Files:
-
- 3 edited
-
calculus/calculus.py (modified) (1 diff)
-
rings/polynomial/complex_roots.py (modified) (1 diff)
-
rings/polynomial/polynomial_element.pyx (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sage/calculus/calculus.py
r7512 r7516 1972 1972 Computing to higher precision we see the truth: 1973 1973 sage: f.n(200) 1974 - 0.000000000000749927402801814311120646143666223486520788951365335933557181974 -7.4992740280181431112064614366622348652078895136533593355718e-13 1975 1975 sage: f.n(300) 1976 - 0.0000000000007499274028018143111206461436626630091372924625896217893520950661817090955756819639671030041976 -7.49927402801814311120646143662663009137292462589621789352095066181709095575681963967103004e-13 1977 1977 1978 1978 Now numerically integrating, we see why the answer is wrong: -
sage/rings/polynomial/complex_roots.py
r7504 r7516 287 287 (-1)*x^4 + (im - 1)*x^3 + im*x^2 + (-im - 1)*x + 1 288 288 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)]) 290 290 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)]) 292 292 sage: rts = complex_roots(p, retval='algebraic_real'); type(rts[0][0]), rts 293 293 (<class 'sage.rings.qqbar.AlgebraicReal'>, [([-1.6180339887498950 .. -1.6180339887498946], 1), ([0.61803398874989479 .. 0.61803398874989491], 1)]) -
sage/rings/polynomial/polynomial_element.pyx
r7514 r7516 2631 2631 sage: p = (x - rts[1][0])^2 * (x^2 + x + 1) 2632 2632 sage: p.roots(ring=QQbar) 2633 [([-0.50000000000000012 .. -0.49999999999999994] + [0.86602540378443859 .. 0.86602540378443871]*I, 1), ([-0.500000000000000 00 .. -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)] 2634 2634 sage: p.roots(ring=CIF) 2635 [([-0.50000000000000 012 .. -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)] 2636 2636 2637 2637 Note that coefficients in a number field with defining polynomial … … 2646 2646 sage: p = p^2 * (y^2 - 2) 2647 2647 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.141425052582393 99 .. -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)] 2649 2649 2650 2650 There are many combinations of floating-point input and output
Note: See TracChangeset
for help on using the changeset viewer.
