Complex Numbers CX.

The CX. namespace adds scalar complex arithmetic without changing the Basic expression parser. Complex values live in a dedicated runtime table and are manipulated with explicit commands, which keeps existing scripts stable and avoids ambiguous syntax such as z = 3 + 4i.

Safe pattern: create a value with CX.SET or CX.FROM_POLAR, operate with CX.ADD/CX.MUL/CX.CONJ, then bridge back to normal numeric variables with CX.RE, CX.IM, CX.ABS or CX.ARG.
CX.CLEAR
CX.SET z, 3, 4
CX.CONJ zc, z
CX.MUL power, z, zc
CX.RE p, power
CX.ABS r, z
CX.ARG phi, z
PRINT "power=", p, " radius=", r, " phase=", phi

Page map

Complex number statements 35

CX.ABS

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.ABS result, z

Stores the modulus |z| in a normal numeric variable.

Minimal example

CX.ABS r, z

CX.ADD

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.ADD dst, a, b

Computes dst = a + b for two scalar complex variables.

Minimal example

CX.ADD

CX.ADD_REAL

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.ADD_REAL dst, z, x

Computes dst = z + x where x is a normal real expression.

Minimal example

CX.ADD_REAL

CX.ARG

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.ARG result, z

Stores the phase angle arg(z), in radians, in a normal numeric variable.

Minimal example

CX.ARG phi, z

CX.CLEAR

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.CLEAR

Clears all scalar complex variables stored in the CX runtime table.

Minimal example

CX.CLEAR

CX.CONJ

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.CONJ dst, z

Computes the complex conjugate of z.

Minimal example

CX.CONJ zc, z
CX.MUL power, z, zc

CX.COPY

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.COPY dst, src

Copies a scalar complex variable.

Minimal example

CX.COPY z2, z

CX.COS

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.COS dst, z

Computes the complex cosine.

Minimal example

CX.COS

CX.DELETE

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.DELETE name

Deletes one scalar complex variable if it exists.

Minimal example

CX.DELETE

CX.DIV

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.DIV dst, a, b

Computes dst = a / b for two scalar complex variables. Division by a zero complex value is rejected.

Minimal example

CX.DIV

CX.DIV_REAL

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.DIV_REAL dst, z, x

Computes dst = z / x where x is a normal real expression. Division by zero is rejected.

Minimal example

CX.DIV_REAL

CX.EXISTS

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.EXISTS name, result

Writes 1 to result when the named scalar complex variable exists, otherwise 0.

Minimal example

CX.EXISTS z, ok
ASSERT ok = 1

CX.EXP

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.EXP dst, z

Computes the complex exponential exp(z).

Minimal example

CX.SET ipi, 0, 3.141592653589793
CX.EXP euler, ipi

CX.FROM_POLAR

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.FROM_POLAR dst, radius, angle

Creates a scalar complex variable from polar coordinates. The radius must be non-negative and the angle is in radians.

Minimal example

CX.FROM_POLAR z, 5, 0.927295218

CX.FROM_RE_IM

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.FROM_RE_IM dst, re, im

Creates a scalar complex variable from rectangular coordinates. Alias-friendly companion of CX.SET.

Minimal example

CX.FROM_RE_IM z, 3, 4

CX.IM

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.IM result, z

Stores the imaginary part of z in a normal numeric variable.

Minimal example

CX.IM im, z

CX.INV

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.INV dst, z

Computes dst = 1/z. Division by a zero complex value is rejected.

Minimal example

CX.INV

CX.LIST

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.LIST

Prints all scalar complex variables currently stored in the CX runtime table.

Minimal example

CX.LIST

CX.LOG

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.LOG dst, z

Computes the principal complex logarithm log(z).

Minimal example

CX.LOG

CX.MUL

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.MUL dst, a, b

Computes dst = a * b for two scalar complex variables.

Minimal example

CX.MUL p, z, zc

CX.MUL_REAL

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.MUL_REAL dst, z, x

Computes dst = z * x where x is a normal real expression.

Minimal example

CX.MUL_REAL

CX.NEG

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.NEG dst, z

Computes dst = -z.

Minimal example

CX.NEG

CX.NORM

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.NORM result, z

Stores squared modulus re*re + im*im in a normal numeric variable.

Minimal example

CX.NORM n2, z

CX.POLAR

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.POLAR dst, radius, angle

Alias of CX.FROM_POLAR.

Minimal example

CX.POLAR z, 5, 0.927295218

CX.POW_REAL

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.POW_REAL dst, z, exponent

Raises z to a real-valued exponent. Complex exponents are intentionally not parsed in this first CX layer.

Minimal example

CX.POW_REAL

CX.PRINT

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.PRINT name

Prints a scalar complex variable in readable real/imaginary form.

Minimal example

CX.SET z, 3, 4
CX.PRINT z

CX.RE

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.RE result, z

Stores the real part of z in a normal numeric variable.

Minimal example

CX.RE re, z

CX.SET

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.SET name, re, im

Creates or replaces a scalar complex variable from real and imaginary parts.

Minimal example

CX.SET z, 3, 4
CX.PRINT z

CX.SIN

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.SIN dst, z

Computes the complex sine.

Minimal example

CX.SIN

CX.SQRT

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.SQRT dst, z

Computes the principal complex square root.

Minimal example

CX.SET z, 3, 4
CX.SQRT root, z

CX.SUB

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.SUB dst, a, b

Computes dst = a - b for two scalar complex variables.

Minimal example

CX.SUB

CX.SUB_REAL

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.SUB_REAL dst, z, x

Computes dst = z - x where x is a normal real expression.

Minimal example

CX.SUB_REAL

CX.TAN

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.TAN dst, z

Computes the complex tangent.

Minimal example

CX.TAN

CX.TO_POLAR

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.TO_POLAR z, radiusResult, angleResult

Stores modulus and phase angle, in radians, in two normal numeric variables.

Minimal example

CX.TO_POLAR z, r, phi

CX.TO_RE_IM

STATEMENTCXBATCH-FRIENDLY
Kind: Command   Category: Complex number statements   Namespace: CX

CX.TO_RE_IM z, reResult, imResult

Stores real and imaginary parts of z in two normal numeric variables.

Minimal example

CX.TO_RE_IM z, re, im