Mathcad and Coriolis Forces

Fig. 1. Search of the minimum of a multidimensional function

Fig. 2. A trace of minimization of a two-variable function

Fig. 3. A trace of minimization of a three-variable function

Fig. 1 demonstrates a programming created function minimum returning coordinates of the minimum point of a multivariable function (which name – is an argument y) and starting search with an initial approximation point (vector x). The search algorithm is easy. A look D (that is the third argument of the function minimum) is taken starting with the point of initial approximation. The values of the minimized function are evaluated at new coordinates[1]. A transition is made to a point the function value is minimal and the given point becomes a new point of approximation to the minimum and all the above-stated operations («feeling» the function all over the approximation point) are repeated. If close to a new point every new value of the function is greater than the previous one the look (D) is halved and operations are repeated. The search is finished when the value of D becomes less than the value of TOL (TOL is the system Mathcad variable controlling the tolerance of calculations).

Fig. 1. Search of the minimum of a multidimensional function

The descent to the minimum algorithm designed in the program in Fig. 1 – is unsophisticated and presents no optimizing ruses. Thus, for example, every successive approximation to the minimum value of the function under analysis results in a repeated calculation of the function value in the previous point. Provided the function is not complicated and allows its value to be calculated easily, this recurrence has a little influence on the total time of the minimum search. And what is to be done if the function is rather complicated? We offer the reader to update the program in Fig. 1 and to improve its disadvantage. The program should store the value of the function under analysis at the point of a preceding approximation and to apply it at subsequent calculations. And there is a more complex task. We are «crossing» a point of a successive approximation searching the minimum of a two-variable function as if blessing the search success:

A more optimal strategy may require «envelopment» of a successive point not by a cross but an equilateral triangle with a side of a length D (simplex-method; minimizing a three-variable function a point is put into a tetrahedron and so on):

Besides the triangle (or the David star or even a five-point star – a new task to the reader) is quite good to be oriented with space in a random way and to be expanded along one of its vertexes at each step of approximation. This also allows a more optimal strategy of the minimum search.

The described tricks are possible to be applied to a task with n variables of optimization (a n-dimensional Judaic or five-point star!). All these ideas are good tasks to the readers. Search and testing optimization algorithms is a section of computing (applied) mathematics. We have just cast a glance at it in the article.

The reader can point out another
«nonoptimality» of the program in Fig. 1. It generates not
only a vector of the variable values minimizing the function, but also the
whole matrix M keeping the search «history». The
matrix should be transposed later (Ì^{Ò}), a number of the last column should be determined (L) and the column should be extracted (Ì^{<}^{L-1}^{>} – see Fig. 6.28). But an overload of the program in Fig.
1 was not idle. As already noted, the Mathcad programming environment is
lacking in debugging facilities. The most simple but, nevertheless, a very
effective facility of program debugging – is observation of subproducts. But
Mathcad does not allow this very thing. And, nevertheless, – if something is
not possible but strongly desired it becomes possible. The program in Fig. 1 successfully copes with rather complicated tasks (see,
for example, Fig. 6.28). But if to palm on it a really simple function (the
Rosenbrock function, for
example) – the program in Fig. 1 gets caught in an endless
loop at certain initial approximations – and you will not be able to wait until
it ends. What is the matter? A certain modernization of the program helps to
answer this question: operation of the program can be interrupted not only by
inequality D
£ TOL, but also
by an additional condition, for example, n
> 30. After a number of approximation steps n exceeds 30 it becomes possible to examine a trace of the minimum
search of the
Rosenbrock
function or some other one (the task to the reader).

Fig. 2. A trace of minimization of a two-variable function

A trace of the minimum search of the
function õ^{8}+y^{6} is
displayed in Fig. 2.

Fill a bath with water, throw a plumelet or
some other light object there and pull out a plug. The plumelet firstly makes
its way towards the hole gently (see the first graph in Fig. 2),
and then starts eddying (the second graph). Our technique can be called not
simply the method of the quickest descent, but *the method of the quickest drain (descent) of water*. The liquid does not barely descent with an eddy, it
always whirls in one direction. Even being twirled in the opposite direction it
overcomes the violence and flows clockwise. They say that this physical
phenomenon is due to

The reader is already likely to guess he is being played a trick – this article was published at the April issue of a computer magazine[2].

But the most amusing in this story is that the descent trajectories displayed in Fig. 2 really started twisting in the opposite direction in Australia. The case was rather simple: a little bug has taken place on the line at transition of the file and instead of the line for i Î ORIGIN .. L - 1 in the program in Fig. 1 the line for i Î L - 1 .. ORIGIN[3] has appeared. That’s all explanation. But the same Coriolis forces are responsible for this – magnetic hard disks at servers and routers in the Southern Hemisphere are spinning a little bit differently than in the Northern Hemisphere. This is the reason for bugs, which are hardly indicated for an error is corrected at a test return e-mail of the file by the principle that «a minus multiplied by a minus yields a plus»[4].

[1] There are four coordinates at a two-dimensional task, 6 – at a three-dimensional and so on.

[2] This is the April-fool-day issue (1997) of the weekly «CompuTerra», which was called «CompuMorra».

[3] ORIGIN rather than 0 (zero) is written down here in order not to be related to a current value of the system variable ORIGIN.

[4] An attempt to prolong the joke.