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.
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.
Gamma: F -> F
Gamma(z) is the Euler gamma
function, Gamma(Z), defined by
Gamma(z) = integrate(t^(z-1)*exp(-t),t=0..%infinity)
Beta: F -> F
Beta(u,v) is the Euler Beta
function B(u,v), defined by
Beta(u,v)=integrate(t^(u-1)*(1-t)^(b-1),t=0..1)
This is related to Gamma(z) by
Beta(u,v)=Gamma(u)*Gamma(v)/Gamma(u+v)
logGamma: F -> F
logGamma(z) is the natural logarithm of Gamma(z). This can often be
computed even if Gamma(z) cannot.
digamma: F -> F
digamma(z), also called psi(z), is the function psi(z), defined by
psi(z)=Gamma'(z)/Gamma(z)
polygamma: (NonNegativeInteger, F) -> F
polygamma(n,z) is the n-th derivative of digamma(z)
besselJ: (F, F) -> F
besselJ(v,z) is the Bessel function of the first kind, J(v,z). This
function satisfies the differential equation
z^(2w)''(z)+zw'(z)+(z^2-v^2)w(z)=0
besselY: (F, F) -> F
besselY(v,z) is the Bessel function of the second kind, Y(v,z). This
function satisfies the same differential equation as
besselJ. The implementation simply
uses the relation
Y(v,z)=(J(v,z)cos(v*%pi)-J(-v,z))/sin(v*%pi)
besselI: (F, F) -> F
besselI(v,z) if the modifed Bessel function of the first kind, I(v,z).
This function satisfies the differential equation
z^2w''(z)+zw'(z)-(z^2+v^2)w(z)=0
besselK: (F, F) -> F
besselK(v,z) is the modifed Bessel function of the second kind, K(v,z).
This function satisfies the same differential equation as
besselI. The implementation simply uses
the relation
K(v,z)=%pi*(I(v,z)-I(-v,z))/(2sin(v*%pi))
airyAi: F -> F
airyAi(z) is the Airy function Ai(z). This function satisfies the
differential equation
w''(z)-zw(z)=0
The implementation simply uses the relation
Ai(-z)=1/3*sqrt(z)*(J(-1/3,2/3*z^(3/2))+J(1/3,2/3*z^(3/2)))
airyBi: F -> F
airyBi(z) is the Airy function Bi(z). This function satisfies the
same differential equation as airyAi.
The implementation simply uses the relation
Bi(-z)=1/3*sqrt(3*z)*(J(-1/3,2/3*z^(3/2))-J(1/3,2/3*z^(3/2)))
hypergeometric0F1: (F, F) -> F
hypergeometric0F1(c,z) is the hypergeometric function 0F1(;c;z). The above
special functions are defined only for small floating point types. If you
give Float arguments, they are converted to
DoubleFloat by Axiom.
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:
chebyshevT:
(nonNegativeInteger,R) -> R
chebyshevT(n,z) is the nth Chebyshev polynomial of the first kind,
T[n](z). These are defined by
(1-t*z)/(1-2*t*z*t**2)=sum(T[n](z)*t**n,n=0..)
chebyshevU:
(nonNegativeInteger,R) -> R
chebyshevU(n,z) is the nth Chebyshev polynomial of the second kind,
U[n](z). These are defined by
1/(1-2*t*z+t**2)=sum(U[n](z)*t**n,n=0..)
hermiteH:
(NonNegativeInteger,R) -> R
hermiteH(n,z) is the nth Hermite polynomial, H[n](z). These are
defined by
exp(2*t*z-t**2)=sum(H[n](z)*t**n/n!,n=0..)
laguerreL:
(NonNegativeInteger,R) -> R
laguerreL(n,z) is the nth Laguerre polynomial, L[n](z). These are
defined by
(exp(-t*z/(1-t))/(1-t)=sum(L[n](z)*t**n/n!,n=0..)
laguerreL:
(NonNegativeInteger,NonNegativeInteger,R) -> R
labuerreL(m,n,2) is the associated Laguerre polynomial, L<m>[n](z).
This is the nth derivative of L[n](z).
legendreP:
(NonNegativeInteger,R) -> R
legendreP(n,z) is the nth Legendre polynomial, P[n](z). These are
defined by
1/sqrt(1-2*z*t+t**2)=sum(P[n](z)*t**n,n=0..)
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.
bernoulliB:
(NonNegativeInteger,R) -> R
bernoulliB(n,z) is the nth Bernoulli polynomial, B[n](z). These are
defined by
t*exp(z*t)/(exp t - 1)=sum(B[n](z)*t**n/n! for n=0..)
eulerE:
(NonNegativeInteger,R) -> R
eulerE(n,z) is the nth Euler polynomial, E[n](z). These are defined by
2*exp(z*t)/(exp t + 1)=sum(E[n](z)*t**n/n! for n=0..)
cyclotomic:
(NonNegativeInteger,R) -> R
cyclotomic(n,z) is the nth cyclotomic polynomial φ(n,z).
This is the polynomial whose roots are precisely the primitive nth
roots of unity. This polynomial has degree given by the Euler
totient function φ(n).
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.