Hacker News new | past | comments | ask | show | jobs | submit login
The unreasonable effectiveness of mathematics (rongarret.info)
84 points by lisper on Feb 9, 2015 | hide | past | favorite | 31 comments



Over the years I've found that whenever I want to make something look sort-of-physical, it winds up being quicker and easier to use real physics than to hack up something that isn't physics-based but looks close enough.

For example, I once made a wave animation just like the one in this post (in 2D but otherwise the same), thusly:

1. Make an array of height values initialized to zero

2. Run a tick() function that applies a spring force between neighboring values, then updates their position/velocity

3. Perturb the middle value by a large amount

Not exactly real fluid mechanics but convincing enough. Perhaps best of all, fine-tuning is easy because the model matches your intuition - if you want the fluid to look more viscous you don't need to guess what to tweak, you just dampen the velocities, etc.


This post gave me a great nostalgia moment and I imagine others have similar experiences.

I remember trying to code a basic platformer at a young age in BASIC or something similar. Moving around the character and jumping are the most basic, essential functions.

I tried to reason it out. Ok, so start off slow, after the character has been moving for a bit speed him up. For jumping, add some positive velocity and reverse it after a bit.

It took forever to fine tune and still didn't really work that well. I gave up in the end. We didn't have the Internet then and I didn't really think about asking the librarian or similar 'how can i make a character jump about'.

Fast forward a few years and my schoolteacher introduced the concept of Newtonian mechanics. Acceleration as a rate of change of velocity; the idea of a ballistic trajectory as a quadratic.

Suddenly the problem becomes trivial! That eureka moment I can probably point to as the defining thing that made me choose to study higher level physics.

(Part of it was probably being young and not having the reasoning skills I do now - but I also often think about how access to information is so different now. What would the ten year old me have done with access to Wikipedia? Mind boggling.)


You may already know this, but actually even a lot of modern game engines use nonphysical methods for moving characters - it's hard to make the character feel responsive using only impulses and friction, etc. I'm working on such an engine at the moment, and it wound up taking some hacking (e.g. I turn off the player's friction when a movement key is pressed - which makes sense when you think about it but seemed nonphysical at first!).

With that said, you've reminded me of an example of this. Years ago I was making a "UFO catcher" crane game in Flash, where the user moves a thingy left and right, and an attached crane arm swings freely like a pendulum. At first I thought: this isn't a damned physics simulation, I'll just hack something up. Then I spent probably a whole day trying to get it to not feel so wrong. Then finally I break down and get the formula for pendulum motion off wikipedia, and 15 minutes later it works perfectly - with maybe three lines of physics code. :D


This approach is effective, but is stateful and iterative. There's elegance and quite likely reduced computational load in a functional approach that can give the wave height value with only the inputs of the coordinates and time. That's what the post is going for here.

Wave phenomena are a curious intersection of functional and imperative paradigms in real life. Of course the real atoms find their positions by stateful interactions over time, but the behavior should approach the pure mathematical definition of the wave functions.


> There's elegance and quite likely reduced computational load in a functional approach that can give the wave height value with only the inputs of the coordinates and time.

Sure, except there isn't any known closed-form expression that can model water waves in cases like the author is aiming for. (In the steady state water waves are roughly trochoidal, not sinusoidal, if you're interested.)

What happened in this article was that the author started with a mental image of what a water drop looks like, then hammered on a sin function until there was a resemblance. That's fine in and of itself, but he might as well have drawn a picture! Whatever resemblance he did or didn't achieve to actual water was a function of how good his mental image was and how long he spent working on the similarity, not a byproduct of the math involved.

What's nice about my awful stateful approach is that the physicality arises unbidden. If you code it up it will behave like water all on its own - you won't have to randomly fiddle with it like the article's author.

Also, with my version you don't have to start out knowing what water waves look like. It will show you. ;)


I liked the explanation of the physics of why there should be a spike. But I don't see the relationship to the original equation. It seems to me that it's just a coincidence that the original equation had a spike.


The explanation is no explanation at all. It is true that water has inertia, and it is true that water has to go somewhere. It is not true that this is sufficient to explain why the water goes up.

In particular, the statement "because of inertia and the fact that water is not compresible, it has to keep moving" is false.

The fact that water is not compressible means that the water moving in one direction is capable of exerting an extremely large force on the water moving in the other direction when they run into each other, which would bring the water to a halt as the hole closes. The interesting question is: why doesn't this happen?

One possibility is that the free surface at the bottom of the hole travels upward due to what amounts to a buoyancy force (think of the hole as a bubble with no top). The water pressure at the bottom of the hole is the same as it is everywhere at that depth, and so the bottom move upwards, and this pressure force creates upward momentum that is not met by any opposing force when the bottom of the hole reaches the water's surface, and therefore creates an upward-moving column of water.

One way of testing this would be by inserting an empty pipe into the water against a flat disk of the same diameter, and then rapidly pulling the pipe out. The flat disk would impede water from moving upward into the hole, which would--on my account--dramatically reduce the size of the spike.

As to the "unreasonable effectiveness of mathematics", the argument is bogus: http://www.tjradcliffe.com/?p=381 Our mathematical descriptions of reality almost all admit of extraneous solutions that have to be discarded based on physical--not mathematical--considerations. This is what you would expect if mathematics was a human-made tool for describing reality. It is not at all what you would expect if mathematics was somehow the pre-existing armature upon which physical reality was constructed.


I think that you're responding to an extreme interpretation of the "unreasonable effectiveness of mathematics". I don't think you have to believe that nature follows perfectly simple mathematical rules to be surprised to the extent that mathematics is effective at describing physical reality.

You make a good point, that mathematics is often designed and invented to describe reality. You need to take into account the fact that a lot of what you "get out" of mathematics has already been "put in". But it is my opinion that even accounting for this, it is quite frequent that you "get out" more than you "put in" to mathematics.

I think a strong set of examples of this sort of behavior is when attempts to address one problem in a mathematical theory often end up addressing other seemingly unrelated problem. The introduction of quantized energy states to explain the blackbody radiation distribution then goes on to explain the photoelectric effect. (I'm not too familiar with what physical phenomena were observed before QM but needed QM to explain them to give more examples).

Now you might say "well of course this theory solves both issues, because they are essentially the same phenomenon, and so there's nothing surprising about your theory explaining what it was designed to explain". But that's precisely the point, that mathematics gives us the tools to see relations between things that on the face of them are different. And that there's no reason that this /has/ to be true (without appealing to mathematics), makes the fact that it is true seem surprising.

Of course, being surprising, or unreasonably effective, etc is a relative statement. Certainly to someone who expected the universe to be described mathematically to precisely the degree that it is in reality, nothing would be surprising. But I think to most people who haven't been introduced to mathematics (kids), the power it gives you certainly is surprising.


    The fact that water is not compressible means that the water moving in one direction is capable of exerting an extremely large force on the water moving in the other direction when they run into each other, which would bring the water to a halt as the hole closes. The interesting question is: why doesn't this happen?
Why would you expect that to happen? The hole in the water is an area of low pressure that the water is going to rush in to fill. Now that water has a lot of kinetic energy and momentum. Why would it suddenly lose that momentum? And how does water's incompressible nature help that? Surely, if anything, this contributes to the difference in resistance between the water and the air and help explain the spike that you initially see.


Just wanted to say I liked reading your blogpost!

Maybe we (humans) have tendencies to put math into the role we often evict mainstream religion from.


It is probably not even possible to model how a drop hits the water with only a 2D cross-section. You probably need three dimensions to model it correctly.

In its present form, it is more like modeling how an infinitely long cylinder is hitting the surface of the water.


Everything is radially symmetric, so a 2D polar coordinate system should be accurate.


True, but note that if you do an actually simulation, waves act fundamentally differently in spaces of odd and even dimension.


As near as I can tell the graphs seem to be mirrored around the origin - that is, they're graphs of abs(x), not x. Which naturally causes a discontinuity for any function whose slope isn't zero at the origin...


It's discontinuous if the value is undefined at the origin. That happens here because the denominator of (x + t) yields a division by zero. A nonzero slope would give a kink in the curve, but not a discontinuity.

One approach to avoiding the whole question of abs(x) would be to use cosine instead of sine, since cosine is symmetric across x = 0.


> One approach to avoiding the whole question of abs(x) would be to use cosine instead of sine, since cosine is symmetric across x = 0.

I don't think that this would work, since the division by an odd function would just make it odd again (that is, `sin(x)/x` is even precisely because `sin` is odd). Note, however, that blaming `abs` for discontinuity (or non-differentiability) is a bit of a red herring; any even function on the real line, no matter how smooth, can be written as a composition with `abs`.


Hurmph. I don't see how it makes much difference whether he uses sine or cosine, since he's also adding t to the operand and then animating over it, causing the waveform to move along the x-axis. He can use one and start from t=0 or use the other and start from t=pi/2, as you like.

My point was simply that the "spike" the article goes on about (which I earlier called a discontinuity, oops) shows up because the author is reflecting his plot around the Y axis. The article makes it sound like the spike was some physically significant feature of the function being graphed.


I agree that it doesn't make any difference when you allow phase shifts (I was intentionally focussing on the `t = 0` case), so I'm puzzled by your suggestion that the author should have used cosine instead.

My point was more that there's nothing inherently 'spiky' about even functions; as your own example of cosine shows, they can be just as smooth (or spiky) as any other function.


I think you're conflating people, if that was in reply to my immediately previous post.


Yes, you're right—I thought that you had made the post that was actually made by T-hawk (https://news.ycombinator.com/item?id=9022743 )—but I think that it doesn't change my point.


> As near as I can tell the graphs seem to be mirrored around the origin - that is, they're graphs of abs(x), not x. Which naturally causes a discontinuity for any function whose slope isn't zero at the origin...

I think that you mean they are graphs of x ↦ f(abs(x)), not just f; and that this causes a point of non-differentiability, not necessarily a discontinuity. Of course, the even extension x ↦ f(abs(x)) of any continuous function `f` on the non-negative real numbers is again continuous (because `abs` is).


It threw me for a bit that x here refers to the distance from the origin, whether or not that distance is leftwards or rightwards.

Anyway, the function's being described isn't really the way water waves actually work, is it? Surely, dropping a stone in water does not start out disturbing every portion of the water immediately like "sin(x)/x", but rather, the disturbance only emanates out over time from the origin, with at any moment only so much water disturbed. (Then again, I'm not a physicist, so what do I know?)


You're right, but the inaccuracy is a consequence of the differential equation model's assumptions rather than a math error. You'll see the same unphysical instantaneous propagation in simple models of heat flow and diffusion. Accounting for laggy propagation, although more realistic, is difficult and usually unnecessary in the classical regime with a few major exceptions, most notably that magnetism is actually just the "lag" in electric forces, hence "electromagnetism."


> most notably that magnetism is actually just the "lag" in electric forces, hence "electromagnetism."

I've never heard that before! Is there any place that I can read about it?


> Anyway, the function's being described isn't really the way water waves actually work, is it?

That's exactly right. In fact, that is one of the interesting features of math: you can often get the right answer even when the math is completely unjustified! This actually happens more than you might think. Quantum mechanics was essentially discovered this way. Even the classical mechanics literature is chock-full of wrong math that happens to give the right answer. See:

http://mitpress.mit.edu/sites/default/files/titles/content/s...


> In fact, that is one of the interesting features of math: you can often get the right answer even when the math is completely unjustified!

As a mild nitpick, I would say that this is a feature of mathematical physics. A mathematician on his or her own would not be satisfied with getting the 'right' answer by wrong methods—in fact, would have no way to judge what is 'right' except by appealing to right methods (there being no outside arbiter who can decide the matter independently, as is the universe itself in mathematical physics).


> Anyway, the function's being described isn't really the way water waves actually work, is it?

No relation at all. They just look similar insofar as all smooth wave functions look sort of similar at small enough amplitudes.

But yeah, the sinusoidal equation doesn't show the initial perturbation, since it's not modeling a perturbation at all.


That animation doesn't resemble a water wave at all. In a water wave, every single point of the surface does a circular movement (elliptic in shallow water). This resembles a transverse wave at best. It doesn't even look like the surface of a water wave. Take a look at this (for instance): http://www.acs.psu.edu/drussell/demos/waves/wavemotion.html


Sure - I said they look similar "insofar as all smooth wave functions look sort of similar", which is to say, only to the extent that they're both waves. But none of the interesting physical characteristics of a water wave are present.


Very nicely done! Love the graphics and the video. BTW, what is your pay grade?


Thanks! :-)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: