Links to other topics
Story Problems Debugging
List of Story Problems Anglish Statements
List of Formulas used in Story Problems Anglish Features

Symbolic Factoring and Computational Efficiency

The alternative program for the net wages problem is the single statement:

     net wages = rate X time - rate X time X percent/100
An alternative form of this statement can be obtained by factoring. Producing:
     net wages = rate X time X (1 - percent/100)
Either form is acceptable. In general, factoring may improve the efficiency of the computation. In this case, the first form requires three multiplications, a division and a subtraction. The factored form requires only two multiplications, a division and a subtraction. In a computer, the total number of arithmetic operations determines the amount of work the computer must do. Therefore, the second form is more efficient. The sequential program corresponding to the factored form is:
     net percent = 100 - percent;
     net wages = rate X time X (net percent/100);
The sequential form requires that the programmer use a new variable name (i.e. net percent). Both the alternative and the sequential alternative forms use the same number of arithmetic operations. The sequential form, however, identifies "net percent" as a key variable. That is, problems of this type are more efficient if stated with the net percent of take home pay instead of with the percent of deductions. Frequently, the factored sequential form provides insight into the basic underlying structure of the problem.

The plural data class.