Error message

  • Warning: count(): Parameter must be an array or an object that implements Countable in theme_table() (line 1998 of /home/admin/web/peeweepc.com/public_html/includes/theme.inc).
  • Warning: count(): Parameter must be an array or an object that implements Countable in theme_table() (line 2061 of /home/admin/web/peeweepc.com/public_html/includes/theme.inc).
  • Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in menu_set_active_trail() (line 2405 of /home/admin/web/peeweepc.com/public_html/includes/menu.inc).

The concept of auxiliary algorithm Part 2

We remember "RECUR" substitutable for a, b, c numbers 2, 3 and 122 and get the result: x1 and x2. To solve another quadratic equation, it is necessary to substitute a, b, C other numbers.

As you can see, between the subsidiary algorithms "Duties" and "RECUR" there is a significant difference. The team calling the algorithm "REQUER" you must specify the source data values of the coefficients of the quadratic equation you want to solve. In the algorithm of "Duties" not the original data. So nothing except the name in the call command should not be specified.

When using an auxiliary algorithm, as a rule, nobody cares, of what it consists. It is only important what the baseline data (parameters) of the algorithm and what is the result of his work. Similarly, in order to use the washing machine, do not have to understand the device. Enough to know that "arguments" are some of her washing powder, clean water and dirty things, a "result" of dirty, soapy water and clean clothes. As for the algorithm "RECUR", his arguments are the coefficients a, b and c, and the result of any roots x1, x2, or the message that there are no roots.

Let's use the algorithm "RECUR" solve any problem from your textbook "Algebra and start the analysis". Take a look at it. For example, the theme of "Exponential equations and inequalities". It explains how to solve equations of the form d2x + pdx + q = 0.

In fact, in your textbook, the following is proposed algorithm for solving such equations:

  • Request d, p, q.
  • To execute the algorithm "RECUR" at a = 1, b = p, c = q.
  • If P2 - 4q ≥ 0 (i.e. if the quadratic equation t2 + pt + q = 0 has roots):
  • To solve the equation dx = x1.
  • Let x.
  • To solve the equation dx = x2.
  • To inform H.
  • The end of branching.

Here it is necessary to mention one very important fact. Imagine that you gave her friend the auxiliary algorithm, "RECVAR" and explained how to use it. Of course, your friend no matter what the notation you used in your algorithm. Therefore, it may happen that in the main algorithm will use the same notation, as in "REQUIRE", for example, d and p (this is what happened in the newly written algorithm).

It is clear that it is necessary to distinguish between variables that are equally marked in primary and secondary algorithms. Therefore, we agree to assume that all symbols of the auxiliary algorithm is only valid within this algorithm. That said, of course, does not apply to results of work of the subsidiary algorithms, because it needs to be used after the completion of his work.

Figuratively speaking, variables with the same name in the main and subsidiary algorithms, just "namesakes". When you call the auxiliary algorithm the values of the variables of the basic algorithm is "frozen", and after the auxiliary algorithm, it "defrosted".

Without such "freezing" would occur very unpleasant things. What? Now you'll see!

Let's see how would execute written above algorithm, if the "freezing" occurred. Click "Request d, p, q", we assign the variable d the value 5, variable R - value of 8, a variable q - value 425.

Now, run the algorithm "RECUR", taking as a, b, c the numbers 1, -8, -425 respectively. Get x1 = 25, x2 = -17. Further, to check the conditions we need to calculate the value of P2 - 4q. But what is it? The p value is not the same - 8! When the algorithm is executed "REQUER" he was assigned the value 42. And d is not the same as before. Now d = 1764. From such "help" auxiliary algorithm becomes uncomfortable. It's as if your tape recorder while playing records at once replaced on the tape, say, "sabre Dance", "dance of the little swans". In fact, after performing the auxiliary algorithm the values of p and q "unfrozen", i.e. again is equal to -8 and -425, and the algorithm gives the correct result (what?).

Thus, the use of auxiliary algorithms, another form of action. The subsidiary is called the algorithm is provided with this heading, which allows you to call this algorithm from other algorithms. Any algorithm can be done auxiliary: it is only necessary to provide it with the appropriate heading (i.e. to specify the name, arguments and results).

As you can see, the support algorithms is a powerful and handy tool that facilitates the solution of difficult problems. We can say that the art of making algorithms is the ability to design a complex algorithm of more simple auxiliary algorithms, i.e., the ability to teach by complex things gradually, going from simple to complex.

Category: