Coding in Quaternions and Matrices

In summary, the individual is currently researching Clifford Algebra and attempting to find an explicit representation of its basis through matrices with entries in the algebra itself. They are specifically trying to write code in mathematica for KroneckerProduct and Quaternion multiplication, but have encountered a coding problem due to the definition of quaternion multiplication with ** instead of *. This creates issues when using non-commutative rings on matrices. The individual is seeking help in overriding the function to account for the non-commutativity of quaternion multiplication.
  • #1
486
0
I am currently doing some research in Clifford Algebra. My topic is to find explicit representation of its basis through matrices with entries in clifford algebra itself. At this moment I am trying to write code in mathematica to do KroneckerProduct and Quaternion multiplication. Now I have encounter a coding problem about mathematica.
In the package of << Algebra`Quaternions`, quaternion multiplication is defined with ** instead of *, where in matrix multiplication product of entries are defined with *. Thus when I use quaternion entries in my matrix multiplication, its matrix product will give me, say, Quaternion[0,1,0,0]Quaternion[0,0,1,0] instead of Quaternion[0,0,0,1]
where Quaternion[a,b,c,d] = a + b i + c j + d k.
Does anyone have any idea to override this function.

Thank you.
 
Physics news on Phys.org
  • #2
I have rewritten my problem due to my horrible english. PLease forgive me.
I am currently doing some research in Clifford Algebra. My topic is to find explicit representation of its basis through matrices with entries in clifford algebra itself. At this moment I am trying to write code in mathematica to do KroneckerProduct and Quaternion multiplication. Now I have encounter a coding problem about mathematica.
In the package of << Algebra`Quaternions`, quaternion multiplication is defined with ** (non-commutative multiplicative operator) instead of *, where matrix multiplication assumes communtivity of elements. Of course this is not the case when I use non-commutative ring on my matrices.

for examples
When I do {{0,Quaternion[0,0,1,0]},{Quaternion[0,0,1,0],0}} * {{0,-Quaternion[0,1,0,0]},{Quaternion[0,1,0,0],0}}, it will give me {{0, 0, Quaternion[0, 0, 1, 0] Quaternion[0, 1, 0, 0], 0}, {0, 0, 0, Quaternion[0, -1, 0, 0] Quaternion[0, 0, 1, 0]},{Quaternion[0, 0, 1,0] Quaternion[0, 1, 0, 0], 0, 0, 0}, {0, Quaternion[0, -1, 0, 0] Quaternion[0, 0, 1, 0], 0, 0}}

My main problem is that when I try to define the following operation Quaternion[a_, b_, c_, d_]Quaternion[e_, f_, g_, h_] := Quaternion[a, b, c, d] ** Quaternion[e, f, g, h]. It automatically assumes commutativity, i.e Quaternion[0,1,0,0]Quaternion[0,0,1,0] = Quaternion[0,0,1,0]Quaternion[0,1,0,0]. But we know they should anticommute instead.

Does anyone have any idea to override this function.

Thank you.
 
  • #3


It sounds like you are working on a very interesting and complex topic. Coding in quaternions and matrices can definitely be challenging, especially when dealing with different packages and their functions.

One possible solution to your problem could be to redefine the ** operator in the package << Algebra`Quaternions` to perform the desired quaternion multiplication. This can be done by using the Mathematica function "UpSet" to redefine the behavior of the ** operator.

Another approach could be to create your own custom function for quaternion multiplication, using the Mathematica functions "Dot" and "Cross" to perform the necessary calculations. This way, you can have more control over the output of your matrix multiplication.

I would also recommend reaching out to the developers of the << Algebra`Quaternions` package for assistance, as they may have some insights or suggestions on how to override the function.

Overall, it will require some experimentation and trial and error to find the best solution for your specific problem. But don't get discouraged, as these challenges are a normal part of coding and research. Keep exploring and I'm sure you will find a way to overcome this hurdle. Best of luck with your project!
 

1. What are quaternions and matrices?

Quaternions and matrices are mathematical tools used to represent and manipulate data in three-dimensional space. Quaternions are a type of hypercomplex numbers that consist of four components, while matrices are arrays of numbers arranged in rows and columns.

2. What is the difference between quaternions and matrices?

The main difference between quaternions and matrices is that quaternions are primarily used to represent rotations in three-dimensional space, while matrices can represent a wider range of transformations such as translation, rotation, and scaling.

3. How are quaternions and matrices used in coding?

Quaternions and matrices are used in coding to perform complex 3D transformations and animations in computer graphics and game development. They are also used in physics simulations and robotics to represent and manipulate spatial data.

4. What are the advantages of using quaternions over matrices?

One advantage of using quaternions over matrices is that they are more efficient in representing and calculating rotations in 3D space, as they require fewer operations. Additionally, quaternions do not suffer from gimbal lock, a limitation of using Euler angles to represent 3D rotations.

5. Is it necessary to have a strong understanding of mathematics to code with quaternions and matrices?

While having a strong understanding of mathematics can certainly be helpful in coding with quaternions and matrices, it is not a requirement. Many programming languages have built-in libraries and functions for working with quaternions and matrices, making it possible for even beginner programmers to use them in their projects.

Suggested for: Coding in Quaternions and Matrices

Replies
1
Views
375
Replies
2
Views
387
Replies
1
Views
680
Replies
5
Views
1K
Replies
1
Views
755
Replies
3
Views
832
Replies
1
Views
691
Replies
9
Views
819
Back
Top