Re: Quaternion problem
- To: mathgroup at smc.vnet.net
- Subject: [mg67463] Re: Quaternion problem
- From: Roger Bagula <rlbagula at sbcglobal.net>
- Date: Mon, 26 Jun 2006 00:13:15 -0400 (EDT)
- References: <e7ap5q$952$1@smc.vnet.net> <e7lf1d$3l9$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Roger Bagula wrote: >Staffan Langin wrote: > > > >>Hello, >> >>I'm a total Mathematica newbee so please bear with me :-). I'm trying to let >>Mathematica analytically evaluate a second order derivative for me. The >>function has several parameters with some of them being of >>"Quaternion-type". I want to instruct Mathematica that the commutative rule >>doesn't apply when evaluation the function. Is that possible? Thanks in >>advance. >> >>Staffan Langin >> >> >> >> >> > > > > I did a simple unitary quaternion differentiation using matrix quaternions and tested the result: ( not a partial differentiation) << Algebra`Quaternions` i = {{0, 1}, {-1, 0}}; j = {{0, I}, {I, 0}}; k = {{I, 0}, {0, -I}}; e = IdentityMatrix[2]; q[t_, x_, y_, z_] := e*t + x*i + j*y + k*z; q[-1/2, 1/2, 1/2, 1/2].q[-1/2, -1/2, -1/2, -1/2] qM[a_, b_, c_, d_] := Quaternion[Re[q[a, b, c, d][[1, 1]]], Re[ q[a, b, c, d][[1, 2]]], Re[q[a, b, c, d][[1, 2]]], Im[q[a, b, c, d][[1, 1]]]] qM[-1/2, 1/2, 1/2, 1/2] ** qM[-1/2, -1/2, -1/2, -1/2] (* Rodrigues unitary quaternion*) qr = q[Cos[r], Sin[r]*Sin[p]*Cos[t], Sin[r]*Sin[p]*Sin[t], Sin[r]*Cos[p]] qrs = q[Cos[r], -Sin[r]*Sin[p]*Cos[t], -Sin[r]*Sin[p]*Sin[t], -Sin[r]*Cos[p]] FullSimplify[ExpandAll[q[Cos[r], Sin[r]*Sin[p]*Cos[t], Sin[r]*Sin[p]*Sin[t], Sin[r]*Cos[p]].q[Cos[r], -Sin[r]*Sin[p]*Cos[t], - Sin[r]*Sin[p]*Sin[t], -Sin[r]*Cos[p]]]] dqrs = D[qrs, {r, 2}] FullSimplify[ExpandAll[ dqr.dqrs]] q2_out = Quaternion[Re[dqr[[1, 1]]], Re[dqr[[1, 2]]], Re[dqr[[1, 2]]], Im[dqr[[1, 1]]]] (* if the angles are all real*) Quaternion[-Cos[r], -Cos[t] Sin[p] Sin[r], -Cos[t] Sin[p] Sin[r], -Cos[p] Sin[r]] (* test*) -dqr == qr True