ChemicalDevelopment.A Real Company
http://chemicaldevelopment.us/
Mon, 26 Feb 2018 18:19:56 +0000Mon, 26 Feb 2018 18:19:56 +0000Jekyll v3.6.2Politics: Kent State Shootings<p>Today, I released my NHD project known as <a href="https://www.youtube.com/watch?v=qLnwFJPmMPU">ChemicalDevelopment presents “Kent State Shootings”</a>.</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/qLnwFJPmMPU?rel=0" frameborder="0" allowfullscreen=""></iframe>
<p>I talk about the massacre itself, as well as the context surrounding the protests, such as the Vietnam war, Cambodian expansion, etc.</p>
Mon, 20 Nov 2017 00:00:00 +0000
http://chemicaldevelopment.us/kent-state-shootings
http://chemicaldevelopment.us/kent-state-shootingspoliticsvietnamnotesMusic: Anthem<p>Here is our official ChemicalDevelopment anthem:</p>
<iframe width="100%" height="265" src="https://clyp.it/e4ztrmam/widget" frameborder="0"></iframe>
<p>If you’d like to see the source, and make your own version, I used <a href="http://lmms.io">LMMS</a> to create this. You can use my exact project, located <a href="https://github.com/CadeBrown/projectfiles/blob/master/music/chemicaldevelopment_anthem.mmpz">here</a>.</p>
<p>Flask boy approves of this message!</p>
Tue, 19 Sep 2017 00:00:00 +0000
http://chemicaldevelopment.us/music/anthem
http://chemicaldevelopment.us/music/anthemmusicSoftware: Mailing List<p>The chemicaldevelopment mailing list is <code class="highlighter-rouge">group@chemicaldevelopment.us</code>.</p>
<p>To join the receive list, email <code class="highlighter-rouge">group@chemicaldevelopment.us</code> with the subject <code class="highlighter-rouge">[REQUEST] Join The Mailing List</code>, and a non-blank body of the message. You can add other mailing addresses you would like on the list in the body.</p>
<p>Make sure not to add spam/spam-like content, or it may be filtered!</p>
<p>Any questions can go there, about specific software, or just general ChemicalDevelopment chatter.</p>
Fri, 09 Jun 2017 00:00:00 +0000
http://chemicaldevelopment.us/software/mailing-list
http://chemicaldevelopment.us/software/mailing-listsoftwareSoftware: PGS Updated<p><a href="/category/#pgs">Here’s a link to posts about PGS</a></p>
<p>Essentially, PGS is a distributed computing program that I wrote to find polynomials which generate prime numbers.</p>
<p>I’ve made lots of updates to it, and plan on a released version in a few weeks.</p>
<h2 id="language-transition">Language Transition</h2>
<p>Originally (and up to version 2.5.0), the bulk of PGS was written in JavaScript. I know, I know, it’s quite odd. I mainly used JS as an expirement, as it supports talking to firebase (the database we use) out of the box. It actually worked very well for cross-process communication and JSON-based datastructures well. Also, it was surprisingly easy to distribute (just include the ‘node’ binary and node_modules/ folder and it works!). However, the archives were 10MB, which was mostly the node binary. Also, there were limitations of using JavaScript and C together.</p>
<p>Python requires a custom library (<a href="https://github.com/thisbejim/Pyrebase">called Pyrebase</a>), which is unofficial and requires pycryptodome.</p>
<p>Still unclear, PGS only works in development mode now, and I will likely return to NodeJS, or use Python with better <code class="highlighter-rouge">--offline</code> support, or possibly switch to C (although this is very unlikely).</p>
Thu, 16 Mar 2017 00:00:00 +0000
http://chemicaldevelopment.us/software/pgs/PGS-Updates
http://chemicaldevelopment.us/software/pgs/PGS-UpdatessoftwarepgsQuestion: Are We A Company?<p>Not yet, but that doesn’t mean we aren’t real.</p>
<p>It’s only as real as you make it</p>
Sun, 05 Mar 2017 00:00:00 +0000
http://chemicaldevelopment.us/question/are-we-a-company
http://chemicaldevelopment.us/question/are-we-a-companyquestionMath: Arithmetic Optimizations<p>We’re always doing math, whether we realize it or not. Whenever you need to know how much tax is on something, or if you can evenly split pizza between people, you are using arithmetic.</p>
<p>Arithmetic is essentially all your number manipulations, adding, subtracting, multiplying and dividing. There are quite a few tricks we can use to speed up doing this in your head.</p>
<p>I’ll present the first part of this article in base 10, but later I’ll go into other bases as well.</p>
<h2 id="base-10">Base 10</h2>
<h3 id="adding">Adding</h3>
<p>Here is what is called grade school addition:</p>
<pre>
( 1 )
248
+ 543
_______
791
</pre>
<p>the <code class="highlighter-rouge">1</code> on top is because <code class="highlighter-rouge">8+3=11</code> is greater than <code class="highlighter-rouge">10</code>, so we write the first digit lower, and the 10s place above the next.</p>
<p>The reason for this is quite simple: we can’t have a digit greater than or equal to the base. if we have a digit of (10) in one place, we know that is invalid, so we seperate it into <code class="highlighter-rouge">1</code> and <code class="highlighter-rouge">0</code>. The same applies here.</p>
<p>There aren’t really any improvements to this, because of how simple it is.</p>
<h3 id="subtracting">Subtracting</h3>
<p>This is grade school subtraction:</p>
<pre>
(4 13 13)
5 4 3
- 2 4 8
___________
2 9 5
</pre>
<p>The numbers on top are because <code class="highlighter-rouge">3<8</code>, so we must “borrow” from the next place value.</p>
<p>Essentially, we are saying that because digits have to be between <code class="highlighter-rouge">0</code> and <code class="highlighter-rouge">9</code>, we will have a negative if we subtract 8 from 3, so we add on 10 knowing that 13 overflows, but that (13-8) will not.</p>
<p>The only real speedup here is that you could start by borrowing from the start, then carry digits later (so you won’t have to stop in the middle)</p>
<p>All in all, however, addition and subtraction do not have many speedups because of their linear nature.</p>
<h3 id="multiplying">Multiplying</h3>
<p>This is grade school multiplication:</p>
<pre>
(12 )
23
* 17
______
161
+ 230
______
391
</pre>
<p>We take it digit-wise multiplication, 7*3, which is equal to 21. This is greater than 10, so we carry the <code class="highlighter-rouge">2</code> above to the next column.</p>
<p>Then, we compute <code class="highlighter-rouge">7*2=14</code>, and add the <code class="highlighter-rouge">2</code> which was our carry from last time, giving us <code class="highlighter-rouge">16</code>. our carry is now <code class="highlighter-rouge">1</code></p>
<p>Since there is no other digit, simply tack on our <code class="highlighter-rouge">1</code> and recieve the first product, <code class="highlighter-rouge">7*23=161</code>.</p>
<p>We move on to the next digit on the bottom number, <code class="highlighter-rouge">1</code>, and begin by adding a <code class="highlighter-rouge">0</code> under our <code class="highlighter-rouge">161</code>.</p>
<p>We move column to column just like last time to end up with <code class="highlighter-rouge">230</code> written. We then sum these two numbers to recieve <code class="highlighter-rouge">391</code></p>
<p>Pretty straight forward, but we can speed things up quickly.</p>
<p>Here are a few things to know:</p>
<p>Obviously, memorizing your multiplication tables for single digits speeds things up a lot for all of this.</p>
<h4 id="2-digit-times-2-digit">2 Digit times 2 Digit</h4>
<p>say you have the number (ab)*(cd),</p>
<p>Where (ab) and (cd) are the digits in base 10</p>
<p>You can write these then as (10a+b)*(10c+d) (since each place value is multiplied by the base, 10)</p>
<p>When you expand this, you get <code class="highlighter-rouge">100*a*c+10*(a*d+b*c)+b*d</code></p>
<p>So, the digits are: <code class="highlighter-rouge">(a*c)</code>, <code class="highlighter-rouge">(a*d+b*c)</code>, and <code class="highlighter-rouge">(b*d)</code></p>
<p>Applying this to our example, <code class="highlighter-rouge">23*17</code>, a=2, b=3, c=1, d=7</p>
<p>Our new number is <code class="highlighter-rouge">(2*1)</code>, <code class="highlighter-rouge">(14+3)</code>, and <code class="highlighter-rouge">(3*7)</code>, or</p>
<p><code class="highlighter-rouge">(2)(17)(21)</code> Obviousy, we need to carry.</p>
<p>By adding the carry from each:</p>
<pre>
(2)(17)(21)
(2)(17+2)(1)=(2)(19)(1)
(2+1)(9)(1)=(3)(9)(1)
23*17=391
</pre>
<p>Once you get this down, multiplying two digit numbers can be faster, a quick example:</p>
<p><code class="highlighter-rouge">Compute 97*83</code></p>
<pre>
(9*8), (7*8+3*9), (7*3)
(72)(56+27)(21) = (72)(83)(21)
(72)(83+2)(1) = (72)(85)(1)
(72+8)(5)(1) = (80)(5)(1)
(8)(0)(5)(1)
97*83 = 8051
</pre>
Mon, 14 Nov 2016 00:00:00 +0000
http://chemicaldevelopment.us/math/arithmetic-optimizations
http://chemicaldevelopment.us/math/arithmetic-optimizationsmathMath: PGS (Prime Generator Search)<p>If you’ve ever read about primes, you have probably wondered how do we generate them? How do we find more?</p>
<p>If you haven’t read my post on primes, it is a good prerequisite to this post, so I’d suggest trying that first.</p>
<h2 id="forms">Forms</h2>
<p>A form is a way to write something.</p>
<p>You can write $ 6 $ as $ 2n $ because $ 6 = 2 * 3 $.
Here, $ n = 3 $, so it has this form.</p>
<p>$ 9 $ is part of a form: $ n^2 $ because $ 9 = 3^2 $.
Here, $ n = 3 $</p>
<h1 id="prime-forms">Prime Forms</h1>
<p>Forms of primes are formulas, like $ 2n $ or $ n^2 $ which hold primes.</p>
<p>For example, all primes except $2$ can be written as $2n+1$. If they were $2n$, then they would not be prime (except for $2$, of course)</p>
<p>Currently, world records for sizes of primes are being broken by GIMPS - which searches for Mersenne primes.</p>
<p><a href="http://www.mersenne.org/">GIMPS</a> searches numbers that are of the form: $ 2^n-1 $, and tests them for primality</p>
<p><a href="http://www.primegrid.com/">Prime Grid</a> searches lots of forms, most notably $ a2^n\pm1 $</p>
<p>They also search prime generators, which they broke a record for $an+b$ which is called <a href="https://www.primegrid.com/download/AP26.pdf">AP26</a></p>
<p>What they found was for $ n = 0 . . . 25 $, $a * n + b$ is prime for $a = 23681770*223092870$ and $b = 43142746595714191$</p>
<p>Which broke the previous world record.</p>
<p><a href="http://pgs.chemicaldevelopment.us">PGS</a> is my program, which searches for polynomials which generate primes for the first values.</p>
<p>Currently, we are searching quadratics, which are of form: $an^2 + bn + c$. We haven’t broken any records yet, but we hope to soon.
PGS is running on UTK’s (University of Tennessee Knoxville) super computer, Newton.</p>
<p>Although it is much faster than any home computer, users can donate their CPU time to check a small block of coefficients.</p>
<h2 id="pgs">PGS</h2>
<p>PGS is a project I have worked on for 3 months now, and just recently added user support and online record keeping.</p>
<p>Here’s how it works.</p>
<p>When you download a release, that includes a few things. A <code class="highlighter-rouge">node</code> executable for your platform. Along with the programs:<code class="highlighter-rouge">PGS.js</code>, <code class="highlighter-rouge">lib.o</code>, <code class="highlighter-rouge">CPGS.o</code>.</p>
<p>Note that PGS.js is just source, while the <code class="highlighter-rouge">.o</code> files are compiled files. The source for everything in PGS is on <a href="https://github.com/ChemicalDevelopment/pgs">Github</a></p>
<p>You enter in your email and password that you signed up with in <code class="highlighter-rouge">my.prefs</code>, and click run.sh. It logs you in, then starts gathering workloads from my server, and runs each using <code class="highlighter-rouge">CPGS.o</code>.
Once these finish, PGS grabs another one, and starts it. It keeps going and going until it is killed, or your prefs specify to stop. It then gracefully shuts down, and marks all of your jobs as incomplete, so the server knows you didn’t finish them.</p>
<p>You will notice a quite large file - <code class="highlighter-rouge">primes.dat</code> which is 250MB. This is not downloaded in the zip. If PGS determines that you don’t have a primes.dat file, it generates one with <code class="highlighter-rouge">lib.o</code>.
This is a bitset - which I’ll explain later - which stores information so I know whether or not every number below $2,000,000,000$ is prime. This is used later to verify whether numbers are prime.</p>
<p>I’ll go into specific parts down below.</p>
<h3 id="bitset">Bitset</h3>
<p>I’m going to assume you know the binary number system for this part. If not, just think of 1 as a “yes” and 0 as a “no”.</p>
<p>So, there are plenty of algorithms to generate the first few primes. I use the Sieve of Eratosthenes to compute a list.</p>
<p>But, if we stored the primes as an array, like [2, 3, 5, 7] this would take up too much space. How much space exactly?</p>
<p>Well, 32 bit integers which can store up to 2^32 each take up 4 bytes because each byte is 8 bits, and 32 / 8 = 4</p>
<p>If we wanted to store each prime under 2,000,000,000, we would have to store over 98,000,000,000. This takes up more space, and is slower at runtime than a bitset, which is explained below.</p>
<p>This approach will take 98,000,000 integers of space (each is 32 bits, which is 4 bytes), and when we check at runtime, we will need to check every integer in the array until we find it, or we find a number that is greater than it.</p>
<p>For example, say I give you a small list of primes: [2, 3, 5, 7, 11, 13, 17, 19]. I ask you if 15 is prime. How do you tell me?</p>
<p>Well, you would go through the list and compare each to 15.</p>
<p>Is 2 = 15?</p>
<p>Is 3 = 15?</p>
<p>. . .</p>
<p>Is 17 = 15?</p>
<p>At this point, you can stop because you have passed where 15 would be, so you know it isn’t prime.</p>
<p>Now then, let’s say we use a list of bits to tell you if the number is prime. The list above would look like:</p>
<p><code class="highlighter-rouge">001101010001010001010</code></p>
<p>This starts at 0, and goes to 19</p>
<p>The <code class="highlighter-rouge">1</code>s mean that the index is prime, so count from the left: <code class="highlighter-rouge">0</code>, <code class="highlighter-rouge">1</code>, <code class="highlighter-rouge">2</code></p>
<p><span style="color: red; font-size: 2em;">001</span><span style="font-size: 2em;">101010001010001010</span></p>
<p>The last number in red is <code class="highlighter-rouge">1</code>, which indicates that <code class="highlighter-rouge">2</code> is prime.</p>
<p>In this case, if I asked you to check if 15 is prime, you don’t need to go through all the numbers in the list; All you need to do is skip to 0 . . . 15, and check that single bit.</p>
<p>And for memory usage, the first approach uses 98000000 integers, whereas this one can store 32 numbers in a single integer (using the list of <code class="highlighter-rouge">1</code>s and <code class="highlighter-rouge">0</code>s), so we would need $2000000000/32 = 62500000$ integers.</p>
<p>So it uses about 60% as much memory as the first approach, and is much faster to use.</p>
<p>We store the array of integers from the second approach in a file, then read it back when you run.</p>
<p>So, it uses 250mb of ram per thread you run, which everyone should have.</p>
<h3 id="checking-a-polynomials">Checking a polynomials</h3>
<p>This part is pretty straight forward. We run 3 for loops which check each possibiliy of a, b, and c within certain ranges.</p>
<p>Then, it keeps evaluating until it finds a value which is not prime. Once it does, if the number of primes was greater than 60, or it has at least 40 distinct in a row, it prints the result out.</p>
<p>It uses the file we created above to verify whether each number is prime, by checking the $(an^2+bn+c)$th bit of the list of <code class="highlighter-rouge">1</code>s and <code class="highlighter-rouge">0</code>s</p>
<p>So, say we are testing $f(n) = an^2+bn+c$</p>
<p>We first plug in n = 0, and we test whether $a0^2+b0^2+c$ is prime</p>
<p>Then, n = 1, and so on until the function isnt prime.</p>
Mon, 03 Oct 2016 00:00:00 +0000
http://chemicaldevelopment.us/math/pgs/PGS
http://chemicaldevelopment.us/math/pgs/PGSmathpgsSchool: PE Class Data Analysis<h1 id="cade-brown--gregory-croisdale">Cade Brown & Gregory Croisdale</h1>
<p>We were given info collected about PE (Physical Education) students at L&N, including mile run times, number of push ups in a minute, and curl ups in 2 minutes.</p>
<p><em>You can find all of our info <a href="https://docs.google.com/spreadsheets/d/1xCyK-8ZdUw0QHg36i6ofSmpou7FUmq571E9HOSaphbA/edit?usp=sharing">here</a></em></p>
<p><em>You can go to File>Make A Copy to view and edit</em></p>
<h2 id="responses">Responses</h2>
<iframe width="600" height="371" seamless="" frameborder="0" scrolling="no" src="https://docs.google.com/spreadsheets/d/1xCyK-8ZdUw0QHg36i6ofSmpou7FUmq571E9HOSaphbA/pubchart?oid=37325881&format=interactive"></iframe>
<p>Although some classes had very few responses, $ L $ day and $ N $ day both made up around $ 50\% $ of the total responses, which is what you would expect.</p>
<p>Some classes did not have all members ($ N4 $ only had 1 response), a good number of people from all made up a large database that accurately respresents mosts of the population.</p>
<iframe width="732.9126506024095" height="454.875" seamless="" frameborder="0" scrolling="no" src="https://docs.google.com/spreadsheets/d/1xCyK-8ZdUw0QHg36i6ofSmpou7FUmq571E9HOSaphbA/pubchart?oid=2114194783&format=interactive"></iframe>
<p>Most of the responses were from males, though it wasn’t too horribly biased. There were still $ > 40\% $ females, so it is still quite reliable.</p>
<p>Some explanations might be: females choose not to take PE as much as boys do, or that boys responded at a higher rate than females.</p>
<h2 id="mile-run">Mile Run</h2>
<p><em>All values are in minutes. So, 2.5 is 2m30s</em></p>
<iframe width="1019" height="629.8978061224489" seamless="" frameborder="0" scrolling="no" src="https://docs.google.com/spreadsheets/d/1xCyK-8ZdUw0QHg36i6ofSmpou7FUmq571E9HOSaphbA/pubchart?oid=1875790007&format=interactive"></iframe>
<table>
<tbody>
<tr>
<td>Mean (Average)</td>
<td>Median (Middle Value)</td>
<td>Standard Deviation (How dense is the set?)</td>
</tr>
<tr>
<td>12.3</td>
<td>12.1</td>
<td>3.4</td>
</tr>
</tbody>
</table>
<p>What this tells us is that on average, you will run around a $ 12.25 $ minute mile, and that $ 68\% $ of students run a mile between $ 8.88 $ minute and $ 15.62 $ minutes <em>(which is generated by $ mean \pm deviation $)</em></p>
<p>Lots of students finished in the $ (-\infty, 15] $ range we can see there are significantly more than in the corresponding range, $ [15, \infty] $ respectively.</p>
<p>This makes sense due to the way students flock together when running or jogging.</p>
<h2 id="push-ups-per-minute">Push Ups Per Minute</h2>
<p><em>These values are in pushups per 1 minute</em></p>
<p><img src="/assets/images/APSTATS/PECLASS/pushups.png" alt="Push Up Info Graph" /></p>
<table>
<tbody>
<tr>
<td>Mean (Average)</td>
<td>Median (Middle Value)</td>
<td>Standard Deviation (How dense is the set?)</td>
</tr>
<tr>
<td>12.2</td>
<td>12</td>
<td>8.1</td>
</tr>
</tbody>
</table>
<p>The standard deviation is very large, which means the amounts vary from the mean, which is evident by the few on the far left of the spectrum. Again we seem to see groups emerge, and this means that certain people are staying almost exactly in sync with each other.</p>
<p>We can say that about $ 68\% $ of students do between $ 4 $ and $ 20 $ pushups in one minute. This is a very large margin due to the size of the standard deviation.</p>
<h2 id="curl-ups-per-2-minutes">Curl Ups Per 2 minutes</h2>
<p><em>These values are in curlups per 2 minutes</em></p>
<p><img src="/assets/images/APSTATS/PECLASS/curlups.png" alt="Curl Up Info Graph" /></p>
<table>
<tbody>
<tr>
<td>Mean (Average)</td>
<td>Median (Middle Value)</td>
<td>Standard Deviation (How dense is the set?)</td>
</tr>
<tr>
<td>34.4</td>
<td>30</td>
<td>17.3</td>
</tr>
</tbody>
</table>
<p>The standard deviation is even larger for this dataset, which means the amounts vary more from the mean. This is surely the case, if you look at the right side, there is a group of just over 30 students who did between 60 and 65 Curlups in 2 minutes.
These few threw off the average and standard deviation quite a bit from what it would have been, and based on the evidence, it would seem that people, in general, find curlups much easier than pushups, and a small group finds them extremely easier than pushups.</p>
Tue, 06 Sep 2016 00:00:00 +0000
http://chemicaldevelopment.us/school/pe-class-data-analysis
http://chemicaldevelopment.us/school/pe-class-data-analysisschoolMath: Infinite Sums<h3 id="what-are-sums">What are sums?</h3>
<p>A sum is addition of a sequence of numbers.</p>
<p>The sum of $1, 2, 3, 4$ is $1+2+3+4$, which is $10$</p>
<h3 id="what-are-infinite-sums">What are infinite sums?</h3>
<p>Essentially, infinite sums are the limit when you add an infinitely long sequence of numbers.</p>
<p>For example, if we add $ 1/n $ for n = $1, 2, 3, 4 . . . \infty$, the limit does not exist; it keeps getting larger and larger.</p>
<p>But, if we add $ 1 / (n^2) $ for n = $1, 2, 3, 4 . . .\infty$, the limit does exist. It is roughly $1.645$ (we’ll look at this one a bit lower)</p>
<h3 id="examples">Examples</h3>
<p>Here are some more famous examples of infinite sums (they are values of the riemann zeta function)</p>
<script type="math/tex; mode=display">\sum_{n=0}^\infty \frac{1}{n^2} = \frac{1}{1} + \frac{1}{2^2} + \frac{1}{3^2} + \cdots + \frac{1}{n^2} + \cdots = \frac{\pi^2}{6}</script>
<p>Or</p>
<script type="math/tex; mode=display">\sum_{n=0}^\infty \frac{1}{n^4} = \frac{1}{1} + \frac{1}{2^4} + \frac{1}{3^4} + \cdots + \frac{1}{n^4} + \cdots = \frac{\pi^4}{90}</script>
<p>Or even</p>
<script type="math/tex; mode=display">\sum_{n=0}^\infty \frac{1}{n^{14}} = \frac{1}{1} + \frac{1}{2^{14}} + \frac{1}{3^{14}} + \cdots + \frac{1}{n^{14}} + \cdots = \frac{2\pi^{14}}{18243224}</script>
<p>The first two are examples of infinite sums, and the third is an infinite product. Sum means adding, product means multiply. In all of these examples, we take them out to infinity (theoretically), and this is the answer we would get. In fact, as we go farther, they get very close to these values.</p>
<p>Before I show you these examples, we are going to look at sums a little bit more generally.</p>
<p>I’ve written a JSFiddle so you can enter your own series and watch the value it converges to.</p>
<p>Full version at <a href="https://jsfiddle.net/CadeBrown/tdxofngq/" target="_blank">https://jsfiddle.net/CadeBrown/tdxofngq/</a></p>
<iframe width="100%" height="775" src="//jsfiddle.net/CadeBrown/tdxofngq/embedded/result,js,html/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
<p>You can just type in “n”, and it will show you the sum of 1 + 2 + 3 + 4 + … + n (which happens to be $ \frac{n(n+1)}{2} $)</p>
<p>A few cool sums to try in it: (copy the shaded part into the “series definition” box)</p>
<script type="math/tex; mode=display">\sum_{n=1}^{\infty}\frac{ {(-1)}^n}{n} = -\ln{2} \approx -.693</script>
<pre> pow(-1, n) / n </pre>
<script type="math/tex; mode=display">\sum_{n=0}^{\infty}\frac{ {(-1)}^n}{2n + 1} = \frac{\pi}{4} \approx .785</script>
<pre> pow(-1, n) / (2 * n + 1) </pre>
<script type="math/tex; mode=display">\sum_{n=0}^{\infty}\frac{1}{(n+1)^2} = \frac{\pi^2}{6} \approx 1.645</script>
<pre> pow(n+1, -2) </pre>
<p>Those 3 series above are what are called convergent series. Convergent means that if you keep evaluating more and more terms, it tends towards a limit.</p>
<p>Like $ \ln{2} $, or $ \frac{\pi}{4} $ were the limits of the first and second sum.</p>
<p>The first 3 sums converge quite slowly, and to get $d$ digits of precision to the “actual value” (if we could take it to infinity), we would need roughly $10^d$ terms. So, to get one more digit of precision, we would need 10 times as many terms to sum! That is why the first 3 are not good ways to calculate their sum ($\pi$, $\ln{2}$, etc)</p>
<p>There exists formulas for $\pi$ that require only $\frac{d}{14}$ terms to get $d$ digits, such as this one:</p>
<script type="math/tex; mode=display">\frac{1}{\pi} = 12\sum_{n=0}^{\infty}\frac{(-1)^n(6n)!(13591409+545140134n)}{(3n)!(n)!^3(640320)^{3n+\frac{3}{2}}} \approx 0.318</script>
<pre> 12 * (pow(-1, n) * fac(6 * n) * (13591409 + 545140134 * n)) / (fac(3 * n) * pow(fac(n), 3) * pow(640320, 3 * n + 1.5)) </pre>
<p>With this, we have $\frac{1}{\pi}$ in an efficient series</p>
<p>In fact, that series (with a few optimizations) is how record number of digits of $\pi$ are computed: <a href="http://www.numberworld.org/digits/Pi/ we are currently at $13,300,000,000,000$ digits">Numberworld</a>.</p>
Sun, 22 May 2016 00:00:00 +0000
http://chemicaldevelopment.us/math/infinite-sums
http://chemicaldevelopment.us/math/infinite-sumsmathMath: All about primes<p>First post on this blog, so I thought we would start it out with something interesting, like primes.</p>
<p>We include some JSFiddles so you can see all the code available with it!</p>
<p>So, lets start out with what they are.</p>
<h1 id="what-are-primes">What are primes?</h1>
<p>Most of the time, you might get something like</p>
<blockquote>
<p>A prime is any positive integer greater than one whose only postive divisors are 1 and itself</p>
</blockquote>
<p>but I prefer to say that a prime is any integer that you can’t make by multiplying two other integers.</p>
<p>For example, 2 is the first prime, 3 is the next. 4 isn’t a prime, though, because 4 = 2 * 2, which means it has other divisors (2), and thus can be made my multiplying two other integers.</p>
<p>I’ve written a little JSFiddle so that you can see if a number is prime. This is a <em>very</em> unoptimized version of primality testing (testing if a number is prime), but you can see how a basic version works.</p>
<p>Full version at <a href="https://jsfiddle.net/CadeBrown/x9h5buwa/" target="_blank">https://jsfiddle.net/CadeBrown/x9h5buwa/</a></p>
<iframe width="100%" height="775" src="//jsfiddle.net/CadeBrown/x9h5buwa/embedded/result,js,html/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
<p>This program takes the remainder dividing your input by all numbers less than it (actually, the square root of it, but that is a simple optimization), and if it is zero, that means the number is divisible by some other number, and is therefore not prime.</p>
<p>One common question is</p>
<blockquote>
<p>Why isn’t 1 or 0 prime?</p>
</blockquote>
<p>And this was a large argument for years. 1 and 0 are not considered prime for a few reasons. The first is the nice property that is called unique factorization, which states that any given integer has exactly one way to factor into primes. For example, 12 = 2 * 2 * 3, and you can’t get 12 from any other primes than 2, 2, and 3. If we said that 1 is a prime, we could have 12 = 2 * 2 * 3 and 12 = 2 * 2 * 3 * 1 . We have agreed that this is a nice property to have. 1 is what is called a unit. As is negative one, which brings us to our next question:</p>
<blockquote>
<p>If 2 is a prime, then isn’t -2 ?</p>
</blockquote>
<p>And the answer is: Sort of.</p>
<p>This is because -2 is similar to +2, one is multiplied by the unit 1, while the other is multiplied by the unit -1 . We only consider a number prime if it is positive, though.</p>
<blockquote>
<p>Are there infinitely many primes?</p>
</blockquote>
<p>Yes, there are. Primes get very far apart (however, there are infinitely many primes <em>exactly</em> 246 apart (<a href="https://www.quantamagazine.org/20141210-prime-gap-grows-after-decades-long-lull/" target="_blank">https://www.quantamagazine.org/20141210-prime-gap-grows-after-decades-long-lull/</a>))</p>
<p>I’ve written a little fiddle to graph how quickly the number of primes grows, and a few approximations to the actual line</p>
<p>Full version at <a href="https://jsfiddle.net/CadeBrown/cfg8bgLt/" target="_blank">https://jsfiddle.net/CadeBrown/cfg8bgLt/</a></p>
<iframe width="100%" height="800" src="//jsfiddle.net/CadeBrown/cfg8bgLt/embedded/result,js,html/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
<h1 id="history-of-primes">History of Primes</h1>
<p>Primes have been in people’s thoughts ever since hunter-gatherer days (They thought about dividing food up. How do you give out 13 orange to 3 people?).</p>
<p>Primes are something that are so tangible, like rearranging fruits to divvy up, but yet so mysterious, we don’t even know if there are infinitely many primes that differ by 2!</p>
<p>People have studied primes initially for dividing up resources, which is still useful today, but primes are also used in cutting edge technologies, such as cryptography. While I won’t get into cryptography in this post, suffice it to say that bigger primes are more secure to encrypt data and then decrypt it because the hacker in between doesn’t have the computing power to factor out large primes (which is a very computation-heavy task).</p>
<p>Currently, the largest known prime is $ 2^{74,207,281}-1 $ which is more than 22 million digits long!</p>
<p>The largest prime found by hand was $ 2^{127} - 1 $, or $ 170,141,183,460,469,231,731,687,303,715,884,105,727 $ Imagine doing that by hand!</p>
<p>Just think about that for a second. No two integers can be multiplied to get $ 2^{127} - 1 $, but $ 2^{127} $ is just 2 multiplied by itself 126 times!</p>
<p>Another reason I like that number is the fact that $ 2^{127} - 1 = 2^{2^{7} - 1} - 1 = 2^{2^{2^{3} - 1} - 1} - 1 = 2^{2^{2^{2^{2} - 1} - 1} - 1} - 1 $</p>
Thu, 19 May 2016 00:00:00 +0000
http://chemicaldevelopment.us/math/software/all-about-primes
http://chemicaldevelopment.us/math/software/all-about-primesmathsoftware