Now let’s review the two original programs.
Regular octahedron
PO Fix, 3, A, :, 2, x , V~, 3, x , A, x2, A ,
23 steps
Regular tetrahedron
P1 Fix, 3, A, :, V~, 3, x , A, x2, J ,
-3 2 2 s te p s
Total: 45 steps
If the two programs are compared, it is evident that the underlined portions are
identical. If these portions are incorporated into a common subroutine, the pro
grams are simplified and the number of steps required is decreased.
Furthermore, the portions indicated by the wavy line are not identical as they stand,
but if P1 is modified to: V- , 2, h- , 3, x , A, xy, 3, +, 4, the two portions become
identical.
Now the portions underlined by the straight line will be stored as an independent
routine in P9 and those underlined with the wavy line will be stored in P8.
P9 Fix, 3, A, :, V- , 3, x , A, x2 12 steps
P8 V” , 2, -s-, 3, x , A, x*, 3 8 steps
After the common segments have been removed, the remainder of the regular
octahedron formula is stored in PO, and that of the regular tetrahedron is stored
in P1. Of course, the “ Prog 9“ and “ Prog 8“ must be added to jump to subroutines
P9 and P8.
PO Prog, 9, :, Ans, x , 2, A, Prog, 8 9 steps
P1 Prog, 9, A , Prog, 8, :, Ans, ^ , 4 9 steps
Total: 38 steps
With this configuration, execution jumps to program P9 at the beginning of pro
grams PO and P1, three decimal places are specified, the value for one side is
entered, and the surface area of the tetrahedron is calculated. The expression
“ 2x ” of the original octahedron formula was omitted in P9, so when execution
returns to PO, “ Ansx2” is used to obtain the surface of the octahedron. In the
case of P1, the result of P9 needs no further modification and so is immediately
displayed upon return to P1.
- 1 2 8 -