Information Technology Reference
In-Depth Information
The complete algorithm for the trapezoidal rule, using the proposed notation,
appears separately as Algorithm 6.1 .
Algorithm 6.1
Trapezoidal Integration.
trapezoidal ( a , b , f , n )
h D ba
n
s D 0
for i D 1;:::;n1
s s Chf . a Cih/
end for
s s C 2 f.a/C 2 f.b/
return s
The notation used in Algorithm 6.1 is a typical example of mathematical pseudo
code.
Having the algorithm available as mathematical pseudo code makes the step
toward a working computer code quite small. Some readers might think that the
step is so small that we could equally well have written the lines directly in a specific
computer language. This argument is relevant in the present example, where there
is hardly any complexity of the algorithm implied by (6.1). In more complicated
problems, however, the mathematical pseudo code is still quite close to the mathe-
matical exposition of the numerical methods, whereas a computer code will contain
many more details specific to the chosen language. Experience shows that the two-
step procedure of first deriving a correct mathematical pseudo code and then using
it as a reference when translating, and later checking, the computer implementation
simplifies software development considerably.
Another attractive feature of the mathematical pseudo code is that we turn numer-
ical solution procedures into a form that is ready for implementation. However, the
choice of programming language, programming style, data types, and computing
instructions (which differ highly between individuals and organizations) remains
open.
6.1.3
Optimization of Algorithms and Implementations
There is a strong tradition in scientific computing of carefully examining algo-
rithms with the aim of reducing the number of arithmetic operations and the need
for storing computed information. This is because advanced problems in scientific
computing require optimization of speed and memory usage.
 
Search WWH ::




Custom Search