Numeric Functions

Axiom provides two basic floating point types: Float and DoubleFloat. This section describes how to use numerical operations defined on these types and the related complex types. As we mentioned in An Overview of Axiom in chapter 1., the Float type is a software implementation of floating point numbers in which the exponent and the significand may have any number of digits. See Float for detailed information about this domain. The DoubleFloat is usually a hardware implementation of floating point numbers, corresponding to machine double precision. The types Complex Float and Complex DoubleFloat are the corresponding software implementations of complex floating point numbers. In this section the term floating point type means any of these four types. The floating point types immplement the basic elementary functions. These include (where $ means DoubleFloat, Float, Complex Float, Complex DoubleFloat):
exp, log: $ -> $
sin, cos, tan, cot, sec, csc: $ -> $
asin, acos, atan, acot, asec, acsc: $ -> $
sinh, cosh, tanh, coth, sech, csch: $ -> $
asinh, acosh, atanh, acoth, asech, acsch: $ -> $
pi: () -> $
sqrt: $ -> $
nthRoot: ($,Integer) -> $
**: ($,Fraction Integer) -> $
**: ($,$) -> $
The handling of roots depends on whether the floating point type is real or complex: for the real floating point types, DoubleFloat and Float, if a real root exists the one with the same sign as the radicand is returned; for the complex floating point types, the principal value is returned. Also, for real floating point types the inverse functions produce errors if the results are not real. This includes cases such as asin(1.2), log(-3.2), sqrt(-1,1). The default floating point type is Float or Complex Float, just use normal decimal notation. To evaluate functions using DoubleFloat or Complex DoubleFloat, a declaration or conversion is required. A number of special functions are provided by the package DoubleFloatSpecialFunctions for the machine precision floating point types. The special functions provided are listed below, where F stands for the types Float or Complex Float. The real versions of the functions yield an error if the result is not real. A number of additional operations may be used to compute numerical values. These are special polynomial functions that can be evaluated for values in any commutative ring R, and in particular for values in any floating-point type. The following operations are provided by the package OrthogonalPolynomialFunctions:

These operations require non-negative integers for the indices, but otherwise the argument can be given as desired. The expression chebyshevT(n,z) evaluates to the nth Chebyshev polynomial of the first kind. The expression chebyshevU(n,z) evaluates to the nth Chebyshev polynomial of the second kind. The expression hermiteH(n,z) evaluates to the nth Hermite polynomial. The expression laguerreL(n,z) evaluates to the nth Laguerre polynomial. The expression legendreP(n,z) evaluates to the nth Legendre polynomial.

Finally, three number-theoretic polynomial operations may be evaluated. The following operations are provided by the package NumberTheoreticPolynomialFunctions. The expression bernoulliB(n,z) evaluates to the nth Bernoulli polynomial. The expression eulerE(n,z) evaluates to the nth Euler polynomial. The expression cyclotomic(n,z) evaluates to the nth cyclotomic polynomial.

Drawing complex functions in Axiom is presently somewhat awkward compared to drawing real functions. It is necessary to use the draw operations that operate on functions rather than expressions. This is the complex exponential function. When this is displayed in color, the height is the value of the real part of the function and the color is the imaginary part. Red indicates large negative imaginary values, green indicates imaginary values near zero and blue/violet indicates large positive imaginary values. This is the complex arctangent function. Again, the height is the real part of the function value but here the color indicates the function value's phase. The position of the branch cuts are clearly visible and one can see that the function is real only for a real argument. This is the complex Gamma function. This shows the real Beta function near the origin. This is the Bessel function J(alpha,x) for index alpha in the range -6..4 and argument x in the range 2..14. This is the modified Bessel function I(alpha,x) evaluated for various real values of the index alpha and fixed argument x=5. This is similar to the last example except the index alpha takes on complex values in a 6x6 rectangle centered on the origin.