Ask Your Question

How to do symbolic computation with quaternions

asked 2013-01-22 03:37:05 +0200

Gilles Falquet gravatar image

I need to do symbolic computations with quaternions. Ideally I'd like to enter something like

Q.<i,j,k> = QuaternionAlgebra(QQ,-1,-1)
q = a*i+b*j+c*k

But it doesn't work : TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and 'Quaternion Algebra (-1, -1) with base ring Rational Field'

Looks like SAGE doesn't know how to multiply a variable and a quaternion. Or should I specify the types of the variables ? How ?

Thanks for your help.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-01-22 14:00:21 +0200

benjaminfjones gravatar image

You should define Q as a QuaternionAlgebra over the symbolic ring SR instead of over the rationals:

sage: Q.<i,j,k> = QuaternionAlgebra(SR, -1, -1)
sage: q = a*i + b*j + c*k
sage: q
a*i + b*j + c*k
sage: q^2
-a^2 - b^2 - c^2
edit flag offensive delete link more

answered 2015-07-31 03:24:24 +0200

uutzinger gravatar image

updated 2015-07-31 03:24:53 +0200

N.<c,d,a1,a2,a3,a4,b1,b2,b3,b4,s> = QQ[]
H.<i,j,k> = QuaternionAlgebra(c,d)
a = a1 + a2 * i + a3 * j + a4 * k
b = b1 + b2 * i + b3 * j + b4 * k


Seems to give better results

Now I just need to figure out how to define vector and rotate it with quaternion.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-01-22 03:37:05 +0200

Seen: 2,280 times

Last updated: Jul 31 '15