
Walking Paths with Complex Numbers - dannybirch
https://dannythecoder.wordpress.com/2016/12/02/walking-paths-with-complex-numbers/
======
ajkjk
Erg. It's true that complex numbers model a rotation operator in 2d geometry.
But I think it's harmful to say that it's better to think about 2d geometry in
terms of complex numbers rather than, well, 2d geometry (vectors and rotation
operators/matrices/geometric algebras). This kind of thinking doesn't extend
to higher dimensions, obfuscates the actual discovery under the 'magic' of
complex numbers, and requires knowing 'one weird trick' to figure out
yourself.

(edit: added reference to geometric algebras, which are cleaner than rotation
matrices for intuitively modeling this.)

~~~
andars
I'd say if it depends on how you think about complex numbers. If your
understanding of the imaginary unit is limited to "that thing that when you
square it you get -1", I agree with you. But if you think of the imaginary
unit as the 2-blade in the geometric algebra of R^2, I would argue it is one
of the best ways to think about 2D geometry.

~~~
ajkjk
My point is that almost no one thinks about it that way, and that's the
problem. People are content using complex numbers and saying 'it magically'
works instead of dealing with the actual structure they want to be using.

~~~
andars
In that case, I agree with you wholeheartedly.

------
posterboy
I still don't get the significance of complex numbers, to me they seem like
vectors with certain operations and I still suppose there is no deeper
revelation, that _sqrt(-1)_ represents, and every example could have a
geometric interpretation, even if this isn't motivated by the example.
Likewise, the only explanation for e^(pi*i)-1=0 I know is the conversion to
polar coordinates.

>Since you need to keep track of your current orientation this slightly
complicates things a bit

>If at each step we keep the imaginary multiplication term from the previous
step we can effectively encode the rotation in our expression

Why, you could just keep track of the rotation as an angle, which would
likewise be a result of the previous step. In binary there wouldn't even be
much of a difference: Look at a 2-bit value either as a modulo 4 ring of type
pi/2, or as a modulo 2 vector of the two complex components. That's my first
thought, at least. Although, the real and imaginary parts would always have
opposite values, so only one bit is needed. I wonder if complexity analysis
would show a difference.

~~~
ThrustVectoring
The best non-geometric interpretation of complex numbers is algebraic closure,
IMO. Basically, mathematicians invent new kinds of numbers when they want to
do things and have the result of the operation always be a number. Adding and
multiplying natural numbers gets you a natural number. Subtraction on integers
yields integers. Division for rational numbers. Infinite series for real
numbers. And factoring all polynomials is the raison d'etre for complex
numbers.

------
jstewartmobile
Good stuff! Even though this may not be the best application for complex
numbers, it is a very simple example for a practical use. For some person out
there, this may even serve as a "gateway drug" to complex analysis.

------
rosstex
[https://acko.net/blog/how-to-fold-a-julia-
fractal/](https://acko.net/blog/how-to-fold-a-julia-fractal/)

------
deckar01
Here is the pseudo-code for matrix rotation for comparison:

    
    
      def rotate(vector, angle):
        rotation_matrix = [
          [cos(angle), -sin(angle)],
          [sin(angle), cos(angle)]
        ]
        return rotation_matrix * vector
      
      position = (0, 0)
      velocity = (0, 1)
      for instruction in [x.strip() for x in input.split(",")]:
        direction = instruction[0]
        distance = int(instruction[1:])
        angle = 90 if direction == 'L' else -90
        velocity = rotate(velocity, angle)
        position += velocity * distance
      print position

~~~
andars
Since you only work with 90 degrees, you don't even need the full machinery.
In my solution I used (a,b) -> (-b,a) and its dual.

