addaptic

Reference Complex arithmetic

lzc_polar

A complex number from its modulus and its angle, r cos θ + i r sin θ.

long lzc_polar( CLZNumber* modulus, CLZNumber* angle, CLZComplex* targetNumber );

r cos θ + i r sin θ, the angle read in the thread's unit. Each part correctly rounded, half-even, and exact where the mathematics is: at whole quarter turns the parts are r, −r and an exact nought, so 1 at 180° is exactly −1 + 0i.

A negative modulus is taken as it is. The answer is in the modulus's base, an angle in another base brought into it. The target is required, and a missing operand is refused, kFailed. A not-a-number in either, or an infinite angle, answers a not-a-number, and an infinite modulus at a finite angle the point at infinity.

Examples

CallAnswer
lzc_polar( 1, 180 ) degrees−1 + 0i
lzc_polar( 2, 30 ) degrees1.732050807568877293527446341505872367 + 1i
lzc_polar( 1, 1 )0.540302305868139717400936607442976604 + 0.841470984807896506652502321630299000i

Each answer is what Addaptic printed for the call, in radians, at 36 places unless a setting is shown.

Returns

kNoError (0) when the answer is written. Otherwise an error code, with the answer flagged infinite or not-a-number; see Errors and flags.

See also

  • lzc_abs The modulus of a complex number, |z|, a real answer.
  • lzc_arg The argument of a complex number, its angle, a real answer in the thread's angle unit.
  • lz_sine_cosine The sine and the cosine of one angle together, for about half the cost of the two.