/usr/share/axiom-20170501/src/algebra/OC.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | )abbrev category OC OctonionCategory
++ Author: R. Wisbauer, J. Grabmeier
++ Date Created: 05 September 1990
++ Date Last Updated: 19 September 1990
++ References: I.L Kantor, A.S. Solodovnikov:
++ Hypercomplex Numbers, Springer Verlag Heidelberg, 1989,
++ ISBN 0-387-96980-2
++ Description:
++ OctonionCategory gives the categorial frame for the
++ octonions, and eight-dimensional non-associative algebra,
++ doubling the the quaternions in the same way as doubling
++ the Complex numbers to get the quaternions.
-- we are cheating a little bit, algebras in \Language{}
-- are mainly considered to be associative, but that's not
-- an attribute and we can't guarantee that there is no piece
-- of code which implicitly
-- uses this. In a later version we shall properly combine
-- all this code in the context of general, non-associative
-- algebras, which are meanwhile implemented in \Language{}
OctonionCategory(R) : Category == SIG where
R : CommutativeRing
SIG ==> Join(Algebra R, FullyRetractableTo R, FullyEvalableOver R) with
conjugate : % -> %
++ conjugate(o) negates the imaginary parts i,j,k,E,I,J,K of octonian o.
real : % -> R
++ real(o) extracts real part of octonion o.
imagi : % -> R
++ imagi(o) extracts the i part of octonion o.
imagj : % -> R
++ imagj(o) extracts the j part of octonion o.
imagk : % -> R
++ imagk(o) extracts the k part of octonion o.
imagE : % -> R
++ imagE(o) extracts the imaginary E part of octonion o.
imagI : % -> R
++ imagI(o) extracts the imaginary I part of octonion o.
imagJ : % -> R
++ imagJ(o) extracts the imaginary J part of octonion o.
imagK : % -> R
++ imagK(o) extracts the imaginary K part of octonion o.
norm : % -> R
++ norm(o) returns the norm of an octonion, equal to
++ the sum of the squares
++ of its coefficients.
octon : (R,R,R,R,R,R,R,R) -> %
++ octon(re,ri,rj,rk,rE,rI,rJ,rK) constructs an octonion
++ from scalars.
if R has Finite then Finite
if R has OrderedSet then OrderedSet
if R has ConvertibleTo InputForm then ConvertibleTo InputForm
if R has CharacteristicZero then CharacteristicZero
if R has CharacteristicNonZero then CharacteristicNonZero
if R has RealNumberSystem then
abs: % -> R
++ abs(o) computes the absolute value of an octonion, equal to
++ the square root of the \spadfunFrom{norm}{Octonion}.
if R has IntegerNumberSystem then
rational? : % -> Boolean
++ rational?(o) tests if o is rational, that all seven
++ imaginary parts are 0.
rational : % -> Fraction Integer
++ rational(o) returns the real part if all seven
++ imaginary parts are 0.
++ Error: if o is not rational.
rationalIfCan : % -> Union(Fraction Integer, "failed")
++ rationalIfCan(o) returns the real part if
++ all seven imaginary parts are 0, and "failed" otherwise.
if R has Field then
inv : % -> %
++ inv(o) returns the inverse of o if it exists.
add
characteristic() ==
characteristic()$R
conjugate x ==
octon(real x, - imagi x, - imagj x, - imagk x, - imagE x,_
- imagI x, - imagJ x, - imagK x)
map(fn, x) ==
octon(fn real x,fn imagi x,fn imagj x,fn imagk x, fn imagE x,_
fn imagI x, fn imagJ x,fn imagK x)
norm x ==
real x * real x + imagi x * imagi x + _
imagj x * imagj x + imagk x * imagk x + _
imagE x * imagE x + imagI x * imagI x + _
imagJ x * imagJ x + imagK x * imagK x
x = y ==
(real x = real y) and (imagi x = imagi y) and _
(imagj x = imagj y) and (imagk x = imagk y) and _
(imagE x = imagE y) and (imagI x = imagI y) and _
(imagJ x = imagJ y) and (imagK x = imagK y)
x + y ==
octon(real x + real y, imagi x + imagi y,_
imagj x + imagj y, imagk x + imagk y,_
imagE x + imagE y, imagI x + imagI y,_
imagJ x + imagJ y, imagK x + imagK y)
- x ==
octon(- real x, - imagi x, - imagj x, - imagk x,_
- imagE x, - imagI x, - imagJ x, - imagK x)
r:R * x:% ==
octon(r * real x, r * imagi x, r * imagj x, r * imagk x,_
r * imagE x, r * imagI x, r * imagJ x, r * imagK x)
n:Integer * x:% ==
octon(n * real x, n * imagi x, n * imagj x, n * imagk x,_
n * imagE x, n * imagI x, n * imagJ x, n * imagK x)
coerce(r:R) ==
octon(r,0$R,0$R,0$R,0$R,0$R,0$R,0$R)
coerce(n:Integer) ==
octon(n :: R,0$R,0$R,0$R,0$R,0$R,0$R,0$R)
zero? x ==
zero? real x and zero? imagi x and _
zero? imagj x and zero? imagk x and _
zero? imagE x and zero? imagI x and _
zero? imagJ x and zero? imagK x
retract(x):R ==
not (zero? imagi x and zero? imagj x and zero? imagk x and _
zero? imagE x and zero? imagI x and zero? imagJ x and zero? imagK x)=>
error "Cannot retract octonion."
real x
retractIfCan(x):Union(R,"failed") ==
not (zero? imagi x and zero? imagj x and zero? imagk x and _
zero? imagE x and zero? imagI x and zero? imagJ x and zero? imagK x)=>
"failed"
real x
coerce(x:%):OutputForm ==
part,z : OutputForm
y : %
zero? x => (0$R) :: OutputForm
not zero?(real x) =>
y := octon(0$R,imagi(x),imagj(x),imagk(x),imagE(x),
imagI(x),imagJ(x),imagK(x))
zero? y => real(x) :: OutputForm
(real(x) :: OutputForm) + (y :: OutputForm)
-- we know that the real part is 0
not zero?(imagi(x)) =>
y := octon(0$R,0$R,imagj(x),imagk(x),imagE(x),
imagI(x),imagJ(x),imagK(x))
z :=
part := "i"::Symbol::OutputForm
(imagi(x) = 1) => part
(imagi(x) :: OutputForm) * part
zero? y => z
z + (y :: OutputForm)
-- we know that the real part and i part are 0
not zero?(imagj(x)) =>
y := octon(0$R,0$R,0$R,imagk(x),imagE(x),
imagI(x),imagJ(x),imagK(x))
z :=
part := "j"::Symbol::OutputForm
(imagj(x) = 1) => part
(imagj(x) :: OutputForm) * part
zero? y => z
z + (y :: OutputForm)
-- we know that the real part and i and j parts are 0
not zero?(imagk(x)) =>
y := octon(0$R,0$R,0$R,0$R,imagE(x),
imagI(x),imagJ(x),imagK(x))
z :=
part := "k"::Symbol::OutputForm
(imagk(x) = 1) => part
(imagk(x) :: OutputForm) * part
zero? y => z
z + (y :: OutputForm)
-- we know that the real part,i,j,k parts are 0
not zero?(imagE(x)) =>
y := octon(0$R,0$R,0$R,0$R,0$R,
imagI(x),imagJ(x),imagK(x))
z :=
part := "E"::Symbol::OutputForm
(imagE(x) = 1) => part
(imagE(x) :: OutputForm) * part
zero? y => z
z + (y :: OutputForm)
-- we know that the real part,i,j,k,E parts are 0
not zero?(imagI(x)) =>
y := octon(0$R,0$R,0$R,0$R,0$R,0$R,imagJ(x),imagK(x))
z :=
part := "I"::Symbol::OutputForm
(imagI(x) = 1) => part
(imagI(x) :: OutputForm) * part
zero? y => z
z + (y :: OutputForm)
-- we know that the real part,i,j,k,E,I parts are 0
not zero?(imagJ(x)) =>
y := octon(0$R,0$R,0$R,0$R,0$R,0$R,0$R,imagK(x))
z :=
part := "J"::Symbol::OutputForm
(imagJ(x) = 1) => part
(imagJ(x) :: OutputForm) * part
zero? y => z
z + (y :: OutputForm)
-- we know that the real part,i,j,k,E,I,J parts are 0
part := "K"::Symbol::OutputForm
(imagK(x) = 1) => part
(imagK(x) :: OutputForm) * part
if R has Field then
inv x ==
(norm x) = 0 => error "This octonion is not invertible."
(inv norm x) * conjugate x
if R has ConvertibleTo InputForm then
convert(x:%):InputForm ==
l : List InputForm := [convert("octon" :: Symbol),
convert(real x)$R, convert(imagi x)$R, convert(imagj x)$R,_
convert(imagk x)$R, convert(imagE x)$R,_
convert(imagI x)$R, convert(imagJ x)$R,_
convert(imagK x)$R]
convert(l)$InputForm
if R has OrderedSet then
x < y ==
real x = real y =>
imagi x = imagi y =>
imagj x = imagj y =>
imagk x = imagk y =>
imagE x = imagE y =>
imagI x = imagI y =>
imagJ x = imagJ y =>
imagK x < imagK y
imagJ x < imagJ y
imagI x < imagI y
imagE x < imagE y
imagk x < imagk y
imagj x < imagj y
imagi x < imagi y
real x < real y
if R has RealNumberSystem then
abs x == sqrt norm x
if R has IntegerNumberSystem then
rational? x ==
(zero? imagi x) and (zero? imagj x) and (zero? imagk x) and _
(zero? imagE x) and (zero? imagI x) and (zero? imagJ x) and _
(zero? imagK x)
rational x ==
rational? x => rational real x
error "Not a rational number"
rationalIfCan x ==
rational? x => rational real x
"failed"
|