|
|
If you're having trouble viewing this whole animation, try getting
rid of a row of browser buttons up top. If you still can't see it all,
at least make sure you can see the
bottom of the animation. Ok, let f(x,y) = x(x-20)(y-20)sin(y/1.5) + y(y-20)(x-20)sin(x/2). This is the function that's plotted in the animation over 0 < x < 20, and 0 < y < 20. The plot is a contour plot, with lighter colors representing higher values of the function. The function is constant along the curves that divide regions of different lightness. Let's assume lighter colors represent higher concentrations of some nutrient that the little orange ball (LOB) needs to survive. And let's suppose that millions of years of evolution has endowed the little orange ball with the ability to sense in which direction the nutrient concentration increases most rapidly, and the ability to move in that direction. Evolution is great. Ok, so at the start of the animation you click and drag the little orange ball from the point (x=0, y=0) to some other point on the graph. Then press the button. Unless you unwisely chose a spot where the nutrient concentration doesn't increase noticably in any direction, the ball should start to move, only stopping when it either reaches a local concentration maximum, or it reaches a point where it can no longer detect much of a difference in concentration gradient in any given direction. To program this behavior, I had the LOB always move in the direction of the gradient, (fx, fy). I didn't actually bother calculating these two partials, but used the approximations: fx ~ (f(x+0.1, y) - f(x,y))/0.1, and fy ~ (f(x, y+0.1) - f(x,y))/0.1. Then at each point I had the LOB move off a bit in the direction of this approximate gradient vector. Because the gradient is always perpendicular to the curves along which f(x,y) is constant, you should see it cross each of the constant value curves on the graph at pretty close to a right angle. So you should be able to predict fairly accurately where the LOB will go from any point you start it. As was mentioned previously, the paths the LOB follows may not be the most direct paths to local concentration maxima (they'll seldom be straight), but they're the best that evolution is likely to come up with. |