<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: The Digits of Pi</title>
	<atom:link href="http://programmingpraxis.com/2009/02/20/the-digits-of-pi/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmingpraxis.com/2009/02/20/the-digits-of-pi/</link>
	<description>A collection of etudes, updated weekly, for the education and enjoyment of the savvy programmer</description>
	<lastBuildDate>Sat, 11 Feb 2012 09:48:16 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Sam Kennedy</title>
		<link>http://programmingpraxis.com/2009/02/20/the-digits-of-pi/#comment-3199</link>
		<dc:creator><![CDATA[Sam Kennedy]]></dc:creator>
		<pubDate>Tue, 05 Jul 2011 16:11:44 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=56#comment-3199</guid>
		<description><![CDATA[It isn&#039;t pretty but it works:

&lt;code&gt;
#!/usr/bin/perl

$&#124; = 1;

push(@B, 0);

$counter = 3;
for($i = 0;$i&lt;=33223;$i++){
    push(@A,$i);
    push(@remainder, 2);
    push(@B, $counter);
    $counter += 2;
}

for($x = 1; $x=1;$i--){
        $m10[$i] = $remainder[$i] * 10;
        $sum[$i] = $m10[$i] + $carried[$i];
        $remainder[$i] = $sum[$i] % $B[$i];
        $carried[$i - 1] = (($sum[$i] - $remainder[$i]) / $B[$i]) * $A[$i];
	}
	
    $m10[0] = $remainder[0] * 10;
    $sum[0] = $m10[0] + $carried[0];
    $remainder[0] = $sum[0]%10;
	$predigit = int($sum[0]/10);
	
	push(@predigits, $predigit);
	
	if($predigit &lt; 9){
		for($i = 0; $i&lt;((scalar @predigits)-1); $i++){
			print $predigits[$i];
		}
		undef @predigits;
		push(@predigits, $predigit);
	}
	
	if($predigit == 10){
		for($i = 0; $i&lt;((scalar @predigits)-1); $i++){
			if($predigits[$i] == 9) { print 0; }
			else {
				$predigits[$i] = $predigits[$i] + 1;
				print $predigits[$i];
			}
		}
		undef @predigits;
		push(@predigits, 0);
	}
}
&lt;/code&gt;]]></description>
		<content:encoded><![CDATA[<p>It isn&#8217;t pretty but it works:</p>
<p><code><br />
#!/usr/bin/perl</p>
<p>$| = 1;</p>
<p>push(@B, 0);</p>
<p>$counter = 3;<br />
for($i = 0;$i&lt;=33223;$i++){<br />
    push(@A,$i);<br />
    push(@remainder, 2);<br />
    push(@B, $counter);<br />
    $counter += 2;<br />
}</p>
<p>for($x = 1; $x=1;$i--){<br />
        $m10[$i] = $remainder[$i] * 10;<br />
        $sum[$i] = $m10[$i] + $carried[$i];<br />
        $remainder[$i] = $sum[$i] % $B[$i];<br />
        $carried[$i - 1] = (($sum[$i] - $remainder[$i]) / $B[$i]) * $A[$i];<br />
	}</p>
<p>    $m10[0] = $remainder[0] * 10;<br />
    $sum[0] = $m10[0] + $carried[0];<br />
    $remainder[0] = $sum[0]%10;<br />
	$predigit = int($sum[0]/10);</p>
<p>	push(@predigits, $predigit);</p>
<p>	if($predigit &lt; 9){<br />
		for($i = 0; $i&lt;((scalar @predigits)-1); $i++){<br />
			print $predigits[$i];<br />
		}<br />
		undef @predigits;<br />
		push(@predigits, $predigit);<br />
	}</p>
<p>	if($predigit == 10){<br />
		for($i = 0; $i&lt;((scalar @predigits)-1); $i++){<br />
			if($predigits[$i] == 9) { print 0; }<br />
			else {<br />
				$predigits[$i] = $predigits[$i] + 1;<br />
				print $predigits[$i];<br />
			}<br />
		}<br />
		undef @predigits;<br />
		push(@predigits, 0);<br />
	}<br />
}<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam Kennedy</title>
		<link>http://programmingpraxis.com/2009/02/20/the-digits-of-pi/#comment-3176</link>
		<dc:creator><![CDATA[Sam Kennedy]]></dc:creator>
		<pubDate>Wed, 29 Jun 2011 13:06:08 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=56#comment-3176</guid>
		<description><![CDATA[This seems like a really interesting exercise, however I cannot understand how this spigot algorithm works. I read the PDF, but I could not follow the maths in the diagram, is there an easier explanation for someone who doesn&#039;t have a massive background in maths?

Cheers,
-Sam]]></description>
		<content:encoded><![CDATA[<p>This seems like a really interesting exercise, however I cannot understand how this spigot algorithm works. I read the PDF, but I could not follow the maths in the diagram, is there an easier explanation for someone who doesn&#8217;t have a massive background in maths?</p>
<p>Cheers,<br />
-Sam</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Graham</title>
		<link>http://programmingpraxis.com/2009/02/20/the-digits-of-pi/#comment-3041</link>
		<dc:creator><![CDATA[Graham]]></dc:creator>
		<pubDate>Tue, 17 May 2011 18:07:22 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=56#comment-3041</guid>
		<description><![CDATA[I modified the fixed-point approach for arccot found
&lt;a href=&quot;http://www.reddit.com/r/lisp/comments/93ofv/how_fast_does_your_lisp_compute_10000_digits_of_pi/&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;
and used it with Wikipedia&#039;s most efficient Machin-Like formula found
&lt;a href=&quot;http://en.wikipedia.org/wiki/Machin-like_formula&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;
&lt;a href=&quot;https://gist.github.com/976997&quot; rel=&quot;nofollow&quot;&gt;My submission&lt;/a&gt;]]></description>
		<content:encoded><![CDATA[<p>I modified the fixed-point approach for arccot found<br />
<a href="http://www.reddit.com/r/lisp/comments/93ofv/how_fast_does_your_lisp_compute_10000_digits_of_pi/" rel="nofollow">here</a><br />
and used it with Wikipedia&#8217;s most efficient Machin-Like formula found<br />
<a href="http://en.wikipedia.org/wiki/Machin-like_formula" rel="nofollow">here</a><br />
<a href="https://gist.github.com/976997" rel="nofollow">My submission</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: programmingpraxis</title>
		<link>http://programmingpraxis.com/2009/02/20/the-digits-of-pi/#comment-1555</link>
		<dc:creator><![CDATA[programmingpraxis]]></dc:creator>
		<pubDate>Fri, 06 Aug 2010 11:59:01 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=56#comment-1555</guid>
		<description><![CDATA[Alexander J. Yee &amp; Shigeru Kondo recently &lt;a href=&quot;http://www.numberworld.org/misc_runs/pi-5t/details.html&quot; rel=&quot;nofollow&quot;&gt;computed&lt;/a&gt; five trillion digits of pi.]]></description>
		<content:encoded><![CDATA[<p>Alexander J. Yee &amp; Shigeru Kondo recently <a href="http://www.numberworld.org/misc_runs/pi-5t/details.html" rel="nofollow">computed</a> five trillion digits of pi.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Weaver</title>
		<link>http://programmingpraxis.com/2009/02/20/the-digits-of-pi/#comment-645</link>
		<dc:creator><![CDATA[Matt Weaver]]></dc:creator>
		<pubDate>Sun, 27 Sep 2009 01:58:04 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=56#comment-645</guid>
		<description><![CDATA[My solution, written in C:

http://codepad.org/WOEQnbTt

This version calculates the requested digit directly, based on the method described in &quot;Computation of the nth decimal digit of pi with low memory&quot;: http://numbers.computation.free.fr/Constants/Algorithms/nthdecimaldigit.pdf (and I must admit I also peeked a little at the implementation at http://numbers.computation.free.fr/Constants/Algorithms/nthdigit.html)

It lacks the conciseness and elegance of the spigot solution, but makes up for it in efficiency.  The spigot version works well until it runs out of main memory and starts paging, at which point performance really hits a wall.  On my computer that point is somewhere between the 20,000th digit (took 1:48) and the 50,000th (I killed it after 3.5 hours).  For comparison, this solution returns the 50,000th digit in ~12 seconds.]]></description>
		<content:encoded><![CDATA[<p>My solution, written in C:</p>
<p><a href="http://codepad.org/WOEQnbTt" rel="nofollow">http://codepad.org/WOEQnbTt</a></p>
<p>This version calculates the requested digit directly, based on the method described in &#8220;Computation of the nth decimal digit of pi with low memory&#8221;: <a href="http://numbers.computation.free.fr/Constants/Algorithms/nthdecimaldigit.pdf" rel="nofollow">http://numbers.computation.free.fr/Constants/Algorithms/nthdecimaldigit.pdf</a> (and I must admit I also peeked a little at the implementation at <a href="http://numbers.computation.free.fr/Constants/Algorithms/nthdigit.html" rel="nofollow">http://numbers.computation.free.fr/Constants/Algorithms/nthdigit.html</a>)</p>
<p>It lacks the conciseness and elegance of the spigot solution, but makes up for it in efficiency.  The spigot version works well until it runs out of main memory and starts paging, at which point performance really hits a wall.  On my computer that point is somewhere between the 20,000th digit (took 1:48) and the 50,000th (I killed it after 3.5 hours).  For comparison, this solution returns the 50,000th digit in ~12 seconds.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

