[Numpy-discussion] double-precision sqrt?

Dag Sverre Seljebotn dagss@student.matnat.uio...
Sat Oct 17 13:25:01 CDT 2009

Adam Ginsburg wrote:
> Hi folks,
>    I'm trying to write a ray-tracing code for which high precision is
> required.  I also "need" to use square roots.  However, math.sqrt and
> numpy.sqrt seem to only use single-precision floats.  Is there a
> simple way to make sqrt use higher precision?  Alternately, am I
> simply being obtuse?

How are you actually using the results of sqrt? When printing the 
results you may not get the full precision...try e.g.

print "%.50f" % np.sqrt(np.float64( 1.034324523462345))

Dag Sverre

More information about the NumPy-Discussion mailing list