Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong quaternion norm implementation #22

Closed
Sujo1 opened this issue Mar 10, 2016 · 4 comments
Closed

Wrong quaternion norm implementation #22

Sujo1 opened this issue Mar 10, 2016 · 4 comments

Comments

@Sujo1
Copy link

Sujo1 commented Mar 10, 2016

The quaternion norm implementation actually gives the square of the quaternion norm as can be seen from the following simple code:

import numpy as np
import quaternion

qv = np.array([1,2,3,4], dtype = np.float64)
q = np.quaternion(1,2,3,4)

print(np.linalg.norm(qv), q.norm(), np.sqrt(q.norm()))

which results in:

5.47722557505 30.0 5.47722557505
@moble
Copy link
Owner

moble commented Mar 10, 2016

It's not wrong; it's just the choice I made. I made that choice for consistency with another package I was using at the time. I agree that including the square-root is more common, but some sources do give the norm as simply the sum of the squares. You might also be interested in the abs method, which does take the square-root.

@moble moble closed this as completed Mar 10, 2016
@moble
Copy link
Owner

moble commented Mar 5, 2018

For the record: I just realized that this choice for the definitions of abs and norm agrees with the same functions in the boost::math::quaternion implementation, as well as the official C++ standard for complex numbers.

@tazr
Copy link

tazr commented Sep 28, 2018

Very confusing indeed. Why call "norm" something that is not a norm? Renaming it to something like ceyley_seminorm would be an improvement in my opinion

@moble
Copy link
Owner

moble commented Sep 28, 2018

Renaming it to something like ceyley_seminorm would be an improvement in my opinion

Well, first of all, that would involve misspelling "Cayley". Second, this is not a seminorm as distinct from a norm because it does not send any nonzero quaternion to zero; referring to it as a seminorm would suggest otherwise.

Why call "norm" something that is not a norm?

Well, there are several reasons. First, it actually is a norm — but there are different conventions for what precisely "norm" refers to [see my comments above, or the very wikipedia article that you linked to]. In particular, the wikipedia article you link to defines a norm for a vector space and while quaternions do form a vector space, they also do more than that: they form an algebra. And specifically in the context of algebras, it is more common to use the word "norm" in reference to the squared version.

Second, this is the choice consistent with the Boost implementation of quaternions, as well as python/numpy's implementation of complex numbers, plus the C++ standard for complex numbers [see my comments above, again].

Third, because I don't code for the lowest common denominator, tazr; you should probably learn to read, code for yourself, or stop complaining.

Repository owner locked as resolved and limited conversation to collaborators Sep 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants