Norm2 of a vector of complex numbers

3.2k Views Asked by At

I am migrating a matlab code into C++ and I need to know how does matlab calculate the norm of below matrix.

For two numbers, A=a+ib , B=c+id, I know I should do [(a-c)^2+(b-d)^2]^1/2. But how is it done for 3 numbers?

    a=[1+1i 2+2i 3+3i]
    norm(a)

    ans = 5.2915
1

There are 1 best solutions below

1
On BEST ANSWER

The (L2) norm of a complex vector $v$ is $\sqrt{\sum_i |v_i|^2}$, where $|x+yi|^2 = x^2 + y^2$. In our case, we get $$ \|a\|^2 = |1+i|^2+|2+2i|^2+|3+3i|^2 = 1^2+1^2+2^2+2^2+3^2+3^2 = 28. $$ You can check that $\sqrt{28}\approx 5.2915$.