Class

# Complex

Inheritance
< Numeric < Object

The complex number class. See complex.rb for an overview.

## Constants

Name   Description
I = Complex(0,1) I is the imaginary number. It exists at point (0,1) on the complex plane.
Unify = true

## Attributes

Name Visibility R/W Description
image public R The imaginary part of a complex number.
real public R The real part of a complex number.

## Aliases

Method Alias Description
image → imag

## Methods

### Class

Visibility Signature
public new (a, b)
public new! (a, b=0)
public polar (r, theta)

### Instance

Visibility Signature
public % (other)
public * (other)
public ** (other)
public + (other)
public - (other)
public / (other)
public <=> (other)
public == (other)
public abs ()
public abs2 ()
public angle ()
public arg ()
public coerce (other)
public conj ()
public conjugate ()
public denominator ()
public hash ()
public inspect ()
public numerator ()
public polar ()
public quo (other)
public to_s ()

## Class Method Detail

#### new!(a, b=0)

Creates a Complex number a+bi.

#### polar(r, theta)

Creates a Complex number in terms of r (radius) and theta (angle).

## Instance Method Detail

#### %(other)

Remainder after division by a real or complex number.

#### *(other)

Multiplication with real or complex number.

#### **(other)

Raise this complex number to the given (real or complex) power.

#### +(other)

Addition with real or complex number.

#### -(other)

Subtraction with real or complex number.

#### /(other)

Division by real or complex number.

#### <=>(other)

Compares the absolute values of the two numbers.

#### ==(other)

Test for numerical equality (a == a + 0i).

#### abs()

Absolute value (aka modulus): distance from the zero point on the complex plane.

#### abs2()

Square of the absolute value.

Alias for arg

#### arg()

Argument (angle from (1,0) on the complex plane).

#### coerce(other)

Attempts to coerce other to a Complex number.

#### conj()

Alias for conjugate

#### conjugate()

Complex conjugate (z + z.conjugate = 2 * z.real).

FIXME

#### hash()

Returns a hash code for the complex number.

#### inspect()

Returns "Complex(real, image)".

FIXME

#### polar()

Returns the absolute value and the argument.

#### to_s()

Standard string representation of the complex number.