I was noodling around with some graphics code the other day to try to produce some schematic representations of water waves for a book that I'm working on. I wanted to produce a little animation of what happens when you throw a stone into a pond. It didn't have to be very flashy, I just wanted it to be qualitatively correct, that is, I wanted to produce a drawing of a wave that spread out from a central source and decreased in amplitude with time and distance from the source. So I started out with the venerable sin(x)/x function:
There, right in the center of an actual physical water wave, was my spike! It didn't have a pointy end: surface tension had made the point shrink up into a sphere, but the spike was unmistakable. It was as if the math was trying to take me by the throat and tell me, "No, water really does work this way."
In retrospect it is actually obvious why water has to work this way. You drop a stone into a pond and the stone makes a hole in the water. The stone keeps falling through the water (because the stone is denser), and as soon as it has moved out of the way, water rushes back in from all sides to fill the hole. All that water rushing in meets at the center of the hole, and because of inertia and the fact that water is not compresible, it has to keep moving, so it has to go somewhere. The only place left for it to go is up.
In 1960 Eugene Wigner published a famous paper entitled "The Unreasonable Effectiveness of Mathematics in the Natural Sciences" which first pointed out this phenomenon, that math often "takes you by the throat" and forces you towards the correct answer even if it sometimes takes people a while to realize that this is what is going on. I thought it was cool to experience this phenomenon firsthand.
 The reason the spike is there, mathematically speaking, is that the function sin(x-t)/(x+t) must be zero when x=t and t>0, but the limit of the function as x->t from above is -1. So at t=0 it has to look like -sin(x)/x, but at t=epsilon it has to have two zero-crossings at x = +/- epsilon. The only way to satisfy that condition, along with continuity constraints, is to have a spike. It is might even be possible to prove that no mathematical function can possibly produce all the desired qualitative characteristics of water waves (damping, forward motion in time, conservation of mass) without a spike, but that's above my pay grade.
> It is might even be possible to prove that no mathematical function can possibly produce all the desired qualitative characteristics of water waves (damping, forward motion in time, conservation of mass) without a spike, but that's above my pay grade.
Simulating conservation laws is quite hard; doing so with fluids in computer graphics may not be a solved problem in any general sense. Have you heard of symplectic integrators? I believe that they work for some N-body problems. Have you investigated how quickly double-precision floating-point fails for a naive implementation of the 2-body problem?
Flailure is always an option
This post is nicely consonant with the prior post on T.J. Radcliffe's blog.
One of the parts I admired about his blog post is this:
"I mention this because we rarely see what goes on behind the scientific curtain. There is always a lot of flailing around, a lot of trial and error. Young people in particular may not be aware of this and feel that their own flailings are uniquely embarrassing. They are not. Flailure is always an option, and often quite a good one."
This jives with my own experience. You may have the overall structure of a program worked out, then you get hung up on one little unexpected piece -- and it takes you hours (or days) to resolve it.
Well I tried the water drop with sin(x^2+y^2)/(x^2+y^2)
I think you want a cylindrical Bessel function.
Yes, but that's one of the really interesting things about this: I ended up making an accurate prediction of physical behavior despite the fact that I had the math completely wrong!
Post a Comment