<?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/"
		>
<channel>
	<title>Comments on: Stand-alone error function erf(x)</title>
	<atom:link href="http://www.johndcook.com/blog/2009/01/19/stand-alone-error-function-erf/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.johndcook.com/blog/2009/01/19/stand-alone-error-function-erf/</link>
	<description>The blog of John D. Cook</description>
	<lastBuildDate>Sat, 11 Feb 2012 01:10:06 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: John</title>
		<link>http://www.johndcook.com/blog/2009/01/19/stand-alone-error-function-erf/comment-page-1/#comment-37848</link>
		<dc:creator>John</dc:creator>
		<pubDate>Thu, 06 May 2010 16:08:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1293#comment-37848</guid>
		<description>Allen: The code is public domain. Do whatever you&#039;d like.

Here is some similar &lt;a href=&quot;http://www.johndcook.com/stand_alone_code.html&quot; rel=&quot;nofollow&quot;&gt;stand-alone code&lt;/a&gt;, also in the public domain.</description>
		<content:encoded><![CDATA[<p>Allen: The code is public domain. Do whatever you&#8217;d like.</p>
<p>Here is some similar <a href="http://www.johndcook.com/stand_alone_code.html" rel="nofollow">stand-alone code</a>, also in the public domain.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allen Downey</title>
		<link>http://www.johndcook.com/blog/2009/01/19/stand-alone-error-function-erf/comment-page-1/#comment-37843</link>
		<dc:creator>Allen Downey</dc:creator>
		<pubDate>Thu, 06 May 2010 14:50:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1293#comment-37843</guid>
		<description>Thanks for this -- I would like to distribute a modified version of this code -- can you tell me what license you intend to distribute this under?

(My version will be support code for Think Stats, a book I am working on.  The current draft is at thinkstatsbook.com)</description>
		<content:encoded><![CDATA[<p>Thanks for this &#8212; I would like to distribute a modified version of this code &#8212; can you tell me what license you intend to distribute this under?</p>
<p>(My version will be support code for Think Stats, a book I am working on.  The current draft is at thinkstatsbook.com)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vishal</title>
		<link>http://www.johndcook.com/blog/2009/01/19/stand-alone-error-function-erf/comment-page-1/#comment-25996</link>
		<dc:creator>Vishal</dc:creator>
		<pubDate>Thu, 15 Oct 2009 22:29:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1293#comment-25996</guid>
		<description>Can I use the code snippet above to compute the erf(x) or are there any issues with the code snippet? Thanks</description>
		<content:encoded><![CDATA[<p>Can I use the code snippet above to compute the erf(x) or are there any issues with the code snippet? Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jaime</title>
		<link>http://www.johndcook.com/blog/2009/01/19/stand-alone-error-function-erf/comment-page-1/#comment-13748</link>
		<dc:creator>Jaime</dc:creator>
		<pubDate>Tue, 24 Feb 2009 13:58:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1293#comment-13748</guid>
		<description>Gene, I&#039;m quoting below a couple of paragraphs, from &quot;The Art of Scientific Computing&quot; by Press et al...

-----

We assume that you know enough never to evaluate a polynomial this way:
p=c[0]+c[1]*x+c[2]*x*x+c[3]*x*x*x+c[4]*x*x*x*x;
or (even worse!),
p=c[0]+c[1]*x+c[2]*pow(x,2.0)+c[3]*pow(x,3.0)+c[4]*pow(x,4.0);
Come the (computer) revolution, all persons found guilty of such criminal behavior will be summarily executed, and their programs won’t be! It is a matter of taste, however, whether to write
p=c[0]+x*(c[1]+x*(c[2]+x*(c[3]+x*c[4])));
or
p=(((c[4]*x+c[3])*x+c[2])*x+c[1])*x+c[0];
If the number of coefficients c[0..n-1] is large, one writes
p=c[n-1];
for(j=n-2;j&gt;=0;j--) p=p*x+c[j];
or
p=c[j=n-1];
while (j&gt;0) p=p*x+c[--j];</description>
		<content:encoded><![CDATA[<p>Gene, I&#8217;m quoting below a couple of paragraphs, from &#8220;The Art of Scientific Computing&#8221; by Press et al&#8230;</p>
<p>&#8212;&#8211;</p>
<p>We assume that you know enough never to evaluate a polynomial this way:<br />
p=c[0]+c[1]*x+c[2]*x*x+c[3]*x*x*x+c[4]*x*x*x*x;<br />
or (even worse!),<br />
p=c[0]+c[1]*x+c[2]*pow(x,2.0)+c[3]*pow(x,3.0)+c[4]*pow(x,4.0);<br />
Come the (computer) revolution, all persons found guilty of such criminal behavior will be summarily executed, and their programs won’t be! It is a matter of taste, however, whether to write<br />
p=c[0]+x*(c[1]+x*(c[2]+x*(c[3]+x*c[4])));<br />
or<br />
p=(((c[4]*x+c[3])*x+c[2])*x+c[1])*x+c[0];<br />
If the number of coefficients c[0..n-1] is large, one writes<br />
p=c[n-1];<br />
for(j=n-2;j&gt;=0;j&#8211;) p=p*x+c[j];<br />
or<br />
p=c[j=n-1];<br />
while (j&gt;0) p=p*x+c[--j];</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith</title>
		<link>http://www.johndcook.com/blog/2009/01/19/stand-alone-error-function-erf/comment-page-1/#comment-13470</link>
		<dc:creator>Keith</dc:creator>
		<pubDate>Tue, 17 Feb 2009 16:39:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1293#comment-13470</guid>
		<description>Just found this through a google search. Very helpful... epecially now that I&#039;ve tried it and it works. Thanks.</description>
		<content:encoded><![CDATA[<p>Just found this through a google search. Very helpful&#8230; epecially now that I&#8217;ve tried it and it works. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.johndcook.com/blog/2009/01/19/stand-alone-error-function-erf/comment-page-1/#comment-12251</link>
		<dc:creator>John</dc:creator>
		<pubDate>Tue, 20 Jan 2009 22:16:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1293#comment-12251</guid>
		<description>Sorry about that. Maybe the A &amp; S abbreviation isn&#039;t as well-known as I thought.</description>
		<content:encoded><![CDATA[<p>Sorry about that. Maybe the A &#038; S abbreviation isn&#8217;t as well-known as I thought.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles McCreary</title>
		<link>http://www.johndcook.com/blog/2009/01/19/stand-alone-error-function-erf/comment-page-1/#comment-12250</link>
		<dc:creator>Charles McCreary</dc:creator>
		<pubDate>Tue, 20 Jan 2009 21:46:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1293#comment-12250</guid>
		<description>I had never heard about &quot;A&amp;S&quot; so I followed the Amazon link only to see the very familiar cover of my Abramowitz &amp; Stegun!</description>
		<content:encoded><![CDATA[<p>I had never heard about &#8220;A&amp;S&#8221; so I followed the Amazon link only to see the very familiar cover of my Abramowitz &amp; Stegun!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gene</title>
		<link>http://www.johndcook.com/blog/2009/01/19/stand-alone-error-function-erf/comment-page-1/#comment-12236</link>
		<dc:creator>Gene</dc:creator>
		<pubDate>Tue, 20 Jan 2009 14:48:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1293#comment-12236</guid>
		<description>I re-factored a sixth order polynomial using Horner’s method. The evaluation is called many times. The re-factoring lead to a dramatic improvement in execution times.

Definitely worth the effort, and unfortunately, easy to make an error until you&#039;ve performed the operation a few times.

So much for plowing through a polynomial using Math.Pow(x, y).</description>
		<content:encoded><![CDATA[<p>I re-factored a sixth order polynomial using Horner’s method. The evaluation is called many times. The re-factoring lead to a dramatic improvement in execution times.</p>
<p>Definitely worth the effort, and unfortunately, easy to make an error until you&#8217;ve performed the operation a few times.</p>
<p>So much for plowing through a polynomial using Math.Pow(x, y).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.johndcook.com/blog/2009/01/19/stand-alone-error-function-erf/comment-page-1/#comment-12208</link>
		<dc:creator>John</dc:creator>
		<pubDate>Mon, 19 Jan 2009 22:30:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1293#comment-12208</guid>
		<description>Thanks! That&#039;s handy sample code for other problems too.

On POSIX systems, &lt;code&gt;erf&lt;/code&gt; is included in &lt;code&gt;math.h&lt;/code&gt;.  But it&#039;s not part of the ISO standard requirement, and Microsoft doesn&#039;t implement it with their compiler. For reasons I don&#039;t understand, Microsoft does implement Bessel functions, but it doesn&#039;t implement function that I imagine are more commonly used, particularly the gamma function.</description>
		<content:encoded><![CDATA[<p>Thanks! That&#8217;s handy sample code for other problems too.</p>
<p>On POSIX systems, <code>erf</code> is included in <code>math.h</code>.  But it&#8217;s not part of the ISO standard requirement, and Microsoft doesn&#8217;t implement it with their compiler. For reasons I don&#8217;t understand, Microsoft does implement Bessel functions, but it doesn&#8217;t implement function that I imagine are more commonly used, particularly the gamma function.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sergey Fomel</title>
		<link>http://www.johndcook.com/blog/2009/01/19/stand-alone-error-function-erf/comment-page-1/#comment-12205</link>
		<dc:creator>Sergey Fomel</dc:creator>
		<pubDate>Mon, 19 Jan 2009 22:21:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=1293#comment-12205</guid>
		<description>erf is actually a standard function in C &quot;math.h&quot;

For some reason, it is not included in Python&#039;s math module but, if you have SWIG, it is easy to write a SWIG wrapper for it. An example on a Linux machine:

&lt;pre&gt;
bash$ cat erf.i

%module erf
#include 
double erf(double);

bash$ swig -o erf_wrap.c -python erf.i
bash$ gcc -o erf_wrap.os -c -fPIC -I/usr/include/python2.4 erf_wrap.c
bash$ gcc -o _erf.so -shared erf_wrap.os
bash$ python
&gt;&gt;&gt; from erf import erf
&gt;&gt;&gt; erf(1)
0.84270079294971489
&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<p>erf is actually a standard function in C &#8220;math.h&#8221;</p>
<p>For some reason, it is not included in Python&#8217;s math module but, if you have SWIG, it is easy to write a SWIG wrapper for it. An example on a Linux machine:</p>
<pre>
bash$ cat erf.i

%module erf
#include
double erf(double);

bash$ swig -o erf_wrap.c -python erf.i
bash$ gcc -o erf_wrap.os -c -fPIC -I/usr/include/python2.4 erf_wrap.c
bash$ gcc -o _erf.so -shared erf_wrap.os
bash$ python
&gt;&gt;&gt; from erf import erf
&gt;&gt;&gt; erf(1)
0.84270079294971489
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.461 seconds -->

