aboutsummaryrefslogtreecommitdiff
path: root/src/hyper/pages/FRAC.ht
blob: eec3322f9ba3abf1bded75a35b467d65dcc3a296 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved.
% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
\newcommand{\FractionXmpTitle}{Fraction}
\newcommand{\FractionXmpNumber}{9.28}
%
% =====================================================================
\begin{page}{FractionXmpPage}{9.28 Fraction}
% =====================================================================
\beginscroll
%

The \spadtype{Fraction} domain implements quotients.
%-% \HDindex{fraction}{FractionXmpPage}{9.28}{Fraction}
The elements must belong to a domain of category \spadtype{IntegralDomain}:
multiplication must be commutative and the product of two non-zero
elements must not be zero.
This allows you to make fractions of most things you would think of,
but don't expect to create a fraction of two matrices!
The abbreviation for \spadtype{Fraction} is \spadtype{FRAC}.

\xtc{
Use \spadopFrom{/}{Fraction} to create a fraction.
}{
\spadpaste{a := 11/12 \bound{a}}
}
\xtc{
}{
\spadpaste{b := 23/24 \bound{b}}
}
\xtc{
The standard arithmetic operations are available.
}{
\spadpaste{3 - a*b**2 + a + b/a \free{a}\free{b}}
}
\xtc{
Extract the numerator and denominator by using
%-% \HDindex{numerator}{FractionXmpPage}{9.28}{Fraction}
\spadfunFrom{numer}{Fraction} and \spadfunFrom{denom}{Fraction},
%-% \HDindex{denominator}{FractionXmpPage}{9.28}{Fraction}
respectively.
}{
\spadpaste{numer(a) \free{a}}
}
\xtc{
}{
\spadpaste{denom(b) \free{b}}
}
Operations like \spadfunFrom{max}{Fraction}, \spadfunFrom{min}{Fraction},
\spadfunFrom{negative?}{Fraction}, \spadfunFrom{positive?}{Fraction} and
\spadfunFrom{zero?}{Fraction} are all available if they are provided for
the numerators and denominators.
See \downlink{`Integer'}{IntegerXmpPage}\ignore{Integer} for examples.

Don't expect a useful answer from \spadfunFrom{factor}{Fraction},
\spadfunFrom{gcd}{Fraction} or \spadfunFrom{lcm}{Fraction} if you apply
them to fractions.
\xtc{
}{
\spadpaste{r := (x**2 + 2*x + 1)/(x**2 - 2*x + 1) \bound{r}}
}
\xtc{
Since all non-zero fractions are invertible, these operations have trivial
definitions.
}{
\spadpaste{factor(r) \free{r}}
}
\xtc{
Use \spadfunFrom{map}{Fraction} to apply \spadfunFrom{factor}{Fraction} to
the numerator and denominator, which is probably what you mean.
}{
\spadpaste{map(factor,r) \free{r}}
}

\xtc{
Other forms of fractions are available.
%-% \HDindex{fraction!continued}{FractionXmpPage}{9.28}{Fraction}
Use \spadfun{continuedFraction} to create a continued fraction.
%-% \HDindex{continued fraction}{FractionXmpPage}{9.28}{Fraction}
}{
\spadpaste{continuedFraction(7/12)}
}
\xtc{
Use \spadfun{partialFraction} to create a partial fraction.
%-% \HDindex{fraction!partial}{FractionXmpPage}{9.28}{Fraction}
See \downlink{`ContinuedFraction'}{ContinuedFractionXmpPage}\ignore{ContinuedFraction} and \downlink{`PartialFraction'}{PartialFractionXmpPage}\ignore{PartialFraction} for
additional information and examples.
%-% \HDindex{partial fraction}{FractionXmpPage}{9.28}{Fraction}
}{
\spadpaste{partialFraction(7,12)}
}

\xtc{
Use conversion to create alternative views of fractions with objects
moved in and out of the numerator and denominator.
}{
\spadpaste{g := 2/3 + 4/5*\%i \bound{g}}
}
\xtc{
Conversion is discussed in detail in \downlink{``\ugTypesConvertTitle''}{ugTypesConvertPage} in Section \ugTypesConvertNumber\ignore{ugTypesConvert}.
}{
\spadpaste{g :: FRAC COMPLEX INT \free{g}}
}
\endscroll
\autobuttons
\end{page}
%