<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On 17 December 2015 at 14:43, Nico Schlömer <span dir="ltr"><<a href="mailto:nico.schloemer@gmail.com" target="_blank">nico.schloemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I'm not sure where I'm going wrong here. Any hints?</blockquote></div><br></div><div class="gmail_extra">You are dancing around the boundary between close floating point numbers, and when you are dealing with ULPs, number of decimal places is a bad measure. Working with plain numbers, instead of arrays (just so that the numbers are printed in full detail)<br><br>a1 = np.float64(3.1415926535897930)<br>a2 = np.float64(3.1415926535897939)<br><br>They are numerically different:<br>a2 - a1<br>8.8817841970012523e-16<br><br>In epsilons (defined as the smallest number such that (1 + eps) - 1 > 0):<br>(a2 - a1) / np.finfo(np.float64).eps<br>4.0<br><br></div><div class="gmail_extra">In fact, there is one number in between, two epsilons away from each one:<br></div><div class="gmail_extra">np.nextafter(a1, a2)<br>3.1415926535897936<br><br>np.nextafter(np.nextafter(a1, 10), 10) - a2<br>0.0<br><br>The next number on the other side:<br>np.nextafter(a1, 0)<br>3.1415926535897927<br><br>For more information:<br><br>print np.finfo(np.float64)<br>Machine parameters for float64<br>---------------------------------------------------------------<br>precision= 15   resolution= 1.0000000000000001e-15<br>machep=   -52   eps=        2.2204460492503131e-16<br>negep =   -53   epsneg=     1.1102230246251565e-16<br>minexp= -1022   tiny=       2.2250738585072014e-308<br>maxexp=  1024   max=        1.7976931348623157e+308<br>nexp  =    11   min=        -max<br>---------------------------------------------------------------<br><br><br></div><div class="gmail_extra">/David<br></div><div class="gmail_extra"><br><br><br></div></div>