Cayley Dickson Calculator
The aim of module Cayley_Calculator is to convert the REPL shell, ipython shell or idle into a fast, programmable table calculator for doing scientific and linear calculations with Cayley-Dickson numbers.
What are Cayley-Dickson numbers (CDN)? CDN's extend real (dimension 1), complex (dimension 2) and quaternionic (dimension 4) numbers (either split or non-split) to octonions (dimension 8), sedenions (dimension 16), pathions (dimension 32), chingons (dimension 64) or routons (dimension 128). These classes are included in the Cayley_Calculator. Further included are extensions of standard functions like exp, log, sin, arcsin, sinh, arsinh, ... to these classes. It is even possible to extend scientific functions in scipy.special. (Of course in this case scipy has to be installed.) As an example jv = sedenize(scipy.special.jv,1) extends the Bessel function of the first kind. Routines for doing linear algebra with CDN's are included. Thus solving equations like a*x + x*a = b are possible (even much more complicated equations).
To run Cayley_Calculator the module numpy must be installed. Modules scipy and numpy-quaternion are not necessary, but they extend the functionality of Cayley_Calculator.
Elementary background
(Citation from https://pypi.org/project/hypercomplex/): The complex numbers may be viewed as an extension of the everyday real numbers. A complex number has two real-number coefficients, one multiplied by 1, the other multiplied by i.
In a similar way, a quaternion, which has 4 components, can be constructed by combining two complex numbers. Likewise, two quaternions can construct an octonion (8 components), and two octonions can construct a sedenion (16 components).
The method for this construction is known as the Cayley-Dickson construction and the resulting classes of numbers are types of hypercomplex numbers. There is no limit to the number of times you can repeat the Cayley-Dickson construction to create new types of hypercomplex numbers, doubling the number of components each time.
Theoretical background: The only aim of this background is to fix notation, not understanding. A Cayley algebra over R is an ordered pair (A,s), where A is an algebra over R with unit element 1 and s, the conjugation, is an antiautomorphism of A such that trace T(a) = a + s(a) in R and norm N(a) = a * s(a) in R. Here s(a0,a1,...,a7) = (a0,-a1,...,a7) and * is the not necessary commutative or associative multiplication, where (a0,...,a7) is a special Octonion. To show how Sedenions are defined, let B = A x A with usual addition and let the multiplication in B be defined by
(x1,y1) * (x2,y2) = (x1*x2 + gamma4*s(y2)*y1, y1*s(x2)+y2*x1)
for (x1,y1) and (x2,y2) in B. Note that order matters. gamma1 is used for the definition of complex numbers from the real numbers, gamma2 for quaternions from complex numbers, ... gamma1 = 1 gives split complex numbers while gamma1 = -1 gives the (usual) complex numbers.
With t((x,y)) = (s(x),-y) the ordered pair (B,t) is a Cayley algebra again with trace T((x,y)) = T(x) and norm N((x,y)) = N(x) - gamma4 * N(y), in this case the algebra of Sedenions.
Literature: A standard text is N. Bourbaki (1989): Algebra I, in particular ch. III.2.4, III.7.4 and ch. III, Appendix. Here you find full proofs about commutativity, associativity and alternativity of Cayley algebras. A well known article is from J. Baez (2001), The Octonions, unfortunately only about Octonions and without proofs of some relevant results.
Installation
pip install Cayley_Calculator
and possibly
pip uninstall Octonion_Sedenion
(Cayley_Calculator generalizes Octonion_Sedenion and name conflicts are possible.)
This package was built with Python 3.14.6 and has been tested to be compatible with python 3.9 through 3.14 on Linux. Since there is no compiled code it should be compatible with python on Mac and Windows. An installation of numpy is absolutely necessary.
Basic Usage
import Cayley_Calculator
from octonion import *
That's all. To test your installation, try
a,b,c = randinteger(-10,11,3)
a,b
# (Octonion(-9, 9, -9, 2, 10, -5, -9, 6), Octonion(-3, 7, 3, 6, 1, -6, 4, -7))
a*b, b*a
# (Octonion( 17, -244, 80, 28, 39, 25, -171, -43), Octonion( 17, 64, -80, -148, -117, 113, 153, 133))
sin(a)
# Octonion(-1.21986179e+08, -1.20165952e+08, 1.20165952e+08, -2.67035450e+07, -1.33517725e+08, 6.67588625e+07, 1.20165952e+08, -8.01106349e+07)
d = randinteger(-10,11,Class=QQ)
# Quaternion(-8, 7, 5, -3)
log(d)
# Quaternion( 2.49521629, 1.76058705, 1.25756218, -0.75453731)
The first line in the initialization is always necessary, but the second line may be replaced by from pathion import *. Then by default randinteger(-10,11) generates a random Pathion with integer coefficients. If we do not want to change the defaults then randinteger(-10,11,Class=PP) has the same effect.
Input of numbers is always handled by __init__(self,*v,array=None). For example
a = Sedenion(Quaternion(1,2,3))
a
# Sedenion(1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
first generates Quaternion(1,2,3,0) and then converts this into a Sedenion. As a further example (Sedenion may be written as SS)
Sedenion(3,4,5)
SS(array = (3,4,5))
Sedenion(array = np.array([3,4,5]))
SS(*range(3,6))
all result in
Sedenion(3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0).
A final example (after from sedenion import *, otherwise e10 is not defined) with some special functions
from sedenion import *
e10
# Sedenion(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0)
u = Sedenion(4+5j)
v = Sedenion(4+5*e10)
w = 4+5*e10
print(exp(u))
print(log(v))
print(sin(w))
results in
15.48743 -52.35549i
1.85679 +0.89606r
-56.16227 -48.50246r
These initializations imply that the numbers generated are non-split. If we want to gerate split Cayley numbers, then we have to add the line set_split() as in
import Cayley_Calculator
from octonion import *
set_split()
(set_split() is equivalent to set_gamma(gamma1=1,gamma2=1,gamma3=1,gamma4=1,gamma5=1,gamma6=1,gamma7=1). The result are split Cayley numbers. Without this command gamma1=-1,...,gamma7=-1, which results in non split Cayley numbers.
Let's try again with the same values.
a = Octonion(-9, 9, -9, 2, 10, -5, -9, 6)
b = Octonion(-3, 7, 3, 6, 1, -6, 4, -7)
a*b,b*a
# (Octonion( 25, -14, 62, 32, -17, -9, 75, -43), Octonion( 25, -166, -62, -152, -61, 147, -93, 133))
a._gamma
# [1, 1, 1, 1, 1, 1, 1]
When a Cayley number is generated, it stores the actual gamma as an attribute as in a._gamma.
(Note: The last values in the corresponding results of a*b and b*a are always equal to the values for non split Cayley numbers. Why?)
Each single initialization makes all classes Complex, Quaternion, Octonion, Sedenion, Pathion, Chingon, Routon accessible.
Functionality
-
Arithmetic
After initialization of Cayley_Calculator addition, subtraction, right and left multiplication, right and left division (as far as possible) and the power function are definied. This allows standard notation. Calculations like
(1+2j)*Octonion(3,4,5,6,7)orOO(1,2,3)/PP(*range(32))(same asOctonion(1,2,3,0,0,0,0,0)/Pathion(0,1,2,...,31)) are possible. If numpy.quaternion is installed a calculation likequaternion(1,2,3,0)*OO(*range(1,9))is possible. The result should beOctonion(-12, 16, -2, 4, -28, -8, 38, 12)(for the non split case).We have two sorts of division:
(a/b)*b = a = b*(a//b) = a. Note that(a*b)/b = aand(a*b)//a = bhold true also (ifaresp.bis no zero divisor). Division by zero divisors is not implemented, but should be possible sometimes by replacingnumpy.linalg.solveby something more appropriate for ill-conditioned systems.As usual
a**bis the power ofabyb. Often the power is not defined if the normN(a)is not positive (possible for split Cayley numbers), except for integerb. IfN(a) > 0then we have (approximately)(a**b)**(1/b) = a. (Implemented are calculations with polar coordinates which solves partially the problem with multivaluedlog. The module cmath does not implement this algorithm.) Remark: For equality in(a**b)**(1/b) = abmust be an element in an alternative algebra, like reals, complex, quaternion or octonions. Isbis a Sedenion, then equality no longer holds true.getitem and setitem methods are available for Cayley numbers.
a.z1gets/sets the first part ofa,a.z2the second. Thusfrom octonion import * set_split() a = Octonion( 2, 4, -8, -5, 10, 10, -8, -4) a.z1 # Quaternion( 2, 4, -8, -5) a.z2 = -a.z1 a # Octonion( 2, 4, -8, -5, -2, -4, 8, 5) print(a*a.conj) # 0 a[1:8:2] = -a[:8:2] a # Octonion( 2, -2, -8, 8, -2, 2, 8, -8) print(a*a.conj) # 0Here
a.conjis the conjugation. -
Functions
-
Standard functions known for the fields R and C are extended to Cayley Numbers. We get the functions exp, sin, cos, tan, sinh, cosh and tanh and their inverses log, arcsin, arccos, arctan, arsinh, arcosh, artanh, further sqrt, pow, norm (the l2-norm). All these functions return values of the same type as the input. Note that some of these don't return a valid value, if the argument is split. Often these functions are implemented as methods. As an example,
a.sin()andsin(a)return the same value. -
The function
sedenizeextends functionsf : C -> Cto functionsf : B -> B, whereBis some non split Cayley algebra. Example:
from octonion import * a = Octonion(1,2,3,4,5) ssin = sedenize(cmath.sin) sin(a) # implemented sin ssin(a) # sedenized sin series.sin(a) # Taylor series of sin # Always Octonion(653.74588161, 114.24557755, 171.36836632, 228.4911551 , 285.61394387, 0, 0, 0)
Note: series is a module, which (for testing) computes some functions the resulting value with Taylor series (slow).
- Similar, for split Cayley numbers (after
set_split()) there issplit_sedenize, which extends functionsf : R -> Rto functionsf : B -> B, whereBnow is some split Cayley algebra. Example:
from octonion import * set_split() a = Octonion(1,2,3,4,5) ssin = split_sedenize(math.sin) sin(a) # implemented sin ssin(a) # sedenized sin series.sin(a) # Taylor series of sin # Always Octonion(-0.01848834, -0.23033006, -0.34549509, -0.46066012, -0.57582515, 0, 0, 0)
- There are random generators
randinteger(a,b,n=1,Class=CLASS)anduniform(a,b,n=1,Class=CLASS), which generatenrandom Cayley numbers of class CLASS with integer resp. real values. After starting withfrom sedenion import *randinteger(a,b,Class=Sedenion)andrandinteger(a,b)have the same effect. Similarly,random_ball(r=1,n=1,Class=CLASS)gerates random Cayley numbers in the ball with radiusr.
-
-
Linear Algebra
After initialization a class
Operatorexist.from octonion import *actually initializes two generatorsself.left_matrix()andself.right_matrix()for each class of Cayley numbers. Trya = Octonion(*range(1,9)) a.left_matrix() a.right_matrix()
Fast left and right multiplication is done with these generators. Essentially
a * bisa.__class__(array = a.left_matrix().array @ b._list). Even these simple operators allow solving the equationa*x+x*a = bwith(a.left_matrix()+a.right_matrix()).solve(b). (Note thata*x+x*aand2*a*xare different.)More linear algebra is available with
from linear_octonion import *
(or
linear_pathion,linear_chingon, etc.) As a simple example tryfrom linear_octonion import * A = random_operator(5,5) b = random_matrix(5) x = solve(A,b) A @ x - b
The result is an array of 5 Octonions of value 0. Here
random_operator(5,5)generates a random 5 x 5 - array of Octonion-Operators,random_matrix(5)a random 5-array of Octonions,x = solve(A,b)solves the equationA * x = b. Note that the coefficients all are Octonions.To solve a system of equations like
a*x + c*(y*b) = d, g*(x*f) + u*y = h, wherea,b,c,d,f,g,h,uare known Octonions (maybe generated witha,b,c,d,f,g,h,u = randinteger(-10,11,8), we can proceed likeL = lambda a : a.left_matrix() R = lambda a : a.right_matrix() A = np.zeros((2,2),dtype = object) A[0,0] = L(a) A[0,1] = L(c)*R(b) # first multiplication from right with `b`, then from left with `c` (order matters) A[1,0] = L(g)*R(f) A[1,1] = L(u) v = np.array(((d),(h))) # v now is a column vector of dtype object w = solve(A,v)
Then with
x = w[0]andy = w[1]the equations hold true.Remark: There are more routines in this paket, probably mostly not of general interest. As an example, rankalg([a,b]) computes the rank of the algebra generated by the elements a and b. You are free to search through the files.
About me
I have been a mathematician (retired) at the KIT in Karlsruhe, Germany. I have studied physics as well. Programming, particularly in python, is a hobby, not a profession.
Metadata
Release files for Cayley-Calculator 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cayley_calculator-1.1.0.tar.gz | 55.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cayley_calculator-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 134.0 kB
Release files / cayley_calculator-1.1.0.tar.gz
| Download URL | cayley_calculator-1.1.0.tar.gz |
|---|---|
| Size | 55.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
55f7d0773d4db425c54cc5303408c68f1ce335e3292f9dc143adc3aab39ecd0f
|
|
BLAKE2b-256 checksum How to use checksums |
cf04d446f4aad39ed07090faec4e713dcc347d4cc95ef194495a31073011ba4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / cayley_calculator-1.1.0-py3-none-any.whl
| Download URL | cayley_calculator-1.1.0-py3-none-any.whl |
|---|---|
| Size | 78.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e402ebd4dedae358302b8215acd16edff55815411557600aa1f251bf3496323d
|
|
BLAKE2b-256 checksum How to use checksums |
13f7821ab1cf5f71a37c6d514c06ff21d52b3bf142e6104723787bd6c7f1de26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|