<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>4by12 &#187; Uncategorized</title>
	<atom:link href="http://4by12.com/blog/archives/category/uncategorized/feed" rel="self" type="application/rss+xml" />
	<link>http://4by12.com/blog</link>
	<description>by Guy Gur-Ari</description>
	<lastBuildDate>Sat, 21 Aug 2010 00:01:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>The Missing Comment</title>
		<link>http://4by12.com/blog/archives/274</link>
		<comments>http://4by12.com/blog/archives/274#comments</comments>
		<pubDate>Tue, 01 Sep 2009 11:28:28 +0000</pubDate>
		<dc:creator>Guy Gur Ari</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://4by12.com/blog/?p=274</guid>
		<description><![CDATA[Over on The Gauge Connection I was engaged in a lively discussion about the arrow of time with the blog owner, Marco Frasca. For some reason he decided to censor my latest comment, and notify me he will not publish anything else by me on his blog. Touchy, touchy. Seeing as I have an acute [...]]]></description>
			<content:encoded><![CDATA[<p>Over on <a href="http://marcofrasca.wordpress.com/2009/08/31/the-question-of-the-arrow-of-time/">The Gauge Connection</a> I was engaged in a lively discussion about the arrow of time with the blog owner, Marco Frasca. For some reason he decided to censor my latest comment, and notify me he will not publish anything else by me on his blog. Touchy, touchy.</p>
<p>Seeing as I have an acute allergy to censorship, I will publish my last comment here, as long with anything else Marco chooses to censor. If you are interested in the nature of the arrow of time, you may want to head over to <a href="http://marcofrasca.wordpress.com/2009/08/31/the-question-of-the-arrow-of-time/">The Gauge Connection</a> for the discussion, and then come back to read my missing comment (below). You can decide for yourself who is right.</p>
<p>For more information, <a href="http://motls.blogspot.com/2009/08/arrow-of-time-understood-for-100-years.html">The Reference Frame has a good post</a> on the subject. I am also working on a series of posts that I hope will demystify the second law of thermodynamics, entropy, and the arrow of time.</p>
<p>Here is my missing comment:</p>
<blockquote><p>>> Of course, even if we are physicists (are you?),</p>
<p>Yes.</p>
<p>>> definitions are important. For one reason, when one goes to do measurements, vagueness can be of no help and our main tool is mathematics. Sloppiness should be rejected on any ground.</p>
<p>Was I vague? Sloppy? I defined exactly a test for whether or not there is an arrow of time. You can do this test in a laboratory, and you can do it in a simulation.</p>
<p>The test is experimental, not theoretical, so the only mathematics you need is the ability to count. Before we try to build a theory, we should have some measurements that we are trying to explain, no? We are talking about some physical phenomenon here, right? Or do you want to have a philosophical discussion?</p>
<p>It’s kind of funny that earlier you lectured me about what is science, and now you make this strange claim that seems to suggest mathematics comes before experiment…</p>
<p>You keep talking about the arrow of time, yet you refuse to discuss what is or is not an example of an arrow of time. You say we are drowning in definitions, so I suggest a simple test. You don’t even say whether you accept this test; you wave it away claiming it’s `vague’, while clearly the opposite is true. And yet, you refuse to provide a definition, an example, or a test of your own for what is the arrow of time… Why are you trying to keep this discussion on a philosophical level, instead of actually drilling down to the heart of the matter?</p>
<p>>> I do not need to do your simulation.</p>
<p>Again, you are ignoring my simple question. Here it is again: What is the result of the test I suggested? Will you not even grant me the answer to this simple question?</p>
<p>I am not yet trying to draw any conclusions, I’m just asking — what is the result of the experiment? What is the result of the simulation?</p>
<p>>> I take two liquids both in equilibrium</p>
<p>Well no, not really. I am taking two liquids in a specific microstate. This is not an equilibrium. I am repeating the experiment many times, but each time I am starting in a specific microstate. Not in equilibrium.</p>
<p>Talking about equilibrium is already trying to model the system using statistical mechanics. But the confusion lies in the transition from deterministic mechanics to statistical mechanics, so I am not using statistical mechanics — I’m sticking to the most basic things.</p>
<p>>> and I make them mix.</p>
<p>No. I let them evolve according to Newton’s laws. We want to see whether they mix or not, and this is why we do the experiment.</p>
<p>>> You can change these distributions as you like, making them unphysical if you want, but the problem will remain.</p>
<p>Again, what is this `problem’? All I did was suggest an experiment and a simulation. I haven’t drawn any conclusions. How can there already be a problem?</p>
<p>>> The question should be: Who puts such deterministic systems with such initial probability distributions?</p>
<p>What do you mean by `who puts’? I am trying to learn how a deterministic system evolves in time. I say: If the laws of nature are deterministic, and I do this experiment, what will be the result? I am not claiming that this describes nature.</p>
<p>>> In conclusion, you introduce an arrow of time since the start and you are a step below Boltzmann.</p>
<p>How did I introduce an arrow of time? Does determinism introduce an arrow of time? Does the distribution for the initial conditions introduce it? Please explain.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://4by12.com/blog/archives/274/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with PDEs</title>
		<link>http://4by12.com/blog/archives/93</link>
		<comments>http://4by12.com/blog/archives/93#comments</comments>
		<pubDate>Tue, 01 May 2007 01:58:43 +0000</pubDate>
		<dc:creator>Guy Gur Ari</dc:creator>
				<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Physics]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://4by12.com/blog/archives/93</guid>
		<description><![CDATA[I just finished working on a numerical simulation of a set of partial differential equations (PDE). I developed these equations for a physics research project I&#8217;m involved in. The equations did not seem to be solvable analytically, so I had to do it numerically. This was my first attempt at solving a PDE, and writing [...]]]></description>
			<content:encoded><![CDATA[<p>I just finished working on a numerical simulation of a set of partial differential equations (PDE). I developed these equations for a physics research project I&#8217;m involved in. The equations did not seem to be solvable analytically, so I had to do it numerically. This was my first attempt at solving a PDE, and writing the simulation turned out to be much more involved than with ordinary differential equations. Here are a couple of interesting pitfalls I encountered.</p>
<h2>PDE Primer</h2>
<p>In case you&#8217;re not familiar with the terminology, I&#8217;ll first explain what a PDE is. A simple equation contains one or more unknowns which represent numbers. For example: <img src='/latexrender/pictures/864a9b719133447ea244573cb054ddfb.png' title='x^2-x-1 = 0' alt='x^2-x-1 = 0' align=absmiddle>. An ordinary differential equation (ODE) is similar, except the unknown is a function rather than a number. Such an equation involves derivatives of the function. Here is an example:</p>
<p><center><img src='/latexrender/pictures/68d6a3d320e55151a2a773697c038965.png' title='f\prime(x) = f(x)' alt='f\prime(x) = f(x)' align=absmiddle></center></p>
<p>-<br />
The solution of this particular equation is <img src='/latexrender/pictures/3a1a0d583b0595d7e871ff3da1462c04.png' title='f(x) = c e^x' alt='f(x) = c e^x' align=absmiddle>, where <img src='/latexrender/pictures/4a8a08f09d37b73795649038408b5f33.png' title='c' alt='c' align=absmiddle> can be any number. Finally, a partial differential equation (PDE) involves a function that has two or more parameters, and includes partial derivatives of this function. For example, the following equation describes waves propagating through a medium:</p>
<p><center><img src='/latexrender/pictures/4a573760921c4497b5eff45969b866c9.png' title='\frac { \partial^2 f } { \partial t^2 } = v^2 \, \frac { \partial^2 f } { \partial x^2 }' alt='\frac { \partial^2 f } { \partial t^2 } = v^2 \, \frac { \partial^2 f } { \partial x^2 }' align=absmiddle></center></p>
<p>-<br />
PDEs are very important in physics. In fact, many of the basic laws of nature are described as PDEs. Examples include Maxwell&#8217;s equations, Shcrodinger&#8217;s equation, and Einstein&#8217;s field equations.</p>
<p>On to the simulation!</p>
<p><!-- more --></p>
<h2>Pitfall 1: Exploding Waves</h2>
<p>So, I built my model for the problem, derived the equations, and was ready to solve them. By &#8216;solving&#8217; I mean that I start out with the known function at time t=0, and I want to find out what that function is at a later time. My function initially looked like this:</p>
<p><center><img src="http://4by12.com/blog/wp-content/uploads/2007/05/rho0.gif"></center></p>
<p>Some thousands of time-steps later, it evolved into this:</p>
<p><center><img src="http://4by12.com/blog/wp-content/uploads/2007/05/rho1.gif"></center></p>
<p>So far so good, but then it completely exploded:</p>
<p><center><img src="http://4by12.com/blog/wp-content/uploads/2007/05/rho3_fix.gif"></center></p>
<p>Going back a bit in time, I was able to trace the beginning of this explosion:</p>
<p><center><img src="http://4by12.com/blog/wp-content/uploads/2007/05/rho2.gif"></center></p>
<p>And zooming in on the &#8216;wavy&#8217; part:</p>
<p><center><img src="http://4by12.com/blog/wp-content/uploads/2007/05/rho2_zoom.gif"></center></p>
<p>It looked as though waves were forming on my function, and then &#8216;exploding&#8217;. </p>
<p><H2>Inherent Instabilities</h2>
<p>I was certain I had a bug, but I couldn&#8217;t find it. While debugging, at one point I decreased the spatial resolution &#8212; using less points per unit of space to describe the function&#8230; and the problem was gone! So, <i>decreasing</i> the accuracy of my solution actually solved the instability&#8230; That was very weird.</p>
<p>Mentioning this to a Ph.D student at the lab, he said this problem sounded familiar to him. And as it turns out, this is a universal problem with PDEs: If the time step is too large compared with the spatial resolution, the amplitude of small waves with short wavelengths quickly increases with time until they dominate the solution. This is due to the way numerical derivatives are calculated. The difficulty here is that the time step needs to be incredibly small, making calculation unfeasible. For some equation, the situation is even worse, as they are unstable for any time step, no matter how small.</p>
<p>For simple PDEs, it is very easy to see this effect by taking the function f to be a wave, and watching what happens to the amplitude over time. You can see a derivation of this result <a href="http://farside.ph.utexas.edu/teaching/329/lectures/node79.html">here</a>. For a more in-depth discussion, Numerical Recipes is your friend. This method of analyzing equations is called von Neumann stability analysis.</p>
<h2>In Comes Lax</h2>
<p>Okay, so I found out not alone, but what can be done to solve this problem? The first thing I tried was to calculate the derivative more accurately. There is a method called Savitzky-Golay, where you fit a polynomial to your function at each point, and calculate the polynomial&#8217;s derivative at that point. The brilliant thing is that this whole operation (fit + derive) can be done using a single convolution, which costs a meager O(n log n) of processing time.</p>
<p>So I implemented S-G, only to discover it doesn&#8217;t solve the problem. More on that in a future post.</p>
<p>As it turns out, there is an incredibly simple solution due to Lax, which says the following. When advancing the function value to the next time step, you do something like this for each position:</p>
<p><center><img src='/latexrender/pictures/3de923578d6c440441bbc686d59bc5bf.png' title='f[j] = f[j] + \frac { \partial f } { \partial t } [j] * dt' alt='f[j] = f[j] + \frac { \partial f } { \partial t } [j] * dt' align=absmiddle></center></p>
<p>-<br />
The Lax method says that the f[j] at the right-hand side should be replaced by an average of it&#8217;s neighboring cells:</p>
<p><center><img src='/latexrender/pictures/08f7b12d31b3ef545da95e66ae44b89a.png' title='f[j] = \frac{f[j-1] + f[j+1]}{2} + \frac { \partial f } { \partial t } [j] \; dt' alt='f[j] = \frac{f[j-1] + f[j+1]}{2} + \frac { \partial f } { \partial t } [j] \; dt' align=absmiddle></center></p>
<p>-<br />
And that&#8217;s it! This replacement causes a numerical diffusion that &#8216;sedates&#8217; the unruly waves, causing them to decay instead of explode. The time step used in the simulation still needs to be below some value, but now it decreases linearly with the spatial distance dx, which is much better than before. So Lax saved the day &#8212; and that was the end of my first pitfall. This is getting to be quite a long post, so I&#8217;ll describe the second problem in another post. Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://4by12.com/blog/archives/93/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Prime Numbers</title>
		<link>http://4by12.com/blog/archives/54</link>
		<comments>http://4by12.com/blog/archives/54#comments</comments>
		<pubDate>Thu, 29 Jun 2006 17:21:31 +0000</pubDate>
		<dc:creator>Guy Gur Ari</dc:creator>
				<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Riddles]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://4by12.com/blog/archives/54</guid>
		<description><![CDATA[Here&#8217;s a nice one. Show that, for any prime number p other than 2 and 5, there is a multiple of p that is written as a series of 1&#8242;s in decimal representation. For example, 111 is a multiple of 3, and 11 is a multiple of itself. Hint: Use the pigeonhole principle. The solution: [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a nice one. Show that, for any prime number p other than 2 and 5, there is a multiple of p that is written as a series of 1&#8242;s in decimal representation. For example, 111 is a multiple of 3, and 11 is a multiple of itself. <b>Hint:</b> Use the pigeonhole principle.</p>
<p><span id="more-54"></span></p>
<p><b>The solution:</b> First, let&#8217;s show that there&#8217;s a multiple of p that is written as a series of 1&#8242;s, followed by a series of 0&#8242;s (e.g. 1111000). Consider the set of numbers {1, 11, 111, 1111, &#8230;}. For each item, calculate its &#8216;modulu p&#8217;: {1 mod p, 11 mod p, &#8230;}. Each of these is an integer between 0 and p-1. Because the original set is infinite, it must therefore contain two different items that are the same mod p (pigeonhole principle). Let&#8217;s call them a and b and assume a>b. Then (a-b) is the desired number, because:<br /> (a-b mod p) = (a mod p) &#8211; (b mod p) = 0.</p>
<p>Okay, so for the prime p we have a number x that&#8217;s divisable by p, and:</p>
<p>x = 111&#8230;10&#8230;0 = 111&#8230;1 * 10^n</p>
<p>We can divide x by 10^n to get rid of the zeros and get y = x / 10^n = 111&#8230;1. y is still divisable by p because p isn&#8217;t 2 or 5.</p>
]]></content:encoded>
			<wfw:commentRss>http://4by12.com/blog/archives/54/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
