W3cubDocs

/Nim

Module complex

This module implements complex numbers.

Imports

math

Types

Complex = tuple[re, im: float]
a complex number, consisting of a real and an imaginary part

Consts

im: Complex = (re: 0.0, im: 1.0)
The imaginary unit. √-1.

Procs

proc toComplex(x: SomeInteger): Complex
Convert some integer x to a complex number.
proc `==`(x, y: Complex): bool {...}{.raises: [], tags: [].}
Compare two complex numbers x and y for equality.
proc `=~`(x, y: Complex): bool {...}{.raises: [], tags: [].}
Compare two complex numbers x and y approximately.
proc `+`(x, y: Complex): Complex {...}{.raises: [], tags: [].}
Add two complex numbers.
proc `+`(x: Complex; y: float): Complex {...}{.raises: [], tags: [].}
Add complex x to float y.
proc `+`(x: float; y: Complex): Complex {...}{.raises: [], tags: [].}
Add float x to complex y.
proc `-`(z: Complex): Complex {...}{.raises: [], tags: [].}
Unary minus for complex numbers.
proc `-`(x, y: Complex): Complex {...}{.raises: [], tags: [].}
Subtract two complex numbers.
proc `-`(x: Complex; y: float): Complex {...}{.raises: [], tags: [].}
Subtracts float y from complex x.
proc `-`(x: float; y: Complex): Complex {...}{.raises: [], tags: [].}
Subtracts complex y from float x.
proc `/`(x, y: Complex): Complex {...}{.raises: [], tags: [].}
Divide x by y.
proc `/`(x: Complex; y: float): Complex {...}{.raises: [], tags: [].}
Divide complex x by float y.
proc `/`(x: float; y: Complex): Complex {...}{.raises: [], tags: [].}
Divide float x by complex y.
proc `*`(x, y: Complex): Complex {...}{.raises: [], tags: [].}
Multiply x with y.
proc `*`(x: float; y: Complex): Complex {...}{.raises: [], tags: [].}
Multiply float x with complex y.
proc `*`(x: Complex; y: float): Complex {...}{.raises: [], tags: [].}
Multiply complex x with float y.
proc `+=`(x: var Complex; y: Complex) {...}{.raises: [], tags: [].}
Add y to x.
proc `+=`(x: var Complex; y: float) {...}{.raises: [], tags: [].}
Add y to the complex number x.
proc `-=`(x: var Complex; y: Complex) {...}{.raises: [], tags: [].}
Subtract y from x.
proc `-=`(x: var Complex; y: float) {...}{.raises: [], tags: [].}
Subtract y from the complex number x.
proc `*=`(x: var Complex; y: Complex) {...}{.raises: [], tags: [].}
Multiply y to x.
proc `*=`(x: var Complex; y: float) {...}{.raises: [], tags: [].}
Multiply y to the complex number x.
proc `/=`(x: var Complex; y: Complex) {...}{.raises: [], tags: [].}
Divide x by y in place.
proc `/=`(x: var Complex; y: float) {...}{.raises: [], tags: [].}
Divide complex x by float y in place.
proc abs(z: Complex): float {...}{.raises: [], tags: [].}
Return the distance from (0,0) to z.
proc conjugate(z: Complex): Complex {...}{.raises: [], tags: [].}
Conjugate of complex number z.
proc sqrt(z: Complex): Complex {...}{.raises: [], tags: [].}
Square root for a complex number z.
proc exp(z: Complex): Complex {...}{.raises: [], tags: [].}
e raised to the power z.
proc ln(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the natural log of z.
proc log10(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the log base 10 of z.
proc log2(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the log base 2 of z.
proc pow(x, y: Complex): Complex {...}{.raises: [], tags: [].}
x raised to the power y.
proc sin(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the sine of z.
proc arcsin(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the inverse sine of z.
proc cos(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the cosine of z.
proc arccos(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the inverse cosine of z.
proc tan(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the tangent of z.
proc arctan(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the inverse tangent of z.
proc cot(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the cotangent of z.
proc arccot(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the inverse cotangent of z.
proc sec(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the secant of z.
proc arcsec(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the inverse secant of z.
proc csc(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the cosecant of z.
proc arccsc(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the inverse cosecant of z.
proc sinh(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the hyperbolic sine of z.
proc arcsinh(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the inverse hyperbolic sine of z.
proc cosh(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the hyperbolic cosine of z.
proc arccosh(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the inverse hyperbolic cosine of z.
proc tanh(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the hyperbolic tangent of z.
proc arctanh(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the inverse hyperbolic tangent of z.
proc sech(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the hyperbolic secant of z.
proc arcsech(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the inverse hyperbolic secant of z.
proc csch(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the hyperbolic cosecant of z.
proc arccsch(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the inverse hyperbolic cosecant of z.
proc coth(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the hyperbolic cotangent of z.
proc arccoth(z: Complex): Complex {...}{.raises: [], tags: [].}
Returns the inverse hyperbolic cotangent of z.
proc phase(z: Complex): float {...}{.raises: [], tags: [].}
Returns the phase of z.
proc polar(z: Complex): tuple[r, phi: float] {...}{.raises: [], tags: [].}
Returns z in polar coordinates.
proc rect(r: float; phi: float): Complex {...}{.raises: [], tags: [].}
Returns the complex number with polar coordinates r and phi.
proc `$`(z: Complex): string {...}{.raises: [], tags: [].}
Returns z's string representation as "(re, im)".

© 2006–2018 Andreas Rumpf
Licensed under the MIT License.
https://nim-lang.org/docs/complex.html