diff options
author | dos-reis <gdr@axiomatics.org> | 2007-08-14 05:14:52 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2007-08-14 05:14:52 +0000 |
commit | ab8cc85adde879fb963c94d15675783f2cf4b183 (patch) | |
tree | c202482327f474583b750b2c45dedfc4e4312b1d /src/hyper/pages/RADIX.ht | |
download | open-axiom-ab8cc85adde879fb963c94d15675783f2cf4b183.tar.gz |
Initial population.
Diffstat (limited to 'src/hyper/pages/RADIX.ht')
-rw-r--r-- | src/hyper/pages/RADIX.ht | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/src/hyper/pages/RADIX.ht b/src/hyper/pages/RADIX.ht new file mode 100644 index 00000000..cffd3630 --- /dev/null +++ b/src/hyper/pages/RADIX.ht @@ -0,0 +1,116 @@ +% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved. +% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk. +\newcommand{\RadixExpansionXmpTitle}{RadixExpansion} +\newcommand{\RadixExpansionXmpNumber}{9.65} +% +% ===================================================================== +\begin{page}{RadixExpansionXmpPage}{9.65 RadixExpansion} +% ===================================================================== +\beginscroll + +It possible to expand numbers in general bases. + +\labelSpace{2pc} +\xtc{ +Here we expand \spad{111} in base \spad{5}. +This means +\texht{$10^2+10^1+10^0 = 4 \cdot 5^2+2 \cdot 5^1 + 5^0.$}{% +\spad{10**2+10**1+10**0 = 4*5**2+2*5**1+5**0.}} +}{ +\spadpaste{111::RadixExpansion(5)} +} + +\xtc{ +You can expand fractions to form repeating expansions. +}{ +\spadpaste{(5/24)::RadixExpansion(2)} +} +\xtc{ +}{ +\spadpaste{(5/24)::RadixExpansion(3)} +} +\xtc{ +}{ +\spadpaste{(5/24)::RadixExpansion(8)} +} +\xtc{ +}{ +\spadpaste{(5/24)::RadixExpansion(10)} +} +\xtc{ +For bases from 11 to 36 the letters A through Z are used. +}{ +\spadpaste{(5/24)::RadixExpansion(12)} +} +\xtc{ +}{ +\spadpaste{(5/24)::RadixExpansion(16)} +} +\xtc{ +}{ +\spadpaste{(5/24)::RadixExpansion(36)} +} +\xtc{ +For bases greater than 36, the ragits are separated by blanks. +}{ +\spadpaste{(5/24)::RadixExpansion(38)} +} +\xtc{ +The \spadtype{RadixExpansion} type provides operations to obtain the +individual ragits. +Here is a rational number in base \spad{8}. +}{ +\spadpaste{a := (76543/210)::RadixExpansion(8) \bound{a}} +} +\xtc{ +The operation \spadfunFrom{wholeRagits}{RadixExpansion} returns a list of the +ragits for the integral part of the number. +}{ +\spadpaste{w := wholeRagits a \free{a}\bound{w}} +} +\xtc{ +The operations \spadfunFrom{prefixRagits}{RadixExpansion} and \spadfunFrom{cycleRagits}{RadixExpansion} +return lists of the initial and repeating ragits in the +fractional part of the number. +}{ +\spadpaste{f0 := prefixRagits a \free{a}\bound{f0}} +} +\xtc{ +}{ +\spadpaste{f1 := cycleRagits a \free{a}\bound{f1}} +} +\xtc{ +You can construct any radix expansion by giving the +whole, prefix and cycle parts. +The declaration is necessary to let \Language{} +know the base of the ragits. +}{ +\spadpaste{u:RadixExpansion(8):=wholeRadix(w)+fractRadix(f0,f1) \free{w f0 f1}\bound{u}} +} +\xtc{ +If there is no repeating part, then the list \spad{[0]} should be used. +}{ +\spadpaste{v: RadixExpansion(12) := fractRadix([1,2,3,11], [0]) \bound{v}} +} +\xtc{ +If you are not interested in the repeating nature of the expansion, +an infinite stream of ragits can be obtained using +\spadfunFrom{fractRagits}{RadixExpansion}. +}{ +\spadpaste{fractRagits(u) \free{u}} +} +\xtc{ +Of course, it's possible to recover the fraction representation: +}{ +\spadpaste{a :: Fraction(Integer) \free{a}} +} + +\showBlurb{RadixExpansion} +More examples of expansions are available in +\downlink{`DecimalExpansion'}{DecimalExpansionXmpPage}\ignore{DecimalExpansion}, +\downlink{`BinaryExpansion'}{BinaryExpansionXmpPage}\ignore{BinaryExpansion}, and +\downlink{`HexadecimalExpansion'}{HexadecimalExpansionXmpPage}\ignore{HexadecimalExpansion}. +\endscroll +\autobuttons +\end{page} +% |