octonion algebra

182 views
Skip to first unread message

Eric Drechsel

unread,
Feb 14, 2008, 8:56:04 PM2/14/08
to sage-devel, then...@pdx.edu, tbo...@pdx.edu, eri...@pdx.edu
Hi, I'm an undergrad at Portland State, where we have been learning
Sage as part of our Computer Assisted Mathematics Group. We want to
compute with octonions in Sage, and discussed at our meeting last
night possibly implementing such an algebra.

As I understand it, multiplication of octonions can be implemented on
top of the quaternions in a simple way using the Cayley-Dickson
construction http://en.wikipedia.org/wiki/Octonion#Cayley-Dickson_construction
.

The difficulty then would seem to be to do it correctly so that it
works with the rest of sage. I'm willing to do it once badly just for
fun and then later maybe help with doing it correctly, but I'd like to
at least get off to a respectable start. Any help would be greatly
appreciated.

Oh also in searching for existing implementations I saw that boost has
this:
http://www.boost.org/doc/html/boost_math/octonions.html
but since sage already implements quaternions it seems unnecessary to
look at boost except perhaps for inspiration.

Regards,
Eric Drechsel

Eric Drechsel

unread,
Feb 14, 2008, 10:46:43 PM2/14/08
to sage-devel
I just noticed this http://groups.google.com/group/sage-devel/browse_thread/thread/16fc3c4cb4020728
recent thread referencing http://wiki.sagemath.org/days7/coercion,
which addresses alot of the things we had questions about. It's good
to see this restructuring happening, and all the good energy around
this project!

Eric Drechsel

On Feb 14, 5:56 pm, Eric Drechsel <ericd...@gmail.com> wrote:
> Hi, I'm an undergrad at Portland State, where we have been learning
> Sage as part of our Computer Assisted Mathematics Group. We want to
> compute with octonions in Sage, and discussed at our meeting last
> night possibly implementing such an algebra.
>
> As I understand it, multiplication of octonions can be implemented on
> top of the quaternions in a simple way using the Cayley-Dickson
> constructionhttp://en.wikipedia.org/wiki/Octonion#Cayley-Dickson_construction

William Stein

unread,
Feb 14, 2008, 11:25:32 PM2/14/08
to sage-...@googlegroups.com, then...@pdx.edu, tbo...@pdx.edu, eri...@pdx.edu
On Thu, Feb 14, 2008 at 5:56 PM, Eric Drechsel <eric...@gmail.com> wrote:
>
> Hi, I'm an undergrad at Portland State, where we have been learning
> Sage as part of our Computer Assisted Mathematics Group. We want to

I saw the blog for your group a few times when I was doing a google blog
search for Sage. It looks really cool. Seattle isn't so far from
Portland, so I
hope some of you will consider coming to the next Sage days when we have
one up here (none are currently planned).

> compute with octonions in Sage, and discussed at our meeting last
> night possibly implementing such an algebra.
>
> As I understand it, multiplication of octonions can be implemented on
> top of the quaternions in a simple way using the Cayley-Dickson
> construction http://en.wikipedia.org/wiki/Octonion#Cayley-Dickson_construction
> .
> The difficulty then would seem to be to do it correctly so that it
> works with the rest of sage. I'm willing to do it once badly just for
> fun and then later maybe help with doing it correctly, but I'd like to
> at least get off to a respectable start. Any help would be greatly
> appreciated.

It's very helpful to take something already in Sage, e.g., the ring
of integers, or quaternions, or real double-precision numbers, and
copy that implementation. Note that most of the basic rings
are now implemented using Cython for speed purposes.

Of course, working in the framework of the upcoming coercion model
could also be very nice.

In any case, you're plan to just play around and do something that
works is a good one.

-- William

>
> Oh also in searching for existing implementations I saw that boost has
> this:
> http://www.boost.org/doc/html/boost_math/octonions.html
> but since sage already implements quaternions it seems unnecessary to
> look at boost except perhaps for inspiration.
>
> Regards,
> Eric Drechsel
>
> >
>

--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

Dan Christensen

unread,
Feb 16, 2008, 10:51:33 PM2/16/08
to sage-...@googlegroups.com
Eric Drechsel <eric...@gmail.com> writes:

> We want to compute with octonions in Sage, and discussed at our
> meeting last night possibly implementing such an algebra.
>
> As I understand it, multiplication of octonions can be implemented on
> top of the quaternions in a simple way using the Cayley-Dickson
> construction http://en.wikipedia.org/wiki/Octonion#Cayley-Dickson_construction
> .

If you define A_0 to be the reals and A_n to be the Cayley-Dickson
construction applied to A_{n-1}, then A_3 is the octonions. More
generally, write A_n(F) for the Cayley-Dickson construction applied
to A_{n-1}(F), where A_0 = F.

I've done lots of computations with A_4(float), A_5(float) and
A_6(float) in python, but not using Sage. I think the cleanest approach
is to define a function CayleyDickson that takes a class representing a
*-algebra and produces a new class representing the result of applying
the Cayley-Dickson construction. This allows you to change the base
"field" from float to int, Z, Z[x], high-precision floats, or whatever
you need for a particular application.

Potential problems:

- If I call CayleyDickson(float) twice, do I get a new class each time?

- How to handle coercions between A_n(F) and A_m(F)? And between A_n(F)
and A_n(F')? (F and F' are ground rings with *.)

- Efficiency. In my application, I was multiplying elements of
A_n(float) zillions of times, and this was *way* to slow using
the obvious recursive method in python. (If I recall correctly,
the time scales like 4**n.)

I instead worked with a class that directly implemented A_n(float)
using numpy arrays, and used weave to compile some inline C code for
the multiplication operation. (Cython/Pyrex might be just as good for
this, but I'm not sure if they can directly access numpy arrays as C
arrays.) It falls back to using python for the multiplication for
"object" arrays, which allows for changing float to other classes,
but is awkward.

I'm not sure how to get the best of both worlds. Maybe the first
way, with some clever Cython/Pyrex, could be made both flexible
and efficient? Or maybe the first way, with some special casing
to speed up common cases?

Dan

William Stein

unread,
Feb 16, 2008, 11:01:08 PM2/16/08
to sage-...@googlegroups.com
On Feb 16, 2008 7:51 PM, Dan Christensen <j...@uwo.ca> wrote:

> I instead worked with a class that directly implemented A_n(float)
> using numpy arrays, and used weave to compile some inline C code for
> the multiplication operation. (Cython/Pyrex might be just as good for
> this, but I'm not sure if they can directly access numpy arrays as C
> arrays.)

Quick remark -- yes, Cython most certainly can directly access numpy
arrays as C arrays. There's an extension to Cython called PEX "in
the works" that is designed partly for doing exactly this really
cleanly, but it can be done
in a messy way too.

William

Rick

unread,
Feb 25, 2008, 10:47:00 AM2/25/08
to sage-devel
If you would like a full description of octonion algebra, I suggest
you visit my web site and pull the PDF file. www.octospace.com

I know nothing about Sage, can't help you there.

Rick


On Feb 16, 7:51 pm, Dan Christensen <j...@uwo.ca> wrote:
> Eric Drechsel <ericd...@gmail.com> writes:
> > We want to compute withoctonionsin Sage, and discussed at our
> > meeting last night possibly implementing such an algebra.
>
> > As I understand it, multiplication ofoctonionscan be implemented on
> > top of the quaternions in a simple way using the Cayley-Dickson
> > constructionhttp://en.wikipedia.org/wiki/Octonion#Cayley-Dickson_construction
> > .
>
> If you define A_0 to be the reals and A_n to be the Cayley-Dickson
> construction applied to A_{n-1}, then A_3 is theoctonions.  More
Reply all
Reply to author
Forward
0 new messages