Help Center

CNthRootfunction

Returns the kth nth root of a complex number where k = 0, 1, 2, 3,...,n - 1.

Numeric DatatypesfunctionAfxComplex.incdocumented

Syntax

FUNCTION CNthRoot (BYREF z AS _complex, BYVAL n AS LONG, BYVAL k AS LONG = 0) AS _complex

Description

Returns the kth nth root of a complex number where k = 0, 1, 2, 3,...,n - 1.
De Moivre's formula states that for any complex number x and integer n it holds that
cos(x)+ isin(x))^n = cos(nx) + isin(nx)
where i is the imaginary unit (i2 = -1).
Since z = re^(it) = r * (cos(t) + i sin(t))
where
z = (a, ib)
r = modulus of z
t = argument of z
i = sqrt(-1.0)
we can calculate the nth root of z by the formula:
z^(1/n) = r^(1/n) * (cos(x/n) + i sin(x/n))
by using log division.

Example

DIM z AS _complex = (2.3, -4.5) DIM n AS LONG = 5 FOR i AS LONG = 0 TO n - 1 print CStr(CNthRoot(z, n, i)) NEXT Output: 1.349457704883236 -0.3012830564679053 * i 0.7035425781022545 +1.190308959128094 * i -0.9146444790833151 +1.036934450322577 * i -1.268823953798186 -0.5494482247230521 * i 0.1304681498960107 -1.376512128259714 * i

Reference

  • Include file AfxComplex.inc
  • Defined in AfxNova/AfxComplex.inc:1492
  • Documented in Numeric Datatypes/Complex Numbers Procedures.md
  • Topic: Complex Numbers Procedures