Ask Your Question

Revision history [back]

You should use

sage:  sage: Q.<i,j,k> = QuaternionAlgebra(CC,1,1)
sage: i * CC(-1).sqrt()
sage: j * CC(2).sqrt()

The reason it fails with your code is that the function sqrt returns symbolic objects when called with non square integers

sage: s = sqrt(2)
sage: print s ,type(s)
sqrt(2) <type 'sage.symbolic.expression.Expression'>

But the symbolic world has nothing such as generalized quaternions and hence it fails. As you wanted a result in your algebra just avoid symbolic objects.

Note that the following works fine

sage: sqrt(CC(-1))
sage: parent(_)
Complex Field with 53 bits of precision

To be compared with

sage: sqrt(-1)
sage: parent(_)
Symbolic Ring