#10042: Doctest failure in sage/rings/polynomial/polynomial_element.pyx
-----------------------+----------------------------------------------------
   Reporter:  mpatel   |       Owner:  mvngu     
       Type:  defect   |      Status:  needs_info
   Priority:  blocker  |   Milestone:  sage-4.6  
  Component:  doctest  |    Keywords:            
     Author:           |    Upstream:  N/A       
   Reviewer:           |      Merged:            
Work_issues:           |  
-----------------------+----------------------------------------------------

Comment(by kcrisman):

 Replying to [comment:10 zimmerma]:
 > Karl-Dieter, please could you isolate the problem (see instructions in
 comment 4)? In particular we need to know if the problem lies in NumPy
 itself, or in the RR<->NumPy conversion.
 >

 Like Dave, I don't have time to do much with this.  Apparently something
 goes 'wrong' in ?RealField, based on what I see here:
 {{{
 ----------------------------------------------------------------------
 | Sage Version 4.6.alpha2, Release Date: 2010-09-29                  |
 | Type notebook() for the GUI, and license() for information.        |
 ----------------------------------------------------------------------
 **********************************************************************
 *                                                                    *
 * Warning: this is a prerelease version, and it may be unstable.     *
 *                                                                    *
 **********************************************************************
 sage: R.<x> = RealField(200)[]
 sage: f = x^2 - R(pi)
 sage: f.roots(algorithm='numpy')
 /Users/student/Desktop/sage-4.6.alpha2/local/bin/sage-ipython:1:
 UserWarning: NumPy does not support arbitrary precision arithmetic.  The
 roots found will likely have less precision than you expect.
   #!/usr/bin/env python
 [(-1.7724538509055161039640324815991334617137908935546875000000, 1),
 (1.7724538509055158819194275565678253769874572753906250000000, 1)]
 sage: seq=[]
 sage: K = f.parent().base_ring()
 sage: L = K
 sage: K
 Real Field with 200 bits of precision
 sage: input_fp = True
 sage: L
 Real Field with 200 bits of precision
 sage: output_fp=True
 sage: input_complex=False
 sage: output_complex=False
 sage: input_arbprec=True
 sage: import numpy
 sage: from numpy.linalg.linalg import LinAlgError
 sage: coeffs = f.list()
 sage: coeffs
 [-3.1415926535897932384626433832795028841971693993751058209749,
 0.00000000000000000000000000000000000000000000000000000000000,
 1.0000000000000000000000000000000000000000000000000000000000]
 sage: ty = float
 sage: numpy_dtype='double'
 sage: numpy_array=numpy.array([ty(c) for c in
 reversed(coeffs)],dtype=numpy_dtype)
 sage: ext_rts1 = numpy.roots(numpy_array)
 sage: ext_rts1
 array([ 1.77245385, -1.77245385])
 sage: rts = []
 sage: for rt in ext_rts1:
 ....:     rts.append(CDF(rt))
 ....:
 sage: rts.sort()
 sage: ext_rts = rts
 sage: ext_rts
 [-1.77245385091, 1.77245385091]
 sage: rts = sorted([L(root.real()) for root in ext_rts if root.imag() ==
 0])
 sage: rts
 [-1.7724538509055161039640324815991334617137908935546875000000,
 1.7724538509055158819194275565678253769874572753906250000000]
 }}}
 which is the same as my final output, I think.  Note that `ext_rts` still
 have the same magnitude.  This is a big-endian machine, I guess (PPC)?  I
 have no idea if that is relevant, and I note that the error seems to be
 the opposite of the one others reported.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10042#comment:12>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to