<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" >

  <title>Erik L. Arneson — Writer and Software Developer</title>
  <subtitle>Erik L. Arneson is a freelance writer and software developer with WordPress experience. He is located in Portland, Oregon.</subtitle>
  <generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator>
  <link href="https://arnesonium.com/feeds/math.xml" rel="self" type="application/atom+xml" />
  <link href="https://arnesonium.com/" rel="alternate" type="text/html" />
  <updated>2026-06-18T15:03:10+00:00</updated>
  <id>https://arnesonium.com/feeds/math.xml</id>
  <author>
    <name>Erik L. Arneson</name>
  </author>
      <entry>
        
        <title>Camlprime Now on OPAM</title>
        <author>
          <name>Erik L. Arneson</name>
        </author>        
        <link href="https://arnesonium.com/2014/12/camlprime-now-on-opam/" rel="alternate" type="text/html" title="Camlprime Now on OPAM" />
        <updated>2014-12-02T22:19:09+00:00</updated>
        <id>https://arnesonium.com/2014/12/camlprime-now-on-opam</id>
          <category term="math" />
        
          <category term="ocaml" />
        
          <category term="opam" />
        
          <category term="programming" />
        <content type="html" xml:base="https://arnesonium.com/2014/12/camlprime-now-on-opam/">&lt;p&gt;My first &lt;a href=&quot;http://opam.ocaml.org/&quot; target=&quot;_blank&quot;&gt;OCaml Package Manager (OPAM)&lt;/a&gt; submission has just been accepted. You can now find &lt;a href=&quot;http://arnesonium.com/2014/11/prime-number-library-for-ocaml/&quot; title=&quot;Prime Number Library for OCaml&quot;&gt;Camlprime, a prime number library&lt;/a&gt;, on &lt;a href=&quot;http://opam.ocaml.org/packages/camlprime/camlprime.0.5/&quot; target=&quot;_blank&quot;&gt;OPAM here&lt;/a&gt;.&lt;/p&gt;</content>
      </entry>
    
      <entry>
        
        <title>Prime Number Library for OCaml</title>
        <author>
          <name>Erik L. Arneson</name>
        </author>        
        <link href="https://arnesonium.com/2014/11/prime-number-library-for-ocaml/" rel="alternate" type="text/html" title="Prime Number Library for OCaml" />
        <updated>2014-11-13T17:08:39+00:00</updated>
        <id>https://arnesonium.com/2014/11/prime-number-library-for-ocaml</id>
          <category term="math" />
        
          <category term="ocaml" />
        
          <category term="programming" />
        <content type="html" xml:base="https://arnesonium.com/2014/11/prime-number-library-for-ocaml/">&lt;p&gt;A couple of weeks ago, I cleaned up my prime number library for &lt;a href=&quot;https://ocaml.org/&quot;&gt;OCaml&lt;/a&gt;. This library has a number of primality-testing methods in it, but my favorite is the &lt;a href=&quot;http://jeremykun.com/2013/06/16/miller-rabin-primality-test/&quot;&gt;Miller-Rabin primality test&lt;/a&gt;. It’s fast and rather accurate.
&lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;If you’d like to take a look at the library, please check out the &lt;a href=&quot;https://github.com/pymander/camlprime&quot;&gt;camlprime GitHub page&lt;/a&gt;. The library is pretty easy to use. If you download and compile the library, you’ll end up with a toplevel that you can play with.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;test.ml&lt;/code&gt; file has some examples of how to use the primality tests. However, my favorite thing about this library is that it includes a &lt;a href=&quot;https://www.haskell.org/haskellwiki/Lazy_evaluation&quot;&gt;lazy list&lt;/a&gt; implementation of prime numbers. The following example shows how to set up a lazy list of prime numbers proved using the MR algorithm in the toplevel.&lt;/p&gt;

&lt;div class=&quot;language-ocaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;open&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Num&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prime_list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Prime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;make&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nn&quot;&gt;Prime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;miller_rabin&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num_of_int&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;val&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prime_list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;LazyList&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;LazyList&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Node&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Int&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;503&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;lazy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Prime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nth&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;prime_list&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;500&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Int&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4363&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The library is pretty fast, even for really large numbers. I’ve tested it on 300-digit prime numbers, and I’m sure it will scale to sizes much larger than that.&lt;/p&gt;

&lt;p&gt;Any thoughts or improvements? Let me know in the comments.&lt;/p&gt;</content>
      </entry>
    
</feed>
