login  home  contents  what's new  discussion  bug reports help  links  subscribe  changes  refresh  edit

Biquaternion Calculus Domain

D. Cyganski and Bill Page - July 2007

This version is implemented as a new domain in SPAD.

)abbrev domain BIQ BiQuaternion
BiQuaternion(R:Join(OrderedSet,CommutativeRing)): Exports == Implementation where
C==>Complex Expression R
Exports ==> QuaternionCategory(C) with
qlist: List C -> %
-- takes a complex list (parameter l) into a quaternion
listq: % -> List C
-- takes a quaternion into a list
matrixq: % -> SquareMatrix(2,C)
-- takes a quaternion into a matrix
sig0: ()->%
sig1: ()->%
sig2: ()->%
sig3: ()->%
siglist: % -> List C
-- Pauli basis representation of the biquaternion
if C has PartialDifferentialRing(Symbol) then
D: (%,Symbol,Symbol,Symbol) -> %
-- quaternion derivative
if C has RadicalCategory and C has Field and C has TranscendentalFunctionCategory then
abs: % -> C
rot: (C,%) -> %
exp: % -> %
-- biquaternion rotation
_/: (%,%) -> %
_/: (C,%) -> %
_/: (%,C) -> %
coerce: Complex R -> %
import C
coerce(z:Complex R):% ==
import Expression(R),ComplexFunctions2(R,Expression R)
map(coerce,z)::%
-- Define a function that takes a complex list (parameter l) into a quaternion
qlist(l:List C):%==
import Integer
quatern(l 1,l 2,l 3,l 4)
-- Define a function that takes a quaternion into a list
listq(x:%):List C == [real x, imagI x, imagJ x, imagK x]
-- Define a function that takes a biquat into a matrix
matrixq(x:%):SquareMatrix(2,C) ==
import List List C
matrix [[real x + imaginary()*imagI(x), imagJ x + imaginary()*imagK(x)],
[-imagJ(x) + imaginary()*imagK(x), real x - imaginary()*imagI(x)]]
-- Define a function that produces the Pauli basis representation of the biquaternion
siglist(x:%):List C == [real x, -imaginary()*imagK(x),-imaginary()*imagJ(x),imaginary()*imagI(x)]
sig0():% == quatern(1,0,0,0)
sig1():% == imaginary() * quatern(0,0,0,1)
sig2():% == imaginary() * quatern(0,0,1,0)
sig3():% == -imaginary() * quatern(0,1,0,0)
-- Define the quaternion derivative (Morgan, 2001, Eq. 2)
if C has PartialDifferentialRing(Symbol) then
D(q:%,x:Symbol,y:Symbol,z:Symbol):% == sig1()*D(q,x)+sig2()*D(q,y)+sig3()*D(q,z)
-- Define a biquaternion rotation operator that takes a biquat through a rotation
-- of theta radians about the axis defined by the unit q biquat (Morgan 2001, Eq 3).
if C has RadicalCategory and C has Field and C has TranscendentalFunctionCategory then
rot(theta:C,q:%):% ==
import Integer, SparseMultivariatePolynomial(Integer, Kernel(C))
cos(theta/2::C)::% - imaginary()*q*sin(theta/2::C)
((x:%) / (y:%)):% == x*inv(y)$% ((x:C) / (y:%)):% == (x::%)*inv(y) ((x:%) / (y:C)):% == x*inv(y::%) abs(q:%):C == sqrt(retract(q*conjugate(q))) exp(q:%):% == import Integer, SparseMultivariatePolynomial(Integer, Kernel(C)) q-conjugate(q)=0 => exp(retract(q+conjugate(q))/2::C)*sig0() exp(retract(q+conjugate(q))/2::C) * (sig0()*cos(abs(q)) + (q-conjugate(q))/abs(q-conjugate(q)) * sin(abs(q))) spad  Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/8384816125117043612-25px001.spad using old system compiler. BIQ abbreviates domain BiQuaternion ------------------------------------------------------------------------ initializing NRLIB BIQ for BiQuaternion compiling into NRLIB BIQ ****** Domain: R already in scope importing Complex Expression R compiling exported coerce : Complex R ->$
Time: 0.29 SEC.
compiling exported qlist : List Complex Expression R -> $Time: 0.01 SEC. compiling exported listq :$ -> List Complex Expression R
Time: 0 SEC.
compiling exported matrixq : $-> SquareMatrix(2,Complex Expression R) Time: 0.02 SEC. compiling exported siglist :$ -> List Complex Expression R
Time: 0 SEC.
compiling exported sig0 : () -> $Time: 0 SEC. compiling exported sig1 : () ->$
Time: 0 SEC.
compiling exported sig2 : () -> $Time: 0 SEC. compiling exported sig3 : () ->$
Time: 0 SEC.
compiling exported D : ($,Symbol,Symbol,Symbol) ->$
Time: 0.05 SEC.
****** Domain: (Complex (Expression R)) already in scope
****** Domain: (Complex (Expression R)) already in scope
augmenting (Complex (Expression R)): (Field)
****** Domain: (Complex (Expression R)) already in scope
augmenting (Complex (Expression R)): (TranscendentalFunctionCategory)
augmenting $: (SIGNATURE$ abs ((Complex (Expression R)) $)) augmenting$: (SIGNATURE $rot ($ (Complex (Expression R)) $)) augmenting$: (SIGNATURE $exp ($ $)) augmenting$: (SIGNATURE $/ ($ ))
augmenting $: (SIGNATURE$ / ($(Complex (Expression R))$))
augmenting $: (SIGNATURE$ / ( (Complex (Expression R))))
compiling exported rot : (Complex Expression R,$) ->$
Time: 0.12 SEC.
compiling exported / : ($,$) -> $Time: 0 SEC. compiling exported / : (Complex Expression R,$) -> $Time: 0 SEC. compiling exported / : ($,Complex Expression R) -> $Time: 0 SEC. compiling exported abs :$ -> Complex Expression R
Time: 0 SEC.
compiling exported exp : $->$
Time: 0.38 SEC.
****** Domain: (Complex (Expression R)) already in scope
augmenting (Complex (Expression R)): (Field)
****** Domain: (Complex (Expression R)) already in scope
****** Domain: (Complex (Expression R)) already in scope
augmenting (Complex (Expression R)): (TranscendentalFunctionCategory)
augmenting $: (SIGNATURE$ abs ((Complex (Expression R)) $)) augmenting$: (SIGNATURE $rot ($ (Complex (Expression R)) $)) augmenting$: (SIGNATURE $exp ($ $)) augmenting$: (SIGNATURE $/ ($ ))
augmenting $: (SIGNATURE$ / ($(Complex (Expression R))$))
augmenting $: (SIGNATURE$ / ( (Complex (Expression R))))
****** Domain: (Complex (Expression R)) already in scope
augmenting (Complex (Expression R)): (CharacteristicNonZero)
****** Domain: (Complex (Expression R)) already in scope
augmenting (Complex (Expression R)): (ConvertibleTo (InputForm))
****** Domain: (Complex (Expression R)) already in scope
augmenting (Complex (Expression R)): (DifferentialRing)
****** Domain: (Complex (Expression R)) already in scope
augmenting (Complex (Expression R)): (Eltable (Complex (Expression R)) (Complex (Expression R)))
****** Domain: (Complex (Expression R)) already in scope
augmenting (Complex (Expression R)): (EntireRing)
****** Domain: (Complex (Expression R)) already in scope
augmenting (Complex (Expression R)): (Evalable (Complex (Expression R)))
****** Domain: (Complex (Expression R)) already in scope
augmenting (Complex (Expression R)): (Field)
****** Domain: (Complex (Expression R)) already in scope
augmenting (Complex (Expression R)): (InnerEvalable (Symbol) (Complex (Expression R)))
****** Domain: (Complex (Expression R)) already in scope
augmenting (Complex (Expression R)): (IntegerNumberSystem)
****** Domain: (Complex (Expression R)) already in scope
augmenting (Complex (Expression R)): (LinearlyExplicitRingOver (Integer))
****** Domain: (Complex (Expression R)) already in scope
augmenting (Complex (Expression R)): (OrderedSet)
****** Domain: (Complex (Expression R)) already in scope
augmenting (Complex (Expression R)): (RetractableTo (Fraction (Integer)))
****** Domain: (Complex (Expression R)) already in scope
augmenting (Complex (Expression R)): (RetractableTo (Integer))
(time taken in buildFunctor:  70)
;;;     ***       |BiQuaternion| REDEFINED
;;;     ***       |BiQuaternion| REDEFINED
Time: 0.43 SEC.
Cumulative Statistics for Constructor BiQuaternion
Time: 1.30 seconds
finalizing NRLIB BIQ
Processing BiQuaternion for Browser database:
--->-->BiQuaternion(constructor): Not documented!!!!
--->-->BiQuaternion((qlist (% (List (Complex (Expression R)))))): Not documented!!!!
--->-->BiQuaternion((listq ((List (Complex (Expression R))) %))): Not documented!!!!
--->-->BiQuaternion((matrixq ((SquareMatrix 2 (Complex (Expression R))) %))): Not documented!!!!
--->-->BiQuaternion((sig0 (%))): Not documented!!!!
--->-->BiQuaternion((sig1 (%))): Not documented!!!!
--->-->BiQuaternion((sig2 (%))): Not documented!!!!
--->-->BiQuaternion((sig3 (%))): Not documented!!!!
--->-->BiQuaternion((siglist ((List (Complex (Expression R))) %))): Not documented!!!!
--->-->BiQuaternion((D (% % (Symbol) (Symbol) (Symbol)))): Not documented!!!!
--->-->BiQuaternion((abs ((Complex (Expression R)) %))): Not documented!!!!
--->-->BiQuaternion((rot (% (Complex (Expression R)) %))): Not documented!!!!
--->-->BiQuaternion((exp (% %))): Not documented!!!!
--->-->BiQuaternion((/ (% % %))): Not documented!!!!
--->-->BiQuaternion((/ (% (Complex (Expression R)) %))): Not documented!!!!
--->-->BiQuaternion((/ (% % (Complex (Expression R))))): Not documented!!!!
--->-->BiQuaternion((coerce (% (Complex R)))): Not documented!!!!
--->-->BiQuaternion(): Missing Description
; compiling file "/var/aw/var/LatexWiki/BIQ.NRLIB/BIQ.lsp" (written 14 JUL 2013 10:44:39 AM):
; /var/aw/var/LatexWiki/BIQ.NRLIB/BIQ.fasl written
; compilation finished in 0:00:00.107
------------------------------------------------------------------------
BiQuaternion is now explicitly exposed in frame initial
BiQuaternion will be automatically loaded when needed from
/var/aw/var/LatexWiki/BIQ.NRLIB/BIQ

fricas
)show BiQuaternion
BiQuaternion(R: Join(OrderedSet,CommutativeRing))  is a domain constructor
Abbreviation for BiQuaternion is BIQ
This constructor is exposed in this frame.
------------------------------- Operations --------------------------------
?*? : (%,%) -> %                      ?*? : (Integer,%) -> %
?*? : (PositiveInteger,%) -> %        ?+? : (%,%) -> %
?-? : (%,%) -> %                      -? : % -> %
?=? : (%,%) -> Boolean                1 : () -> %
0 : () -> %                           ?^? : (%,PositiveInteger) -> %
annihilate? : (%,%) -> Boolean        coerce : Complex(R) -> %
coerce : Integer -> %                 coerce : % -> OutputForm
conjugate : % -> %                    hash : % -> SingleInteger
latex : % -> String                   one? : % -> Boolean
opposite? : (%,%) -> Boolean          recip : % -> Union(%,"failed")
sample : () -> %                      sig0 : () -> %
sig1 : () -> %                        sig2 : () -> %
sig3 : () -> %                        zero? : % -> Boolean
?~=? : (%,%) -> Boolean
?*? : (Fraction(Integer),%) -> % if Complex(Expression(R)) has FIELD
?*? : (%,Fraction(Integer)) -> % if Complex(Expression(R)) has FIELD
?*? : (Complex(Expression(R)),%) -> %
?*? : (%,Complex(Expression(R))) -> %
?*? : (NonNegativeInteger,%) -> %
?/? : (%,Complex(Expression(R))) -> % if Complex(Expression(R)) has FIELD and Complex(Expression(R)) has RADCAT and Complex(Expression(R)) has TRANFUN
?/? : (Complex(Expression(R)),%) -> % if Complex(Expression(R)) has FIELD and Complex(Expression(R)) has RADCAT and Complex(Expression(R)) has TRANFUN
?/? : (%,%) -> % if Complex(Expression(R)) has FIELD and Complex(Expression(R)) has RADCAT and Complex(Expression(R)) has TRANFUN
?<? : (%,%) -> Boolean if Complex(Expression(R)) has ORDSET
?<=? : (%,%) -> Boolean if Complex(Expression(R)) has ORDSET
?>? : (%,%) -> Boolean if Complex(Expression(R)) has ORDSET
?>=? : (%,%) -> Boolean if Complex(Expression(R)) has ORDSET
D : (%,Symbol,Symbol,Symbol) -> % if Complex(Expression(R)) has PDRING(SYMBOL)
D : (%,(Complex(Expression(R)) -> Complex(Expression(R)))) -> %
D : (%,(Complex(Expression(R)) -> Complex(Expression(R))),NonNegativeInteger) -> %
D : (%,List(Symbol),List(NonNegativeInteger)) -> % if Complex(Expression(R)) has PDRING(SYMBOL)
D : (%,Symbol,NonNegativeInteger) -> % if Complex(Expression(R)) has PDRING(SYMBOL)
D : (%,List(Symbol)) -> % if Complex(Expression(R)) has PDRING(SYMBOL)
D : (%,Symbol) -> % if Complex(Expression(R)) has PDRING(SYMBOL)
D : (%,NonNegativeInteger) -> % if Complex(Expression(R)) has DIFRING
D : % -> % if Complex(Expression(R)) has DIFRING
?^? : (%,Integer) -> % if Complex(Expression(R)) has FIELD
?^? : (%,NonNegativeInteger) -> %
abs : % -> Complex(Expression(R)) if Complex(Expression(R)) has FIELD and Complex(Expression(R)) has RADCAT and Complex(Expression(R)) has TRANFUN or Complex(Expression(R)) has RNS
associates? : (%,%) -> Boolean if Complex(Expression(R)) has ENTIRER
characteristic : () -> NonNegativeInteger
charthRoot : % -> Union(%,"failed") if Complex(Expression(R)) has CHARNZ
coerce : Fraction(Integer) -> % if Complex(Expression(R)) has FIELD or Complex(Expression(R)) has RETRACT(FRAC(INT))
coerce : Complex(Expression(R)) -> %
convert : % -> InputForm if Complex(Expression(R)) has KONVERT(INFORM)
differentiate : (%,(Complex(Expression(R)) -> Complex(Expression(R)))) -> %
differentiate : (%,(Complex(Expression(R)) -> Complex(Expression(R))),NonNegativeInteger) -> %
differentiate : (%,List(Symbol),List(NonNegativeInteger)) -> % if Complex(Expression(R)) has PDRING(SYMBOL)
differentiate : (%,Symbol,NonNegativeInteger) -> % if Complex(Expression(R)) has PDRING(SYMBOL)
differentiate : (%,List(Symbol)) -> % if Complex(Expression(R)) has PDRING(SYMBOL)
differentiate : (%,Symbol) -> % if Complex(Expression(R)) has PDRING(SYMBOL)
differentiate : (%,NonNegativeInteger) -> % if Complex(Expression(R)) has DIFRING
differentiate : % -> % if Complex(Expression(R)) has DIFRING
?.? : (%,Complex(Expression(R))) -> % if Complex(Expression(R)) has ELTAB(COMPLEX(EXPR(R)),COMPLEX(EXPR(R)))
eval : (%,Symbol,Complex(Expression(R))) -> % if Complex(Expression(R)) has IEVALAB(SYMBOL,COMPLEX(EXPR(R)))
eval : (%,List(Symbol),List(Complex(Expression(R)))) -> % if Complex(Expression(R)) has IEVALAB(SYMBOL,COMPLEX(EXPR(R)))
eval : (%,List(Equation(Complex(Expression(R))))) -> % if Complex(Expression(R)) has EVALAB(COMPLEX(EXPR(R)))
eval : (%,Equation(Complex(Expression(R)))) -> % if Complex(Expression(R)) has EVALAB(COMPLEX(EXPR(R)))
eval : (%,Complex(Expression(R)),Complex(Expression(R))) -> % if Complex(Expression(R)) has EVALAB(COMPLEX(EXPR(R)))
eval : (%,List(Complex(Expression(R))),List(Complex(Expression(R)))) -> % if Complex(Expression(R)) has EVALAB(COMPLEX(EXPR(R)))
exp : % -> % if Complex(Expression(R)) has FIELD and Complex(Expression(R)) has RADCAT and Complex(Expression(R)) has TRANFUN
exquo : (%,%) -> Union(%,"failed") if Complex(Expression(R)) has ENTIRER
hashUpdate! : (HashState,%) -> HashState
imagI : % -> Complex(Expression(R))
imagJ : % -> Complex(Expression(R))
imagK : % -> Complex(Expression(R))
inv : % -> % if Complex(Expression(R)) has FIELD
listq : % -> List(Complex(Expression(R)))
map : ((Complex(Expression(R)) -> Complex(Expression(R))),%) -> %
matrixq : % -> SquareMatrix(2,Complex(Expression(R)))
max : (%,%) -> % if Complex(Expression(R)) has ORDSET
min : (%,%) -> % if Complex(Expression(R)) has ORDSET
norm : % -> Complex(Expression(R))
qlist : List(Complex(Expression(R))) -> %
quatern : (Complex(Expression(R)),Complex(Expression(R)),Complex(Expression(R)),Complex(Expression(R))) -> %
rational : % -> Fraction(Integer) if Complex(Expression(R)) has INS
rational? : % -> Boolean if Complex(Expression(R)) has INS
rationalIfCan : % -> Union(Fraction(Integer),"failed") if Complex(Expression(R)) has INS
real : % -> Complex(Expression(R))
reducedSystem : Matrix(%) -> Matrix(Complex(Expression(R)))
reducedSystem : (Matrix(%),Vector(%)) -> Record(mat: Matrix(Complex(Expression(R))),vec: Vector(Complex(Expression(R))))
reducedSystem : (Matrix(%),Vector(%)) -> Record(mat: Matrix(Integer),vec: Vector(Integer)) if Complex(Expression(R)) has LINEXP(INT)
reducedSystem : Matrix(%) -> Matrix(Integer) if Complex(Expression(R)) has LINEXP(INT)
retract : % -> Complex(Expression(R))
retract : % -> Fraction(Integer) if Complex(Expression(R)) has RETRACT(FRAC(INT))
retract : % -> Integer if Complex(Expression(R)) has RETRACT(INT)
retractIfCan : % -> Union(Complex(Expression(R)),"failed")
retractIfCan : % -> Union(Fraction(Integer),"failed") if Complex(Expression(R)) has RETRACT(FRAC(INT))
retractIfCan : % -> Union(Integer,"failed") if Complex(Expression(R)) has RETRACT(INT)
rot : (Complex(Expression(R)),%) -> % if Complex(Expression(R)) has FIELD and Complex(Expression(R)) has RADCAT and Complex(Expression(R)) has TRANFUN
siglist : % -> List(Complex(Expression(R)))
smaller? : (%,%) -> Boolean if Complex(Expression(R)) has ORDSET
subtractIfCan : (%,%) -> Union(%,"failed")
unit? : % -> Boolean if Complex(Expression(R)) has ENTIRER
unitCanonical : % -> % if Complex(Expression(R)) has ENTIRER
unitNormal : % -> Record(unit: %,canonical: %,associate: %) if Complex(Expression(R)) has ENTIRER

fricas
Q := BiQuaternion Integer
 (1)
Type: Type
fricas
q:Q := quatern(q0,q1,q2,q3)
 (2)
Type: BiQuaternion?(Integer)

For testing the derivative we define this set of operators

fricas
Ft:=operator 'Ft; Fx:=operator 'Fx; Fy:=operator 'Fy; Fz:=operator 'Fz;
Type: BasicOperator?

Now form a general quaternion which is a function of x,y,z

fricas
F:Q:=Ft(x,y,z)*sig0()+Fx(x,y,z)*sig1()+Fy(x,y,z)*sig2()+Fz(x,y,z)*sig3()
 (3)
Type: BiQuaternion?(Integer)

In the Pauli basis the derivative of this biquat should produce (Morgan 2001, eq 1):

  D(Ft+F.sigma)=div(F)+(grad(Ft)+%i*curl(F)).sigma


which it does

fricas
siglist(D(F,x,y,z))
 (4)
Type: List(Complex(Expression(Integer)))

## Test

(comment out this test later)

fricas
%i::Q
 (5)
Type: BiQuaternion?(Integer)
fricas
abs(%i::Q)
 (6)
Type: Complex(Expression(Integer))
fricas
abs(q)
 (7)
Type: Complex(Expression(Integer))
fricas
cos(abs(%i::Q))
 (8)
Type: Complex(Expression(Integer))

If I've defined these correctly, then the rotation about the x axis defined by qx below by 2 radians should give the same answer as exponentiation to -%i*qx (not a very complete test)

fricas
qx:Q:=sig1()
 (9)
Type: BiQuaternion?(Integer)
fricas
siglist(rot(2,qx))
 (10)
Type: List(Complex(Expression(Integer)))
fricas
siglist(exp(-%i::Q*qx))
 (11)
Type: List(Complex(Expression(Integer)))

which it does

fricas
(%%(-1)=%%(-2))@Boolean
 (12)
Type: Boolean

I would love to express a proof of equality such as:

   rot(theta,q) = exp((-theta/2)*%i*q)


for arbitrary real and biquaternion q as I would in Maple.

fricas
theta:Complex Expression Integer := _\theta
 (13)
Type: Complex(Expression(Integer))
fricas
map(simplify, siglist( rot(theta,q) - exp((-%i*theta/2) * q)))::List Expression Complex Integer
 (14)
Type: List(Expression(Complex(Integer)))

fricas
map(simplify,siglist(rot(2,qx)))
 (15)
Type: List(Expression(Integer))

 Subject:   Be Bold !! ( 14 subscribers )