Shlomi Fish >
Math-Cephes >
pmath

pmath - simple command line interface to Math::Cephes

bash> pmath Interactive interface to the Math::Cephes module. TermReadLine enabled. Type 'help' or '?' for help. pmath> setprec 4 display set to 4 decimal places pmath> cos($PI) -1.0000 pmath> acos(%) 3.1416 pmath> q bash>

This script provides a simple command line interface to the `Math::Cephes`

module. If available, it will use the `Term::ReadKey`

and `Term::ReadLine::Perl`

or `Term::ReadLine::GNU`

modules to provide command line history and word completion.

Typing `help`

or `?`

alone will provide a list of help topics grouped by major category name. `help category`

will provide a listing and short description of each function within the named category. `help function`

will provide a description and synopsis of the named function.

Entering an expression that returns a single value, such as `sin($x)`

, or one that returns multiple values, such as `airy($x)`

, will result in all return values being printed. The last (successful) single value returned is saved as the `%`

symbol (as in Maple), so that one can do

pmath> sin($PI/2) 1 pmath> asin(%) 1.570796 pmath>

The number of decimal places displayed can be set to `j`

using `setprec j`

:

pmath> setprec 8 display set to 8 decimal places pmath> $PI 3.14159265 pmath>

Multiple statements can be entered on a line, such as pmath> $x=1; $y=exp($x); printf("\texp(%5.2f)=%5.2f\n",$x,$y); exp( 1.00)= 2.72 pmath>

or on multiple lines using `\`

as a continuation signal:

pmath> $x = 1; \ $y = exp($x); \ printf("exp(%5.2f)=%5.2f\n", $x, $y); exp( 1.00)= 2.72 pmath>

To quit the program, enter `q`

, `quit`

, or `exit`

.

The `Math::Cephes`

module has some support for handling fractions and complex numbers through the `Math::Cephes::Fraction`

and `Math::Cephes::Complex`

modules. For fractions, one can use the `fract()`

function to create a fraction object, and then use these in a fraction routine:

pmath> $f=fract(1,3); $g=fract(4,3); $f->radd($g); 5/3 pmath> mixed(%) 1 2/3 pmath>

Similarly, for complex numbers one can use the `cmplx()`

function to create a complex number object, and then use these in a complex number routine:

pmath> $f=cmplx(1,3); $g=cmplx(4,3); $f->cadd($g); 5+6 i pmath>

See Math::Cephes::Polynomial for an interface to some polynomial routines, and Math::Cephes::Matrix for some matrix routines.

Probably. Please report any to Randy Kobes <randy@theoryx5.uwinnipeg.ca>

Math::Cephes, Math::Cephes::Fraction, Math::Cephes::Complex, Math::Cephes::Polynomial and Math::Cephes::Matrix.

This script is copyrighted, 2000, 2002, by Randy Kobes. It may be distributed under the same terms as Perl itself.

syntax highlighting: