Naming of methods in num::complex

A little question on naming in num::complex.

num::complex calls

  • "norm" what is typically called the modulus or absolute value (i.e. (re^2+im^2).sqrt()) and
  • "norm_sqr" what is typically called the norm (i.e. re^2+im^2).

I found this when comparing fn-names in the documentation to Complex number - Wikipedia.

I agree, "norm" in complex numbers normally means the "field norm", i.e. a²+b². The "euclidean norm" √(a²+b²) is typically called the absolute value, not the "norm".

C++ terminology matches this.

The wikipedia article, from my reading, only says that Gauss called a²+b² the norm, not that it is the general usage of the term. The vector space article mentions the following , which also matches the definition that I was taught in linear algebra in university:

Norms and inner products are denoted | v | and ⟨ v , w ⟩, respectively. The datum of an inner product entails that lengths of vectors can be defined too, by defining the associated norm | v | := √⟨ v , v ⟩.

From my notes:

Let V be a vector space over field K with scalar product ⟨ , ⟩. Then the norm of a vector v ∈ V is defined by ||v|| = √⟨v,v⟩.

The √(a²+b²) calculation matches those definitions.

1 Like

Unfortunately the word "norm" is used in two very different ways in mathematics.

If you treat complex numbers as an inner product space, you would be right. The norm in an inner product space means the square root of the inner product with itself, √⟨v,v⟩.

But complex numbers are not normally talked about as an inner product space. The type Complex in num::complex doesn't even define the inner product operation <u, v>! This would make sense for a Vector2 type where * is typically the inner product operation. But in complex numbers * is a very different operation.

If you treat complex numbers as a field, rather than an inner product space, there is a whole different concept of a "norm", unrelated to a vector space norm. See field norm. It's the determinant of the matrix defining multiplication. For a complex number a+bi the multiplication matrix is [[a, -b], [b, a]], and its determinant is a²+b².

In particular this second "norm" is often used in number theory, where they deal with complex numbers with integer coefficients, aka Gaussian integers. Complex<i32> are Gaussian integers.

The wikipedia article on Gaussian integers says:

The norm of a Gaussian integer is its product with its conjugate.
N(a+bi)=(a+bi)(a−bi)=a2+b2
The norm of a Gaussian integer is thus the square of its absolute value as a complex number.

It would thus make sense to rename the norm fuction to abs, and norm_sqr to norm (or abs_sqr if you wanted to avoid the "norm" terminology altogether).

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.