class Complex

A Complex object houses a pair of values, given when the object is created as either rectangular coordinates or polar coordinates.

Rectangular Coordinates

The rectangular coordinates of a complex number are called the real and imaginary parts; see Complex number definition.

You can create a Complex object from rectangular coordinates with:

Note that each of the stored parts may be a an instance one of the classes Complex, Float, Integer, or Rational; they may be retrieved:

The corresponding (computed) polar values may be retrieved:

Polar Coordinates

The polar coordinates of a complex number are called the absolute and argument parts; see Complex polar plane.

In this class, the argument part in expressed radians (not degrees).

You can create a Complex object from polar coordinates with:

Note that each of the stored parts may be a an instance one of the classes Complex, Float, Integer, or Rational; they may be retrieved:

The corresponding (computed) rectangular values may be retrieved:

What’s Here

First, what’s elsewhere:

Here, class Complex has methods for:

Creating Complex Objects

Querying

Comparing

Converting

Performing Complex Arithmetic

Working with JSON

These methods are provided by the JSON gem. To make these methods available:

require 'json/add/complex'