functions
Module-level functions and constants for `nustd.cmath`.
Module nustd.cmath.functions.
Module-level functions and constants for nustd.cmath.
cmath is a function module - free functions over complex numbers plus a few
constants - so this is the function half of the surface: typed wrappers that
mirror cmath.sqrt / cmath.phase / cmath.polar 1-1, plus the module
constants. Each wrapper builds its interaction atom (lazily imported, like
nustd.math) and returns the Form that matches the host return type:
- most functions ->
complex(the Form for the builtin) phase->Floatpolar->Tuple(the(r, phi)pair)isnan/isinf/isfinite/isclose->Boolrect(r, phi)->complex
Constants are plain values, so they ride on Literal instead of an atom.
pi / e / tau / inf / nan are floats; infj / nanj are
complex, so they are wrapped in the complex Form.
| Name | Call | Meaning |
|---|---|---|
| acos | cmath.acos(x) | The arc cosine of x: mirrors cmath.acos(). |
| asin | cmath.asin(x) | The arc sine of x: mirrors cmath.asin(). |
| atan | cmath.atan(x) | The arc tangent of x: mirrors cmath.atan(). |
| cos | cmath.cos(x) | The cosine of x: mirrors cmath.cos(). |
| cosh | cmath.cosh(x) | The hyperbolic cosine of x: mirrors cmath.cosh(). |
| exp | cmath.exp(x) | e raised to x: mirrors cmath.exp(). |
| isclose | cmath.isclose(a, b) | Whether a and b are close: mirrors cmath.isclose(). |
| isfinite | cmath.isfinite(x) | Whether both components of x are finite: mirrors cmath.isfinite(). |
| isinf | cmath.isinf(x) | Whether x has an infinite component: mirrors cmath.isinf(). |
| isnan | cmath.isnan(x) | Whether x has a NaN component: mirrors cmath.isnan(). |
| log | cmath.log(x, base=None) | The logarithm of x (natural, or to base): mirrors cmath.log(). |
| log10 | cmath.log10(x) | The base-10 logarithm of x: mirrors cmath.log10(). |
| phase | cmath.phase(x) | The phase angle of x, in radians: mirrors cmath.phase(). |
| polar | cmath.polar(x) | x as the polar pair (r, phi): mirrors cmath.polar(). |
| rect | cmath.rect(r, phi) | The complex number with modulus r and phase phi: mirrors cmath.rect(). |
| sin | cmath.sin(x) | The sine of x: mirrors cmath.sin(). |
| sinh | cmath.sinh(x) | The hyperbolic sine of x: mirrors cmath.sinh(). |
| sqrt | cmath.sqrt(x) | The square root of x: mirrors cmath.sqrt(). |
| tan | cmath.tan(x) | The tangent of x: mirrors cmath.tan(). |
| tanh | cmath.tanh(x) | The hyperbolic tangent of x: mirrors cmath.tanh(). |
acos
The arc cosine of x: mirrors cmath.acos().
cmath.acos(x)Path nustd.cmath.acos. Defined on nustd.cmath.functions, bound as a function. Builds complex.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg |
Undocumented: example.
asin
The arc sine of x: mirrors cmath.asin().
cmath.asin(x)Path nustd.cmath.asin. Defined on nustd.cmath.functions, bound as a function. Builds complex.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg |
Undocumented: example.
atan
The arc tangent of x: mirrors cmath.atan().
cmath.atan(x)Path nustd.cmath.atan. Defined on nustd.cmath.functions, bound as a function. Builds complex.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg |
Undocumented: example.
cos
The cosine of x: mirrors cmath.cos().
cmath.cos(x)Path nustd.cmath.cos. Defined on nustd.cmath.functions, bound as a function. Builds complex.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg |
Undocumented: example.
cosh
The hyperbolic cosine of x: mirrors cmath.cosh().
cmath.cosh(x)Path nustd.cmath.cosh. Defined on nustd.cmath.functions, bound as a function. Builds complex.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg |
Undocumented: example.
exp
e raised to x: mirrors cmath.exp().
cmath.exp(x)Path nustd.cmath.exp. Defined on nustd.cmath.functions, bound as a function. Builds complex.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg |
Undocumented: example.
isclose
Whether a and b are close: mirrors cmath.isclose().
cmath.isclose(a, b)Path nustd.cmath.isclose. Defined on nustd.cmath.functions, bound as a function. Builds Bool.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
a | ComplexArg | ||
b | ComplexArg |
Undocumented: example.
isfinite
Whether both components of x are finite: mirrors cmath.isfinite().
cmath.isfinite(x)Path nustd.cmath.isfinite. Defined on nustd.cmath.functions, bound as a function. Builds Bool.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg |
Undocumented: example.
isinf
Whether x has an infinite component: mirrors cmath.isinf().
cmath.isinf(x)Path nustd.cmath.isinf. Defined on nustd.cmath.functions, bound as a function. Builds Bool.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg |
Undocumented: example.
isnan
Whether x has a NaN component: mirrors cmath.isnan().
cmath.isnan(x)Path nustd.cmath.isnan. Defined on nustd.cmath.functions, bound as a function. Builds Bool.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg |
Undocumented: example.
log
The logarithm of x (natural, or to base): mirrors cmath.log().
cmath.log(x, base=None)Path nustd.cmath.log. Defined on nustd.cmath.functions, bound as a function. Builds complex.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg | ||
base | ComplexArg | None | None |
Undocumented: example.
log10
The base-10 logarithm of x: mirrors cmath.log10().
cmath.log10(x)Path nustd.cmath.log10. Defined on nustd.cmath.functions, bound as a function. Builds complex.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg |
Undocumented: example.
phase
The phase angle of x, in radians: mirrors cmath.phase().
cmath.phase(x)Path nustd.cmath.phase. Defined on nustd.cmath.functions, bound as a function. Builds Float.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg |
Undocumented: example.
polar
x as the polar pair (r, phi): mirrors cmath.polar().
cmath.polar(x)Path nustd.cmath.polar. Defined on nustd.cmath.functions, bound as a function. Builds Tuple.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg |
Undocumented: example.
rect
The complex number with modulus r and phase phi: mirrors cmath.rect().
cmath.rect(r, phi)Path nustd.cmath.rect. Defined on nustd.cmath.functions, bound as a function. Builds complex.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
r | FloatArg | ||
phi | FloatArg |
Undocumented: example.
sin
The sine of x: mirrors cmath.sin().
cmath.sin(x)Path nustd.cmath.sin. Defined on nustd.cmath.functions, bound as a function. Builds complex.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg |
Undocumented: example.
sinh
The hyperbolic sine of x: mirrors cmath.sinh().
cmath.sinh(x)Path nustd.cmath.sinh. Defined on nustd.cmath.functions, bound as a function. Builds complex.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg |
Undocumented: example.
sqrt
The square root of x: mirrors cmath.sqrt().
cmath.sqrt(x)Path nustd.cmath.sqrt. Defined on nustd.cmath.functions, bound as a function. Builds complex.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg |
Undocumented: example.
tan
The tangent of x: mirrors cmath.tan().
cmath.tan(x)Path nustd.cmath.tan. Defined on nustd.cmath.functions, bound as a function. Builds complex.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg |
Undocumented: example.
tanh
The hyperbolic tangent of x: mirrors cmath.tanh().
cmath.tanh(x)Path nustd.cmath.tanh. Defined on nustd.cmath.functions, bound as a function. Builds complex.
Arguments
| Name | Type | Default | Meaning |
|---|---|---|---|
x | ComplexArg |
Undocumented: example.