<div dir="ltr">Hi again Danny,<div><br></div><div style>Very interesting note, thanks for the details. The problem is a slightly easier version of one the ProjectEuler.net problems (see here: <a href="http://projecteuler.net/problem=210">http://projecteuler.net/problem=210</a>) Basically the hard part of the problem is finding the grid points that fall in a circle with origin at (12500000, 12500000) with radius = ldiv8xrad2 (sqrt(2)*100000000/8).</div>
<div style><br></div><div style>-Joe</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 4, 2013 at 4:20 PM, Danny Yoo <span dir="ltr"><<a href="mailto:dyoo@hashcollision.org" target="_blank">dyoo@hashcollision.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr"><div>Yes, makes perfect sense, hmmm... there's probably a way to avoid so many sqrt calls.</div></div></blockquote><div><br></div></div><div>This probably won't help. No individual iteration in that inner loop is beyond 32 bits. The accumulated sum itself is what grows beyond the bounds of a 32-bit representation. Reducing the number of sqrt calls is likely not to noticeably improve the runtime performance on 32-bit platforms: the dominant part of your runtime is the fact that bignum operations will not be constant time for the quantities your program is working with.</div>
<div> <br></div><div>If you can tell us more about the problem domain, maybe we can suggest improvements. It looks like it's a numerical computation of something. Do you need the result to be exact? What is it actually computing, and why?</div>
<div class="im">
<div> <br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">
<div></div><div>How do you like Go? How is the performance on this code?</div></div></blockquote><div><br></div></div><div>I can't say anything too informed about it yet. I just started learning it a few days ago. As far as compile and run times are concerned, here's what I see:</div>
<div><br></div><div>######</div><div><div>bash-3.2$ time go build euler210.go </div><div>real<span style="white-space:pre-wrap">        </span>0m0.193s</div><div>user<span style="white-space:pre-wrap">        </span>0m0.152s</div>
<div>sys<span style="white-space:pre-wrap">        </span>0m0.037s</div><div><div><br></div><div>bash-3.2$ time ./euler210 </div><div>15981747679237090</div><div><br></div><div>real<span style="white-space:pre-wrap">        </span>0m0.117s</div>
<div>user<span style="white-space:pre-wrap">        </span>0m0.112s</div><div>sys<span style="white-space:pre-wrap">        </span>0m0.003s</div></div><div><div><br></div><div><div>bash-3.2$ time raco make euler210.rkt</div><div>
<br></div><div>real<span style="white-space:pre-wrap">        </span>0m0.291s</div><div>user<span style="white-space:pre-wrap">        </span>0m0.211s</div><div>sys<span style="white-space:pre-wrap">        </span>0m0.058s</div></div>
<div><div>bash-3.2$ time racket euler210.rkt</div><div>15981747679237090</div><div><br></div><div>real<span style="white-space:pre-wrap">        </span>0m0.803s</div><div>user<span style="white-space:pre-wrap">        </span>0m0.736s</div>
<div>sys<span style="white-space:pre-wrap">        </span>0m0.037s</div></div><div>######</div><div></div></div><div><br></div><div>Note that my Go version is "cheating" in a sense: I kept changing the size of the numeric representations until I stopped seeing differences from the canonical Racket version. What I've got is not backed by any kind of numeric tower. If I were to really write it in a way that tries to do a better job at preserving the meaning of the program, I'd need to add a whole bunch of references to Go's math/big library, and be very careful in doing so.</div>
</div></div></div></div>
</blockquote></div><br></div>