% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved.
% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
\newcommand{\DecimalExpansionXmpTitle}{DecimalExpansion}
\newcommand{\DecimalExpansionXmpNumber}{9.15}
%
% =====================================================================
\begin{page}{DecimalExpansionXmpPage}{9.15 DecimalExpansion}
% =====================================================================
\beginscroll

%
%
%
%
%




All rationals have repeating decimal expansions.
Operations to access the individual digits of a decimal expansion can
be obtained by converting the value to \spadtype{RadixExpansion(10)}.
More examples of expansions are available in
\downlink{`BinaryExpansion'}{BinaryExpansionXmpPage}\ignore{BinaryExpansion},
\downlink{`HexadecimalExpansion'}{HexadecimalExpansionXmpPage}\ignore{HexadecimalExpansion}, and
\downlink{`RadixExpansion'}{RadixExpansionXmpPage}\ignore{RadixExpansion}.
\showBlurb{DecimalExpansion}

\xtc{
The operation \spadfunFrom{decimal}{DecimalExpansion} is used to create
this expansion of type \spadtype{DecimalExpansion}.
}{
\spadpaste{r := decimal(22/7) \bound{r}}
}
\xtc{
Arithmetic is exact.
}{
\spadpaste{r + decimal(6/7) \free{r}}
}
\xtc{
The period of the expansion can be short or long \ldots
}{
\spadpaste{[decimal(1/i) for i in 350..354] }
}
\xtc{
or very long.
}{
\spadpaste{decimal(1/2049) }
}
\xtc{
These numbers are bona fide algebraic objects.
}{
\spadpaste{p := decimal(1/4)*x^2 + decimal(2/3)*x + decimal(4/9)  \bound{p}}
}
\xtc{
}{
\spadpaste{q := differentiate(p, x) \free{p}\bound{q}}
}
\xtc{
}{
\spadpaste{g := gcd(p, q)            \free{p q} \bound{g}}
}
\endscroll
\autobuttons
\end{page}
%
