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 Aldor .

aldor
#pile
#include "axiom"
import from NonNegativeInteger
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 Complex(Expression(R)) has PartialDifferentialRing(Symbol) then D: (%,Symbol,Symbol,Symbol) -> % -- quaternion derivative rot: (C,%) -> % -- biquaternion rotation /: (%,%) -> % /: (C,%) -> % /: (%,C) -> % abs: % -> C exp: % -> % coerce: Complex R -> %
Implementation ==> Quaternion C add import from C
coerce(z:Complex R):% == import from 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 from 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 from 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 Complex(Expression(R)) 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). rot(theta:C,q:%):% == import from 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 from 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)))
aldor
Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7484925992146577797-25px001.as
using AXIOM-XL compiler and options
-O -Fasy -Fao -Flsp -laxiom -Mno-ALDOR_W_WillObsolete -DAxiom -Y $AXIOM/algebra -I$AXIOM/algebra
Use the system command )set compiler args to change these
options.
#1 (Warning) Could not use archive file libaxiom.al'.
#2 (Warning) Could not use archive file libaxiom.al'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 4:
import from AxiomLib;
............^
[L4 C13] #3 (Error) No meaning for identifier AxiomLib'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 15: import { true: %, false: % } from Boolean; ..................................^ [L15 C35] #4 (Error) No meaning for identifier Boolean'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 17: string: Literal -> %; ........................^.......^ [L17 C25] #5 (Error) No meaning for identifier Literal'. [L17 C33] #6 (Error) There are no suitable meanings for the operator ->'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 18: } from String; .......^ [L18 C8] #8 (Error) No meaning for identifier String'.
"/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7484925992146577797-25px001.as", line 4: import from NonNegativeInteger ............^ [L4 C13] #9 (Error) No meaning for identifier NonNegativeInteger'.
"/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7484925992146577797-25px001.as", line 6: BiQuaternion(R:Join(OrderedSet,CommutativeRing)): Exports == Implementation where ...............^....^..........^ [L6 C16] #10 (Error) There are no suitable meanings for the operator Join'. [L6 C21] #11 (Error) No meaning for identifier OrderedSet'. [L6 C32] #12 (Error) No meaning for identifier CommutativeRing'. [L6 C32] #13 (Fatal Error) Too many errors (use -M emax=n' or `-M no-emax' to change the limit).
The )library system command was not called after compilation.

fricas
)show BiQuaternion
The )show system command is used to display information about types or partial types. For example, )show Integer will show information about Integer .
BiQuaternion is not the name of a known type constructor. If you want to see information about any operations named BiQuaternion , issue )display operations BiQuaternion

fricas
Q := BiQuaternion Integer
There are no library operations named BiQuaternion Use HyperDoc Browse or issue )what op BiQuaternion to learn if there is any operation containing " BiQuaternion " in its name.
Cannot find a definition or applicable library operation named BiQuaternion with argument type(s) Type
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. q:Q := quatern(q0,q1,q2,q3) (1) Type: Quaternion(Polynomial(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() There are no library operations named sig0 Use HyperDoc Browse or issue )what op sig0 to learn if there is any operation containing " sig0 " in its name. Cannot find a no-argument definition or library operation named sig0 . 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)) There are no library operations named D having 4 argument(s) though there are 11 exposed operation(s) and 4 unexposed operation(s) having a different number of arguments. Use HyperDoc Browse, or issue )what op D to learn what operations contain " D " in their names, or issue )display op D to learn more about the available operations. Cannot find a definition or applicable library operation named D with argument type(s) Variable(F) Variable(x) Variable(y) Variable(z) Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

Test

(comment out this test later)

fricas
%i::Q
Cannot convert from type Complex(Integer) to NIL for value %i
abs(%i::Q)
Cannot convert from type Complex(Integer) to NIL for value %i
abs(q)
There are 6 exposed and 2 unexposed library operations named abs having 1 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op abs to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named abs with argument type(s) Quaternion(Polynomial(Integer))
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. cos(abs(%i::Q)) Cannot convert from type Complex(Integer) to NIL for value %i 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() There are no library operations named sig1 Use HyperDoc Browse or issue )what op sig1 to learn if there is any operation containing " sig1 " in its name. Cannot find a no-argument definition or library operation named sig1 . siglist(rot(2,qx)) There are no library operations named rot Use HyperDoc Browse or issue )what op rot to learn if there is any operation containing " rot " in its name. Cannot find a definition or applicable library operation named rot with argument type(s) PositiveInteger Variable(qx) Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. siglist(exp(-%i::Q*qx))
Cannot convert from type Complex(Integer) to NIL for value %i

which it does

fricas
(%%(-1)=%%(-2))@Boolean
There are 2 exposed and 8 unexposed library operations named = having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse, or issue )display op = to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named = with argument type(s) BasicOperator Quaternion(Polynomial(Integer))
Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. 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 (2) Type: Complex(Expression(Integer)) fricas map(simplify, siglist( rot(theta,q) - exp((-%i*theta/2) * q)))::List Expression Complex Integer There are no library operations named rot Use HyperDoc Browse or issue )what op rot to learn if there is any operation containing " rot " in its name. Cannot find a definition or applicable library operation named rot with argument type(s) Complex(Expression(Integer)) Quaternion(Polynomial(Integer)) Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

fricas
map(simplify,siglist(rot(2,qx)))::List Expression Complex Integer
There are no library operations named rot Use HyperDoc Browse or issue )what op rot to learn if there is any operation containing " rot " in its name.
Cannot find a definition or applicable library operation named rot with argument type(s) PositiveInteger Variable(qx)
Perhaps you should use "@" to indicate the required return type, or "\$" to specify which version of the function you need.

 Subject:   Be Bold !! ( 15 subscribers )