MathLib.Complex()

MathLib provides a large interface for calculations with complex numbers. Complex numbers are implemented as elements of $\hat{\mathbb{C}}$ (this set is basically $\mathbb{C}$ with a point at infinity.) The point at infinity is internally represented as $\infty + \infty i$

Examples

There are several ways to initialise complex numbers:

Methods

For a list of properties and methods common to all complex numbers please see the documentation page for the Complex.prototype.
.polar()
Constructs a complex number out of the absolute value and the argument.
.toContentMathML()
Returns a content MathML string representation of the complex field.
.toLaTeX()
Returns a LaTeX string representation of the complex field.
.toMathML()
Returns a presentation MathML string representation of the complex field.
.toString()
Returns a string representation of the complex field.

Specification

MathLib.Complex accepts two arguments, where the second argument is optional. Any additional arguments will be ignored. The type of both argument should be number.
  1. If either argument is NaN, return {re: NaN, im: NaN}.
  2. If either argument is infinite, return {re: Infinity, im: Infinity}.
  3. If no second argument is provided, set it to +0.
  4. Return {re: firstArgument, im: secondArgument}.