Talk:Essays/Complex Operations

From J Wiki
Jump to navigation Jump to search

Exponential form

It's perhaps worth further emphasizing that trig functions of real number values can be expressed as exponential functions of complex numbers. The page currently contains numerous illustrations of this but without expressing trig functions in that fashion.

For example:

  j=: %:_1  NB. 0j1
  J=: *&j@+  NB. swap real and imaginary components of complex number
  mean=: +/%#
  re=: mean@(, +)  NB. real part of complex number
  im=: re@J  NB. imaginary part of complex number
  cos=: re@^@J NB. 2 o.
  sin=: im@^@J NB. 1 o.
  atan2=: im@^.@(+ J) NB. arc tangent y%x with correct quadrants

(Atan2 would also be {:@*.@j. without using exponentials.)