Information Technology Reference
In-Depth Information
C or Fortran code to be called from Maple, or (better) use a built-in Maple func-
tion to perform the task. In the case of numerical integration, Maple offers the
user many computationally efficient functions. The plain trapezoidal rule is not
available. Maple instead offers sophisticated methods with user interfaces for spec-
ifying the desired precision and a particular rule rather than the detailed parameters
of a method. Maple then calls up highly optimized Fortran 77 functions, which
automatically find a rule compatible with the user's accuracy requirement.
In the present case, we just write
q:=evalf(Int(f1,0..2,'method'=_NCrule));
to evaluate the integral of f1 numerically by the simplest rules in Maple. The answer
is returned in a fraction of a second. Maple computes our integral faster than the
Fortran 77 program and with higher precision. The reason is because Maple applies
a much more efficient numerical integration rule.
To summarize, we can easily implement Algorithm 6.2 in Maple, but the exe-
cution time will be long if n is large. The “right” solution is to use the built-in
numerical integration functions, but this invokes much more sophisticated and
efficient methods than Algorithm 6.2 .
6.3.9
Summary
In the previous sections we have presented implementations of the trapezoidal rule
in different computing environments. Although the trapezoidal rule is among the
very simplest of all numerical algorithms, quite significant differences in perfor-
mance and convenience of the various programming tools have come to be. These
differences are much larger and more serious when addressing more complicated
numerical algorithms.
It is almost impossible to draw firm conclusions about the preferred computing
environment, since this depends heavily on personal taste and previous experience.
We have tried to define some characteristics of the different programming tools
in Table 6.1 when implementing the trapezoidal rule. The purpose is to provide a
quick comparison of some features that programmers of numerical applications may
emphasize when choosing a language.
Some trends are clear when comparing Fortran 77, C/C CC , Java, Python, Mat-
lab, and Maple. If computational speed is the most important factor, one should
choose one of the compiled languages: Fortran 77, C, C CC , or Java. If program-
ming convenience is regarded as most important, the interpreted and dynamically
typed environments Maple, Matlab, and Python constitute the preferred choice.
Speed versus convenience can also be expressed as computational versus human
efficiency. The former is very important if the total CPU time is hours, days, or
weeks, or if the program is to be executed “as is” in thousands of production runs
by many people. Students or scientists will often be most concerned with human
Search WWH ::




Custom Search