Complex number arithmetic with rectangular and polar forms.
Literal syntax: a+bi, a-bi (e.g. 3+4i, 0+1i, 2-3i)
Extends arithmetic operators (+, -, *, /, =) with complex promotion.
make-complexcx-imag-fraccx-imag-dotcx-imag-intcx-signcx-real-fraccx-real-dotcx-negcx-real-intcx-addcx-subcx-mulcx-divcx-eqensure-complexcomplex-typenumber?Test whether a value is any numeric type (integer, rational, float, or complex).
Parameters:
ANY — Value to testReturns: BOOL — True if x is a number
Examples:
(number? 3+4i) => #tcomplex?Test whether a value is any numeric type (alias for number?).
Parameters:
ANY — Value to testReturns: BOOL — True if x is a number
Examples:
(list (complex? 3+4i) (complex? 'a)) => (#t #f)real?Test whether a value is a real number (integer, rational, or float, but not complex).
Parameters:
ANY — Value to testReturns: BOOL — True if x is a real number
Examples:
(list (real? 1.5) (real? 3+4i)) => (#t #f)Complex(Complex type)The complex type handle, for Convert and Type.
Returns: ATOM — The COMPLEX type handle
(Complex complex? x)Test whether a value is any numeric type (alias for number?).
Parameters:
ANY — Value to testReturns: BOOL — True if x is a number
Examples:
(Complex complex? 2i) => #t(Complex make re im)Construct a complex number from rectangular coordinates.
Parameters:
NUMBER — Real partNUMBER — Imaginary partReturns: COMPLEX|NUMBER — Complex number, or real if imaginary part is zero
Examples:
(Complex make 3 4) => 3+4i
(Complex make 3 0) => 3(Complex from-polar mag ang)Construct a complex number from polar coordinates (magnitude and angle).
Parameters:
NUMBER — MagnitudeNUMBER — Angle in radiansReturns: COMPLEX|NUMBER — Complex number from polar coordinates
Examples:
(Complex from-polar 2 0) => 2.0+0.0i(Complex real-part z)Return the real part of a complex number, or the number itself for reals.
Parameters:
COMPLEX|NUMBER — Complex or real numberReturns: NUMBER — Real part
Examples:
(Complex real-part 3+4i) => 3(Complex imag-part z)Return the imaginary part of a complex number, or 0 for reals.
Parameters:
COMPLEX|NUMBER — Complex or real numberReturns: NUMBER — Imaginary part
Examples:
(Complex imag-part 3+4i) => 4
(Complex imag-part 7) => 0(Complex magnitude z)Return the magnitude (absolute value) of a complex or real number.
Parameters:
COMPLEX|NUMBER — Complex or real numberReturns: FLOAT — Absolute value (distance from origin)
Examples:
(Complex magnitude 3+4i) => 5.0(Complex angle z)Return the angle (argument) of a complex number in radians.
Parameters:
COMPLEX|NUMBER — Complex or real numberReturns: FLOAT — Angle in radians
Examples:
(Complex angle 0+1i) => 1.5707963267949(Complex + a b)Add two complex numbers (reals promote).
Parameters:
COMPLEX|NUMBER — First operandCOMPLEX|NUMBER — Second operandReturns: COMPLEX|NUMBER — Sum, collapsed to real if imaginary part is zero
Examples:
(Complex + 1+2i 3-1i) => 4+1i(Complex - a b)Subtract two complex numbers (reals promote).
Parameters:
COMPLEX|NUMBER — First operandCOMPLEX|NUMBER — Second operandReturns: COMPLEX|NUMBER — Difference, collapsed to real if imaginary part is zero
Examples:
(Complex - 3+4i 3) => 0+4i(Complex * a b)Multiply two complex numbers (reals promote).
Parameters:
COMPLEX|NUMBER — First operandCOMPLEX|NUMBER — Second operandReturns: COMPLEX|NUMBER — Product, collapsed to real if imaginary part is zero
Examples:
(Complex * 2i 2i) => -4(Complex / a b)Divide two complex numbers (reals promote).
Parameters:
COMPLEX|NUMBER — DividendCOMPLEX|NUMBER — DivisorReturns: COMPLEX|NUMBER — Quotient, collapsed to real if imaginary part is zero
Examples:
(Complex / 4+2i 2) => 2+1i(Complex = a b)Test whether two complex numbers are equal (reals promote).
Parameters:
COMPLEX|NUMBER — Left operandCOMPLEX|NUMBER — Right operandReturns: BOOL — True if both real and imaginary parts are equal
Examples:
(Complex = 2 2+0i) => #t