Numeric Computation in Maple
This document describes the Maple numeric computation environment. It contains information regarding the following topics.
Goals of the Computation Environment
Events, Exceptions, and Status Flags
Functions and Predicates
Input and Output Formatting
Goals of the Maple Numeric Computation Environment
The Maple numeric computation environment is designed to achieve the following goals.
1. Consistency with IEEE standards.
2. Consistency across different types of numeric computations (hardware, software, and exact).
3. Provision of direct support for handling exceptional events.
4. Integration of routines from the Numerical Algorithms Group (NAG).
5. Ability to enable further refinements and extensions to the environment.
IEEE Standards and Maple Numerics
The IEEE/754 and IEEE/854 standards for floating-point arithmetic have natural generalizations to arbitrary precision computing environments, such as Maple. By adopting such natural generalizations, Maple provides a uniform and consistent view of numeric computation across each of the hardware (fixed precision), software (arbitrary precision), and exact computation environments. Furthermore, IEEE/754 has been widely adopted in the computer industry to the point where Maple is now supported only on machines that claim to be IEEE/754 compliant.
For more information, see IEEEdiffs.
Extensions to Industry Standards
Maple floating-point computation environments differ from the IEEE/754 standard by including the following features.
1. Extensions to symbolic data.
2. The extension to complex numerics.
3. Square root is not considered a basic operation, and does not signal Invalid on negative arguments.
4. The RealToComplex event is included to handle operations that receive real input and return complex results.
The Maple numeric computation environment supports the following number formats. Each format has an associated constructor and type-checking function. For more information, see the individual constructor and type-checking help pages.
Maple hardware floating-point
A software floating-point number (type sfloat) and a general floating-point number (type float) are considered to be the same object.
Maple hardware floating-point numbers can exist as elements of rtables, as elements extracted from rtables, within the evalhf evaluator, or more generally in ordinary computation. For the specific cases of Matrix and Vector rtables with hardware-float entries, linear algebra computations can usually be carried out via calls to NAG library routines, resulting in significant efficiency gains over similar computations performed in the symbolic computation domain. (See also UseHardwareFloats.)
Numeric objects in any of the above formats are structural units in expressions; in particular, they are atomic with respect to map(). Standard functions are provided to extract the mathematical components of these objects (numerator, denominator, sign, mantissa, exponent, real part, and imaginary part). See the section on Functions and Predicates.
In each of the numeric formats listed in the previous section, there are the following special symbols.
infinity (both +infinity and -infinity)
undefined (representing the IEEE/754 NaN ("Not a Number"))
Both types of infinities and at least one type of undefined are represented in each of the numeric formats (see the help pages for the respective constructors listed in the previous section). For specific information on these special symbols, see the infinity and undefined help pages.
There are four environment variables that control the operation of the numeric environment. For more information regarding their functionality, see the corresponding help page.
controls the precision when performing
controls the rounding of floating-point results
contains the active numeric event handler procedures
controls whether floating-point operations
are performed in the hardware or software environment
The standard operations of addition, subtraction, multiplication, division by a non-zero number, and exponentiation by an integer are provided.
Complex arithmetic is implemented according to standard formulas, and produces correctly rounded infinitely precise results whenever that result is representable in the current numeric environment. Furthermore, the result of an arithmetic operation when at least one operand is a complex numeric is a complex numeric, unless all complex numeric operands are purely imaginary and the mathematical result would be real, (in which case the Maple result is a real numeric (for example, Complex(1)^2 = Integer(-1))).
Note: The complex conjugate of a real number is that real number, not a complex number with 0 imaginary part.
Arithmetic Involving 0's, infinities, and undefineds
A. Real case
The following rules specify the default results of the arithmetic operations other than exponentiation on real numeric operands when at least one of the operands is an infinity, 0, or undefined and no exception is signaled (see Events, Exceptions, and Status Flags). The rules are checked in order. The symbol x stands for any non-complex value not already included in a prior rule, and signum(x) means the sign of x.
1. Any basic operation for which either operand is an undefined returns an undefined (which will usually be one of the input undefineds).
2. ∞+x=∞ (x≠−∞)
3. x*infinity=signum⁡x⁢infinity (x≠0)
5. x−x=−x+x=x+−x=+0 unless the rounding mode is set to Round toward -infinity, in which case the result is -0; −0−0=−0+−0=−0, regardless of rounding mode.
9. ∞x=∞ if 0<x and is 0 if x<0
B. Complex case
The rules for complex arithmetic are inherited from the corresponding rules for real arithmetic, including the rules for operations involving infinities, undefineds, and 0's except if an operand to an operation is a 2-argument complex numeric in which exactly one component is 0 (hence, +0.0 or -0.0). In such cases, the correct interpretation of the 0 component is that it provides qualitative information rather than quantitative information. In particular, such a 0 component should not be understood to be an infinitesimal value. The operation in question produces qualitatively the same result as if the relevant operand were replaced by the mathematically equal real or purely imaginary value. Effectively, the product of a 0 component and an undefined or infinity is 0, with sign information being obtained according to the usual rules of arithmetic.
Function evaluation also inherits this interpretation.
For example, let z=undefined+0ⅈ. Then:
because z could be on a branch cut or not, with different imaginary parts for the result in each case.
Arithmetic involving infinities is performed in the same manner.
The standard rules apply in the case of a product of any real or complex that is equal to 0 and any kind of infinity.
If either component of a complex numeric is infinity, then the number is considered to be infinite for the purposes of computation.
Maple provides direct support for handling exceptional events. The NumericEventHandler environment variable holds the active numeric event handler procedures. For more information regarding events and status flags, see the following related help pages.
Type-checking facilities are provided in the Maple computation environment.
Note: While IEEE/754 uses predicates (for example, IsFinite(expr)), which are allowed to fail (signal Invalid), Maple generally uses types (for example, type(expr, finite)), which are required to return false if they are not able to return true.
The various numeric types are listed in the numeric_types help page.
The following functions and predicates are provided in the Maple computation environment. They extend the functions and predicates of the IEEE/754 Standard. For more information regarding a particular function or predicate, see the associated help page.
Numeric formats supported in Maple can be formatted in a variety of representations. For more information on formatting input and output of numerics, see the printf and scanf help pages.
For information regarding IEEE standards and other references used in the development of the Maple numeric computation environment, see the help page on numericrefs.
Download Help Document