# \[WSS19\] Hypercomplex Numbers Package

**URL:** <https://community.wolfram.com/t/wss19-hypercomplex-numbers-package/14396>\
**Category:** Staff Picks\
**Tags:** physics, wolfram-add-ons, graphics-and-visualization, group-theory, packages-and-paclets, symbolic-computations, staff-pick, wolfram-summer-research-institute\
**Created:** [July 10, 2019, 9:32pm UTC](https://community.wolfram.com/t/wss19-hypercomplex-numbers-package/14396 "2019-07-10T21:32:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alecmacher](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/alecmacher/32/20530_2.png) [@alecmacher](https://community.wolfram.com/u/alecmacher)\
**Post date:** [July 10, 2019, 9:32pm UTC](https://community.wolfram.com/t/wss19-hypercomplex-numbers-package/14396/1 "2019-07-10T21:32:36Z")

</div>

# Introduction

Mathematica allows for symbolic manipulation of real and complex numbers natively. Great collective efforts have been done to implement quaternions, but higher dimensional Cayley-Dickson algebras have not been implemented as of now. Previous implementations of quaternions are designed in such a way that extending to octonions for example is not very practical.

# Cayley-Dickson Construction

A key feature in mind while developing this package was to have a framework in which all Cayley-Dickson algebras and other future implementations of hypercomplex algebras such as the biquaternions could sit on. The Cayley-Dickson Construction is the way in which Cayley-Dickson hypercomplex numbers are constructed in pure mathematics. The way it works is to define complex numbers as an ordered pair of real numbers, and quaternions as an ordered pair of complex numbers, and octonions as an ordered pair of quaternions and so on. Then, defining addition pointwise and multiplication of two ordered pairs as

(a,b)(c,d)=(ac-d^{\*}b,ad+bc^{\*})

where multiplication of the ordered pairs and of its elements is not commutative. Hence, if we are multiplying two octonions we represent them as ordered pairs of quaternions and when we have to multiply them we apply the definition again, in each step reducing until we get to the real numbers. So for this reason, I decided to symbolically represent this type of hypercomplex numbers like this.

# Symbolic Manipulation

A great feature of this is that the programmer is no longer required to tediously provide the formula for multiplication of hypercomplex numbers. For example for octonionic multiplication one would need to define it like so:

```
Octonion[{a, b, c, d, e, f, g, h}]\[CenterDot]Octonion[{s, t, u, v, w,
    x, y, z}]

```

![ScreenShot2019-07-10at5.23.09PM.png](https://global.discourse-cdn.com/wolfram/original/2X/4/42c6fb1b0712c27e9c03b9978532a71ae3daeb36.png)

A symbolic approach propagates to a lot of benefits to the user as well:

```
Exp[Octonion[{a, b, c, d, e, f, g, h}]]

```

 ![ScreenShot2019-07-10at5.23.23PM.png](https://global.discourse-cdn.com/wolfram/original/3X/2/3/23b561ecc09de13627dcad8c45c6495d44692b97.png)

Dimensions higher than sedenions are called with the head Hypercomplex. If Hypercomplex is called with a list of 8 arguments for example, it will output with an Octonion head.

# Quaternionic Rotation

The package also provides functions that might be of use. For example this generates a rotation quaternion about the given angle and axis of rotation

```
RotationQuaternion[\[Pi]/6, {1, 2, 1}]

```

![ScreenShot2019-07-10at5.21.09PM.png](https://global.discourse-cdn.com/wolfram/original/3X/0/7/078e958810115bf493ce17b10bcec1b779594ebf.png)

This function provides the corresponding 3D rotation matrix with the given rotation quaternion:

```
RotationQuaternionMatrix[
  RotationQuaternion[\[Pi]/6, {1, 2, 1}]] // TraditionalForm

```

![ScreenShot2019-07-10at5.25.35PM.png](https://global.discourse-cdn.com/wolfram/original/2X/6/6607625af5d9f5784236698f333469b7f3f64412.png)

The inverse is problem of finding the rotation quaternion given a rotation matrix is also handled:

```
RotationQuaternion[{{1, 0, 0}, {0, Sqrt[3]/2, -(1/2)}, {0, 1/2, Sqrt[
   3]/2}}]

```

![ScreenShot2019-07-10at5.26.14PM.png](https://global.discourse-cdn.com/wolfram/original/2X/8/8d6f4eee83aee187c0d19726556bcfd9085dd2e4.png)

We can easily do some fun stuff with this:

 ![ScreenShot2019-07-10at5.35.11PM.png](https://global.discourse-cdn.com/wolfram/original/3X/f/3/f361e31640ce87ed192c9f4c699bcb97cb3ac833.png)

![9253spikeyrotation.gif](https://global.discourse-cdn.com/wolfram/original/2X/0/0fe11fdeb14b9b6cd0927b4c71af40765e1ed66a.gif)

# Cayley Table

When researching algebraic structures a common approach is to produce a Cayley table. The package provides a function that given a 2^n dimension gives the Cayley table associated with the Cayley-Dickson algebra of 2^n dimensions.

```
HypercomplexCayleyTable[16]

```

 ![ScreenShot2019-07-10at5.27.27PM.png](https://global.discourse-cdn.com/wolfram/original/3X/c/3/c3566b7e03067dabccd35f594cead0e0fc3de961.png)

To verify this it might be quite tedious to write down 16 numbers. For this Hypercomplex, apart from being able to take a list of coefficients, it can also take a function and a dimension. The result is a hypercomplex number that takes as its coefficients the function applied to the index of the unit vector the coefficient corresponds to. So, we can verify a value for our Cayley table like this:

```
e[i_] := Hypercomplex[If[# == i, 1, 0] &, 16]
e[15]\[CenterDot]e[13]

```

![ScreenShot2019-07-10at5.28.38PM.png](https://global.discourse-cdn.com/wolfram/original/3X/f/8/f82d80454ad25923defb0cbb79973895e98efeca.png)

# Further Direction

The previous definition of referring to a hypercomplex number as a function makes me consider the case where the size tends to infinity. I like to call these ‘ultracomplex’ numbers since they form an infinite-dimensional vector space and they are beyond any hypercomplex number. Future directions would probably include tools to analyze these numbers, although the Wolfram Language already contains various analysis tools that may help in this research.  
Additionally, Complex[1,2] outputs the number 1+2I. It would be interesting to have a similar notation for hypercomplex numbers. Quaternions are usually written as I,J,K but we might like a more abstract algebraic notation for higher dimensional numbers.  
Also, there are modified versions of the Cayley-Dickson Construction that give rise to split-quaternions for example. So implementing these would also be a direction to follow. By a similar fashion we also have biquaternions and so on, which are just like we’ve seen so far but with complex coefficients.  
Finally, I think hypercomplex numbers should be implemented as natively as complex numbers so that their calculation are improved.

Here is the link to the package’s Github [repository](https://github.com/alecmacher/SummerSchool2019).

---

<div class="post-metadata">

**Author:** ![wolframcommunity](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/wolframcommunity/32/8335_2.png) [@wolframcommunity](https://community.wolfram.com/u/wolframcommunity)\
**Post date:** [December 19, 2022, 10:19pm UTC](https://community.wolfram.com/t/wss19-hypercomplex-numbers-package/14396/2 "2022-12-19T22:19:30Z")

</div>

![news-congrads-kkluyshnik-02-04-19.jpg](https://global.discourse-cdn.com/wolfram/original/3X/6/a/6a310c2d0904616faf4e6e148260c9f29ab9f4eb.jpeg) – you have earned _ **Featured Contributor Badge** _ ![2015-11-02_10-07-11.png](https://global.discourse-cdn.com/wolfram/original/3X/5/0/50e59c9ead62f729e7130d3ea1482555a75602b6.png)  
Your exceptional post has been selected for our editorial column _ **Staff Picks** _ [http://wolfr.am/StaffPicks](http://wolfr.am/StaffPicks) and [Your Profile](http://community.wolfram.com/web/alecmacher) is now distinguished by a _ **Featured Contributor Badge** _ and is displayed on the [Featured Contributor Board](https://community.wolfram.com/people). Thank you!

---

<div class="post-metadata">

**Author:** ![robertwalgate](https://avatars.discourse-cdn.com/v4/letter/r/e5b9ba/32.png) [@robertwalgate](https://community.wolfram.com/u/robertwalgate)\
**Post date:** [May 15, 2025, 1:46am UTC](https://community.wolfram.com/t/wss19-hypercomplex-numbers-package/14396/3 "2025-05-15T01:46:47Z")

</div>

Very promising, thank you!

But I have two questions:

1. How could I access your package without joining GitHub?
2. For a representation of a Clifford algebra in Mathematica, I need to construct and multiply matrices of biquaternions, ie quaternions with complex components, ie ones in which the imaginary parts commute with the other elements of the algebra. But the Cayley-Dickinson procedure assumes all components are real; so the C-D quaternion has four real components, whereas the biquaternion has eight (but because of the commutation I mentioned it is NOT an octonion). Does your package allow such complex components?

Robert Walgate

---

<div class="post-metadata">

**Author:** ![alecmacher](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/alecmacher/32/20530_2.png) [@alecmacher](https://community.wolfram.com/u/alecmacher)\
**Post date:** [May 15, 2025, 4:37pm UTC](https://community.wolfram.com/t/wss19-hypercomplex-numbers-package/14396/4 "2025-05-15T16:37:21Z")

</div>

This package is very outdated. I recommend the GeometricAlgebra paclet instead:

[https://resources.wolframcloud.com/PacletRepository/resources/Wolfram/GeometricAlgebra/](https://resources.wolframcloud.com/PacletRepository/resources/Wolfram/GeometricAlgebra/)

As well, here is a Tech Note that shows how to define bi-quaternions using this paclet:

[https://www.wolframcloud.com/obj/nikm/Published/GeometricNumbers.nb](https://www.wolframcloud.com/obj/nikm/Published/GeometricNumbers.nb)

---

<div class="post-metadata">

**Author:** ![hansmilton](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/hansmilton/32/8656_2.png) [@hansmilton](https://community.wolfram.com/u/hansmilton)\
**Post date:** [May 15, 2025, 5:04pm UTC](https://community.wolfram.com/t/wss19-hypercomplex-numbers-package/14396/5 "2025-05-15T17:04:31Z")

</div>

On GitHub I can find several Mathematica packages working with either quaternions or octonions. But none that covers both, the hyper complex numbers.

[https://github.com/search?q=Quaternions%20language%3AMathematica&type=repositories](https://github.com/search?q=Quaternions%20language:Mathematica&type=repositories)

[https://github.com/search?q=Octonions%20language%3AMathematica&type=repositories](https://github.com/search?q=Octonions%20language:Mathematica&type=repositories)

[https://github.com/search?q=Hypercomplex%20language%3AMathematica&type=repositories](https://github.com/search?q=Hypercomplex%20language:Mathematica&type=repositories)

When searching on GitHub you need to have an account and being logged in. Otherwise you may get an annoying “Whoa There” message.
