Friday, December 19, 2008

iron's odor

Well, just a short post on an interesting finding. I was curious why iron tends to produce strange metallic smells (it occurs to some other metals as well as blood), and it looks like a quick Googling gives me a neat explanation of this phenomenon. Go check it out.

It's funny that some common phenomena can be so easily ignored, and we never get to appreciate the science behind it.

Saturday, December 6, 2008

numerical pendulum

There was this "flash of idea" that I could solve "any" differential equations numerically, which implies I could "simulate" Maxwell's differential equations using a computer program. Sadly, that was too tall an order, so I could only manage to simulate the most basic of differential equations.

So far I managed to derive a simple method to simulate pendulums directly using the rigid pendulum equation (c is a negative constant)m
\frac{\mathrm{d}^2\theta}{\mathrm{d}t^2} = c \sin \theta
I do know Euler's method, which is really simple. But how do I apply it to second derivatives? That's the trick here.

I found that if I broke this equation into two by defining a variable ω,
\begin{align*} \omega &= \frac{\mathrm{d}\theta}{\mathrm{d}t} \\ \frac{\mathrm{d}\omega}{\mathrm{d}t} &= c \sin \theta \end{align*}
I can easily apply Euler's method using the finite differences approximation,
\begin{align*} \frac{\Delta \theta}{\Delta t} &= \omega \\ \frac{\Delta \omega}{\Delta t} &= c \sin \theta \end{align*}
Therefore, I can convert this into a form useful for programming,
\begin{align*} \Delta \omega_i &= c \sin \theta_i \Delta t \\ \Delta \theta_i &= \omega_i \Delta t \\ \omega_{i + 1} &= \omega_i + \Delta \omega_i \\ \theta_{i + 1} &= \theta_i + \Delta \theta_i \end{align*}
This is easily done by iteration; simply keep track of the index i and the values of ω and θ. By choosing the Δt to be small, one can approximate the pendulum with some precision. I have tested the method and it seems to be quite stable, though I'm not sure how good the precision.