Carl McTague <mctague@santafe.edu> writes:
> Hi, I'd like to do some computations with quaternions.
[...]
> Is it possible to implement them with the .-operator with reduction
> rules similar to those used to implement the complex numbers: so
> that I could do something like (%i+2*%j).(4-6*%j), for instance?
Schelter's `affine' package implements various facilities for dealing
with non-commutative algebras. Unfortunately, it's not in the current
release, but I intend to check it in now. I am going to send a
separate message about this to the mailing list.
Meanwhile, here is a Maxima transcript which shows one way of setting
up the quaternion algebra and doing some basic calculations (after
loading the affine package). I added some comments (between /* ...
*/).
/* First some options, which should give us a reasonably bug free
state. */
(C2) dotexptsimp:false;
(D2) FALSE
(C3) dotscrules:true;
(D3) TRUE
(C4) matrix_element_mult:".";
(D4) .
/* Generators of the algebra. */
(C5) current_variables:[i,j,k];
(D5) [i, j, k]
(C6) declare_weights(i,0,j,0,k,0);
(D6) FALSE
/* Weights are declared 0 because i.i etc. should be scalars. Here is
a simple test. */
(C7) nc_degree(i.i);
(D7) 0
/* Give a generating set of relations. */
(C8) set_up_dot_simplifications([i.i+1,j.j+1,i.j-k,j.i+k]);
The value of $ORDER_FUNCTION is $MONOMIAL_ALPHALESSP
Beginning to simplify:
i . i + 1
starting to resimplify dot simplifications..
[i . i, - 1]
They were OK
Adding to simps:
[i . i, - 1]
Beginning to simplify:
j . j + 1
starting to resimplify dot simplifications..
[j . j, - 1, i . i, - 1]
They were OK
Adding to simps:
[j . j, - 1]
Beginning to simplify:
- k + i . j
starting to resimplify dot simplifications..
[k, i . j, j . j, - 1, i . i, - 1]
They were OK
Adding to simps:
[k, i . j]
Beginning to simplify:
k + j . i
starting to resimplify dot simplifications..
[k, i . j, j . j, - 1, j . i, - i . j, i . i, - 1]
They were OK
Adding to simps:
[j . i, - i . j]
The new dot simplifications are set up
(D8)/R/ [k, i . j, j . j, - 1, j . i, - i . j, i . i, - 1]
/* Now check that Maxima is able to complete the multiplication table */
(C9) dotsimp(k.k);
Beginning to simplify:
k . k
Final answer:
- 1
(D9) - 1
(C10) dotsimp(j.k);
Beginning to simplify:
j . k
(D10)/R/ i
(C11) dotsimp(k.j);
Beginning to simplify:
k . j
(D11)/R/ - i
(C12) dotsimp(k.i);
Beginning to simplify:
k . i
(D12)/R/ j
(C13) dotsimp(i.k);
Beginning to simplify:
i . k
(D13)/R/ - j
/* Your example */
(C14) dotsimp(expand((i+2*j).(4-6*j)));
Beginning to simplify:
- 12 (j . j) + 8 j - 6 (i . j) + 4 i
(D14)/R/ 8 j - 6 (i . j) + 4 i + 12
(C15)
Wolfgang