LijiH

90 Reputation

7 Badges

13 years, 204 days

MaplePrimes Activity


These are replies submitted by LijiH

I see what you are doing, it's very brilliant!

May I ask you what package you have with'd to be able to writ


unitquat := identical~(unitquats):

in a new worksheet, I get the following error. could it be that I am still using maple 12?

I see what you are doing, it's very brilliant!

May I ask you what package you have with'd to be able to writ


unitquat := identical~(unitquats):

in a new worksheet, I get the following error. could it be that I am still using maple 12?

thank you!

thank you!

thanks you!

thanks you!

thank you.

thank you.

here it is, thanks in advance!

here it is, thanks in advance!

@acer 

thank you as always!

@acer 

thank you as always!

good point. thanks for pointing this out.

good point. thanks for pointing this out.

first of all, thank you for your help.

yes what I am doing is trying to write my own quaternion package.

the one written by Michael Carter from Purdue University uses the following:

proc () [`*` = Quaternions:-`*`] end proc

#so * points to Quaternions:-`*`, so let's see what Quaternions:-`*` is.

readlib(Quaternions:-`*`)

proc (qx::quaternion, qy::quaternion)
    options overload;
    if type(qx, complex) and type(qy, complex) then
        return qx*qy
    end if;
    try
    return `Quaternions:-Qmult`(qx, qy)
    catch:
    return qx*qy
    end try
end proc

#so we need to know what Quaternions:-Qmult is:

readlib(Qmult);
proc (qx::quaternion, qy::quaternion)
    local q, q1, q2;
    q1 := Qeval(qx);
    q2 := Qeval(qy);
    if is(q1, real) or is(q2, real) then
        return Qeval(q1*q2)
    end if;
    try q := Qeval(linalg[multiply](q1, q2)) catch:
        return q1*q2
    end try;
    if not is(q, quaternion) then
        Qeval(evalf(q))
    else
        return q
    end if
end proc

#so all of this depend on Qeval:

readlib(Qeval);
proc(q1)
    local q:=q1;
    try
        if type(evalm(q),'matrix'(square)) then
            return sort(collect(expand(linalg[trace](linalg[submatrix](q,1..1,1..1))+linalg[trace](linalg[submatrix](q,1..1,2..2))*'i'+linalg[trace](linalg[submatrix](q,3..3,2..2))*'j'+linalg[trace](linalg[submatrix](q,3..3,1..1))*'k'),{i,j,k}),[k,j,i],ascending)
        else
            return sort(expand(q),[k,j,i],ascending)
        end if
    catch:
        return eval(q1)
    end try
end proc

 

Now, on the other hand, my approach is somewhat completely different.

I want to define the quaternion multiplication rules first, so

define(M, 'flat', 'multilinear', 'identity' = 1,
M(I,I)=-1, M(J,J)=-1, M(K,K)=-1, M(I,J)=K, M(J,I)=-K, M(J,K)=I, M(K,J)=-I, M(I,K)=-J, M(K,I)=J);

and then somehow extend '*' so that it does what M does when it sees I/J/K.

1 2 3 4 5 Page 4 of 5