-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Labels
Description
I think there is a bug in Base.log(q::Quaternion) if q is a negative real.
For example:
julia> q = quat(-1.0)
QuaternionF64(-1.0, 0.0, 0.0, 0.0, true)
julia> exp(log(q)) == q
falsenote that this is not due to floating point (im-)precision:
julia> exp(log(q))
QuaternionF64(1.0, 0.0, 0.0, 0.0, true)
julia> log(q)
QuaternionF64(0.0, 0.0, 0.0, 0.0, false)Related answer on math.stackexchange: https://math.stackexchange.com/a/3750503
Note in particular:
For negative reals, the imaginary component of the branches has the form (2n+1)πu^. Thus (log(k),0,0,0) is not a valid value of log(k,0,0,0).
I think a fix would be to choose the branch of the logarithm that corresponds to the logarithm on complex numbers, again quoting above math.stackexchange answer:
But, for example, if you choose u^=(1,0,0) then you get log(−2,0,0,0)=(log(|−2|),(2n+1)π,0,0). This is exactly the logarithm on C.