FriCAS provides two kinds of floating point numbers. The domain Float (abbreviation FLOAT) implements a model of arbitrary precision floating point numbers. The domain DoubleFloat (abbreviation DFLOAT) is intended to make available hardware floating point arithmetic in FriCAS. The actual model of floating point DoubleFloat that provides is system-dependent. For example, on the IBM system 370 FriCAS uses IBM double precision which has fourteen hexadecimal digits of precision or roughly sixteen decimal digits. Arbitrary precision floats allow the user to specify the precision at which arithmetic operations are computed. Although this is an attractive facility, it comes at a cost. Arbitrary-precision floating-point arithmetic typically takes twenty to two hundred times more time than hardware floating point.
The usual arithmetic and elementary functions are available for DoubleFloat. Use )show DoubleFloat to get a list of operations or the HyperDoc browse facility to get more extensive documentation about DoubleFloat.
By default, floating point numbers that you enter into FriCAS are of type Float.
You must therefore tell FriCAS that you want to use DoubleFloat values and operations. The following are some conservative guidelines for getting FriCAS to use DoubleFloat.
To get a value of type DoubleFloat, use a target with @, ...
a conversion, ...
2.71828 :: DoubleFloat
or an assignment to a declared variable. It is more efficient if you use a target rather than an explicit or implicit conversion.
eApprox : DoubleFloat := 2.71828
You also need to declare functions that work with DoubleFloat.
avg : List DoubleFloat -> DoubleFloat
avg l == empty? l => 0 :: DoubleFloat reduce(_+,l) / #l
this complains but succeeds
Compiling function avg with type List Float -> DoubleFloat
Use package-calling for operations from DoubleFloat unless the arguments themselves are already of type DoubleFloat.
cos(3.1415926 :: DoubleFloat)
By far, the most common usage of DoubleFloat is for functions to be graphed. For more information about FriCAS’s numerical and graphical facilities, see Section ugGraph , ugProblemNumeric , and FloatXmpPage .