How can we manipulate and operate with dual quaternionic variables in Mathematica? Since a dual quaternion can be expressed like this

$\hat q = a + \epsilon b $

where $a,b \in \mathbb{H}$, or writing in the explicit form

$\hat q = a_0+a_1 i + a_2 j + a_3 k + \epsilon (b_0+b_1 i + b_2 j + b_3 k ) $

It's possible to utilize the Quaternion package with the definition of dual unit, with $\epsilon^2=0$

\[\Epsilon] /: Power[\[Epsilon], n_] := 0 /; n >= 2

to acomplish this?

  • 1
    $\begingroup$ You can always express the dual quaternion product as a $8\times8$ matrix product. $\endgroup$
    – yarchik
    Commented Jun 12, 2020 at 21:29

2 Answers 2


Add this line to your code:

Post=(#/.ε->0)+ε(D[#, ε]/.ε->0)&

Then use quaternions and $ε$.

  • $\begingroup$ Reference to the other answers implementing dual numbers here $\endgroup$ Commented Oct 31, 2022 at 16:24

While the answer from Anixx is good for dual number and some basic operations from Quaternions package, you may need to implement the Norm[] and Normalize[] if you want to work with unit dual quaternion. The block code below is my implementation for both functions (developed from Anixx answer and ashen answer in here):

DQ={(#/.de->0)+de(D[#, de]/.de->0)}&;
a = DQ[Quaternion[0.1,0.2,0.3,0.4]+de Quaternion[0.5,0.6,0.7,0.8]]
MyNorm= Norm[#] /. de -> 0 &;
InternalDotDQ=(List @@(# /. de->0)[[1]]).(List @@ Coefficient[#,de][[1]]) &;
MyNormalize=(# /. de->0)/ MyNorm[#] + de (Coefficient[#,de] / MyNorm[#]  - (# /. de->0) * ((List @@  (# /. de->0)[[1]]).(List @@ Coefficient[#,de][[1]]))/ (MyNorm[#] ^3))&;
b = MyNormalize[a]

Note that unit dual quaternion require the internal dot product = 0 and the new norm = 1, List @@ is Apply List (I need this to perform dot product), (# /. de->0)[[1]] will return the real part, and Coefficient[#,de][[1]] returns the dual part.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.