1 | initial version |
You should use
sage: sage: Q.<i,j,k> = QuaternionAlgebra(CC,1,1)
sage: i * CC(-1).sqrt()
1.00000000000000*I*i
sage: j * CC(2).sqrt()
1.41421356237310*j
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))
1.00000000000000*I
sage: parent(_)
Complex Field with 53 bits of precision
To be compared with
sage: sqrt(-1)
I
sage: parent(_)
Symbolic Ring