[HN Gopher] Calculating the norm of a complex number
       ___________________________________________________________________
        
       Calculating the norm of a complex number
        
       Author : mfrw
       Score  : 34 points
       Date   : 2024-10-23 21:30 UTC (1 days ago)
        
 (HTM) web link (eli.thegreenplace.net)
 (TXT) w3m dump (eli.thegreenplace.net)
        
       | andrewla wrote:
       | The trouble is that complex conjugation is not holomorphic
       | (analytic) over the complex numbers.
       | 
       | It's incredibly useful as an operator, and it appears all over
       | the place in Hilbert spaces and other complex-probability
       | situations, but fundamentally it defies attempts to use it for
       | analytic purposes (like differential equations or contour
       | integration).
       | 
       | Useful when you need to treat the complex plane as a vector space
       | or are interested in the topology of a complex function, but a
       | pain to deal with in almost any other context.
        
         | rachofsunshine wrote:
         | For those of you wondering why on Earth such a simple function
         | wouldn't be well-behaved, it can help to think about what you
         | can do with the conjugate.
         | 
         | In particular, since sums of holomorphic functions are
         | holomorphic, the sum f(z) = z + z* of the identity function
         | g(z) = z and conjugate function h(z) = z* would need to be
         | holomorphic. But z + z* cancels out the imaginary part of z and
         | therefore maps the complex plane to the real line - and it
         | should be obvious that a map from C to R cannot possibly
         | preserve the properties of C in any intuitive way.
         | 
         | Roughly speaking, the conjugate fails to be holomorphic because
         | it maps C to its mirror image, rather than C itself, in much
         | the same way that reflecting a circle is different from
         | rotating it.
        
           | bobbylarrybobby wrote:
           | Constant functions are holomorphic without preserving the
           | properties of C
           | 
           | The issue is that the Cauchy Riemann equations don't hold.
           | (You would need 1==-1)
        
             | rachofsunshine wrote:
             | Picard's theorem tells us constant functions are the only
             | example of that, though (more or less because 0 == -0 [1]
             | and that's only true _for_ 0).
             | 
             | [1] I sincerely apologize to anyone who works with floats
             | for this statement.
        
         | Tainnor wrote:
         | > The trouble is that complex conjugation is not holomorphic
         | (analytic) over the complex numbers.
         | 
         | Even more generally, a real-differentiable function is complex
         | differentiable iff its (Wirtinger) derivative with respect to
         | z* is 0.
        
         | kevinventullo wrote:
         | Maybe worth noting that it is _real-analytic_.
        
         | aabajian wrote:
         | Does the problem boil down to selecting the real part of a
         | complex number? Correct me if I'm wrong, but the conjugate of z
         | is merely 2*Re(z) - z. For example, the conjugate of a + bi is
         | 2*a - (a + bi) = a - bi.
        
       | Adrock wrote:
       | A simple demonstration of why this is necessary is to consider
       | the distance between the points 1 and i on the complex plane. If
       | you naively compute the distance between them using the familiar
       | Euclidean formula [?](a2+b2) you get:
       | 
       | [?](12+i2) = [?](1-1) = 0
       | 
       | That can't be right...
        
         | kgwgk wrote:
         | Even simpler is trying to calculate |i| (i.e. the distance
         | between the points 0 and i on the complex plane) as [?]i2 =
         | [?]-1 = i.
        
         | nokan wrote:
         | you are calculating inner product of otrhogonal vectors. For
         | distance it should be abs(a-b) it will result to sqrt(2).
        
       | kgwgk wrote:
       | > Why z squared is not a norm-square Now it's time to go back to
       | the question we started the post with. Why isn't zz (or z^2) the
       | norm-square? [several paragraphs later]. Looking at the formal
       | definition of the norm, it's clear right away that won't do. The
       | norm is defined as a real-valued function, whereas zz is not
       | real-valued.
       | 
       | That much is clear much righter away just by noticing that for
       | the simplest imaginary number imaginable (z=i) zz is negative but
       | the norm-squared is positive-valued.
        
       | rdtsc wrote:
       | You can try it out in Python directly which natively support
       | complex numbers (just use j instead of i):                  >>>
       | import math        >>> z=1+2j        >>> z*complex.conjugate(z)
       | (5+0j)        >>> math.sqrt((z*complex.conjugate(z)).real)
       | 2.23606797749979        >>> abs(z)        2.23606797749979
       | 
       | As we can see abs(z) does the right thing. Try it with a negative
       | imaginary part too and "nicer" values:                  >> z =
       | 3-4j        >>> math.sqrt((z*complex.conjugate(z)).real)
       | 5.0        >>> abs(z)        5.0
        
         | jcgrillo wrote:
         | This is what made me fall in love with python. It's over now,
         | but it was nice while it lasted.
        
         | hpcjoe wrote:
         | Same in Julia, but no need to "import math", its already built
         | in :D                   joe@zap:~ $ julia
         | _            _       _ _(_)_     |  Documentation:
         | https://docs.julialang.org               (_)     | (_) (_)    |
         | _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
         | | | | | | | |/ _` |  |           | | |_| | | | (_| |  |
         | Version 1.10.5 (2024-08-27)          _/ |\__'_|_|_|\__'_|  |
         | |__/                   |              julia> z=1+2*im         1
         | + 2im              julia> z*conj(z)         5 + 0im
         | julia> sqrt(z*conj(z))         2.23606797749979 + 0.0im
         | julia> abs(z)         2.23606797749979
        
       | Tainnor wrote:
       | I don't understand the starting point of this blog post. Why
       | should one intuitively think that |z|^2 = zz? I've never seen
       | anyone been confused by this. It's like writing an article about
       | why 2*3 can't be 5 or something.
        
         | mikewarot wrote:
         | Because it happens to work when Z has no imaginary component.
        
         | griffzhowl wrote:
         | > Why should one intuitively think that |z|^2 = zz?
         | 
         | I guess because it's true for the reals. But yeah, I agree
         | anyone who has got 10 minutes into an explanation of complex
         | arithmetic should have got that far... I guess it's directed at
         | people not acquainted with complex numbers much at all
        
       | billti wrote:
       | Multiplying any two complex numbers 'a' and 'b' gives you a
       | complex number z whose magnitude is the magnitude of 'a' times
       | the magnitude of 'b' (that's covered in the article). I always
       | thing of a 'complex conjugate' as a reflection across the real
       | number line (i.e. has the opposite angle or 'phase'), so when a
       | complex number and its conjugate are multiplied the angle
       | disappears and you're left with no imaginary component, thus just
       | the real part which IS the magnitude. (As a^2 + 0 = c^2)
       | 
       | I hadn't worked with complex numbers much for most of my life,
       | but getting into quantum computing recently it is ALL complex
       | numbers (and linear algebra). It's fascinating (for a certain
       | mindset at least, which I guess I fall into), but it is a lot of
       | mental work and repetition before it starts to feel in any way
       | 'comfortable'.
        
       | mikewarot wrote:
       | I wondered what happens when you try to do this in more than 2
       | dimensions? It turns out that you can just extend the negation of
       | the imaginary part before proceeding.
       | 
       | https://math.libretexts.org/Bookshelves/Abstract_and_Geometr....
        
       | siktirlanibne wrote:
       | zz* !? Why not z*z if you're nitpicking already? inb4 WFH killed
       | Commutators.
        
       ___________________________________________________________________
       (page generated 2024-10-24 23:00 UTC)