Chapter 13

Chapter 13

On Scientific and Engineering Computation

Perl is not really known to be a language suitable for complex mathematical computations. The number of built-in mathematical functions it provides is quite small. However, the initial perception is surprisingly wrong. There are many modules contributed by individuals from around the world to facilitate efficient and complex mathematical processing. Some of the modules Perl provides are interfaces to well-known C-based libraries. There are also modules that interface with commercially available packages such as Mathematica. Thus, one can program any conceivable mathematical computation in Perl in an efficient and flexible manner. This ability to write complex mathematical programs is helpful because it complements Perl’s strong text-processing and networking capabilities. Some of the complex programs that are written in Perl in the context of the Web, such as learning a Web browser’s preferences, and serving targeted
advertisements, require efficient text-processing, networking and mathematical computation.

In this chapter, we briefly discuss Perl’s built-in mathematical functions and operators. We follow by discussing only one contributed module among the many available. Our discussion gives an overview and a few introductory examples. There are large number of additional useful modules, but we leave it to the interested reader to research, explore and use them.

In particular, there are three useful and powerful modules that stand out: Math::Cephes, PDL and

Math::Pari. These three modules are able to assist in a wide variety of mathematical and scientific computation.

Math::Cephes provides access to an extensive C-based library of over 150 functions that deal with arithmetic, probabilistic, trigonometric, and hyperbolic functions. Math::Cephes also has powerful routines to handle complex numbers, fractions and calculus-based computation. The PDL module allows fast matrix-based calculation and is especially useful when the task at hand calls for large data sizes needed in manipulation of images, time series data, and audio and video data. Math::Pari provides access to a package that is primarily aimed at number theory-based computation, but can be used by anybody whose primary need is speed. It performs many symbolic computations as well. However, its authors admit that compared to commercially available systems such as Maple, Mathematica or Macsyma, Math::Pari’s abilities are limited, but the Pari package can be 5 to 100 times faster than such systems on many computations. In this section, we discuss only module: Math::Cephes. Even when discussing it, we barely
scratch its surface.