|
|
|
|
|
by srean
1 day ago
|
|
META: Pulling this out of its original context because I think more readers would find the code amusing. I am breaking the rules, but hopefully for a good/pardonable reason. > Most of the time we think of complex numbers as vectors in R2 or as rotation+scaling operators, but rarely do we actually we want them in both roles at the same time. I can give one counterexample. I was asked to comment on a piece of code that did 2D geometry in Python. There was one piece that was a tangle of trigonometry to find the angular bisector of an angle subtended at the origin by two points. Using the fact that points can be represented by complex numbers and that rotation is just multiplication one can make that function into a one liner. √(z1 * z2)
The geometric mean of the two points as represented by complex numbers gives you the bisector. Python has native support for complex numbers so all the computation is handled by the runtime. |
|
The exact same thing is happening here, only multiplicatively, where z1^(1/2) * z2^(1/2) is a combination with two weights of 1/2 (thus, summing to 1). It is geometrically meaningful to treat 2d vectors (displacements in a plane) as complex numbers, raise them to exponents summing to 1, and then multiply these together to get another vector in the same plane. But it is not generally geometrically meaningful to just multiply one vector by another vector to get a third vector in the same space (because this would require distinguishing some particular direction and magnitude as "1").