diff options
Diffstat (limited to 'src/algebra/fraction.spad.pamphlet')
-rw-r--r-- | src/algebra/fraction.spad.pamphlet | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/src/algebra/fraction.spad.pamphlet b/src/algebra/fraction.spad.pamphlet index 6fd77e97..56d14743 100644 --- a/src/algebra/fraction.spad.pamphlet +++ b/src/algebra/fraction.spad.pamphlet @@ -66,12 +66,10 @@ Localize(M:Module R, [x.num,u] m/d == if zero? d then error "division by zero" else [m,d] coerce(x:%):OutputForm == --- one?(xd:=x.den) => (x.num)::OutputForm - ((xd:=x.den) = 1) => (x.num)::OutputForm + one?(xd:=x.den) => (x.num)::OutputForm (x.num)::OutputForm / (xd::OutputForm) latex(x:%): String == --- one?(xd:=x.den) => latex(x.num) - ((xd:=x.den) = 1) => latex(x.num) + one?(xd:=x.den) => latex(x.num) nl : String := concat("{", concat(latex(x.num), "}")$String)$String dl : String := concat("{", concat(latex(x.den), "}")$String)$String concat("{ ", concat(nl, concat(" \over ", concat(dl, " }")$String)$String)$String)$String @@ -324,13 +322,11 @@ Fraction(S: IntegralDomain): QuotientFieldCategory S with if S has GcdDomain and S has canonicalUnitNormal then retract(x:%):S == --- one?(x.den) => x.num - ((x.den) = 1) => x.num + one?(x.den) => x.num error "Denominator not equal to 1" retractIfCan(x:%):Union(S, "failed") == --- one?(x.den) => x.num - ((x.den) = 1) => x.num + one?(x.den) => x.num "failed" else retract(x:%):S == @@ -341,21 +337,18 @@ Fraction(S: IntegralDomain): QuotientFieldCategory S with if S has EuclideanDomain then wholePart x == --- one?(x.den) => x.num - ((x.den) = 1) => x.num + one?(x.den) => x.num x.num quo x.den if S has IntegerNumberSystem then floor x == --- one?(x.den) => x.num - ((x.den) = 1) => x.num + one?(x.den) => x.num x < 0 => -ceiling(-x) wholePart x ceiling x == --- one?(x.den) => x.num - ((x.den) = 1) => x.num + one?(x.den) => x.num x < 0 => -floor(-x) 1 + wholePart x @@ -414,8 +407,7 @@ Fraction(S: IntegralDomain): QuotientFieldCategory S with normalize x == zero?(x.num) => 0 --- one?(x.den) => x - ((x.den) = 1) => x + one?(x.den) => x uca := unitNormal(x.den) zero?(x.den := uca.canonical) => error "division by zero" x.num := x.num * uca.associate @@ -426,8 +418,7 @@ Fraction(S: IntegralDomain): QuotientFieldCategory S with normalize [x.den, x.num] cancelGcd x == --- one?(x.den) => x.den - ((x.den) = 1) => x.den + one?(x.den) => x.den d := gcd(x.num, x.den) xn := x.num exquo d xn case "failed" => @@ -475,10 +466,8 @@ Fraction(S: IntegralDomain): QuotientFieldCategory S with x:% * y:% == zero? x or zero? y => 0 --- one? x => y - (x = 1) => y --- one? y => x - (y = 1) => x + one? x => y + one? y => x (x, y) := ([x.num, y.den], [y.num, x.den]) cancelGcd x; cancelGcd y; normalize [x.num * y.num, x.den * y.den] @@ -506,8 +495,7 @@ Fraction(S: IntegralDomain): QuotientFieldCategory S with x = y == (x.num = y.num) and (x.den = y.den) --x / dd == (cancelGcd (z:=[x.num,dd*x.den]); normalize z) --- one? x == one? (x.num) and one? (x.den) - one? x == ((x.num) = 1) and ((x.den) = 1) + one? x == one? (x.num) and one? (x.den) -- again assuming canonical nature of representation else @@ -549,8 +537,7 @@ Fraction(S: IntegralDomain): QuotientFieldCategory S with qqD:DP:=map(retract(#1*denqq),qq) g:=gcdPolynomial(ppD,qqD) zero? degree g => 1 --- one? (lc:=leadingCoefficient g) => map(#1::%,g) - ((lc:=leadingCoefficient g) = 1) => map(#1::%,g) + one? (lc:=leadingCoefficient g) => map(#1::%,g) map(#1 / lc,g) if (S has PolynomialFactorizationExplicit) then |