## `Dom::Complex` -- the field of complex numbers

#### Introduction

`Dom::Complex` is the field of complex numbers represented by elements of the domains `DOM_INT`, `DOM_RAT`, `DOM_FLOAT`, `DOM_COMPLEX` and `DOM_EXPR`.

#### Creating Elements

`Dom::Complex(x)`

#### Parameters

`x` | - | An expression of type `DOM_INT`, `DOM_RAT`, `DOM_FLOAT`, `DOM_COMPLEX`. An expression of type `DOM_EXPR` is also possible if it is of type `Type::Arithmetical` and if it contains only indeterminates which are of type `Type::ConstantIdents` or if it contains no indeterminates.

#### Categories

`Cat::DifferentialRing`

, `Cat::Field`

#### Related Domains

`Dom::Float`, `Dom::Integer`, `Dom::Numerical`, `Dom::Rational`, `Dom::Real`

#### Details

- `Dom::Complex` is the domain of complex constants represented by expressions of type `DOM_INT`, `DOM_RAT`, `DOM_FLOAT` or `DOM_COMPLEX`. An expression of type `DOM_EXPR` is considered a complex number if it is of type `Type::Arithmetical` and if it contains only indeterminates which are of type `Type::ConstantIdents` or if it contains no indeterminates, cf. example 2.

- `Dom::Complex` is of category `Cat::Field` due to pragmatism. This domain actually is not a field because `bool(1.0 = float(3) / float(3))` returns `FALSE`, for example.
- Elements of `Dom::Complex` are usually not created explicitly. However, if one creates elements using the usual syntax, it is checked whether the input expression can be converted to a number. This means `Dom::Complex` is a facade domain which creates elements of domain type `DOM_INT`, `DOM_RAT`, `DOM_FLOAT`, `DOM_COMPLEX` or `DOM_EXPR`.
- `Dom::Complex` has no normal representation, because `0` and `0.0` both represent the zero.
- Viewed as a differential ring, `Dom::Complex` is trivial. It only contains constants.
- `Dom::Complex` has the domain `Dom::BaseDomain` as its super domain, i.e., it inherits each method which is defined by `Dom::BaseDomain` and not re-implemented by `Dom::Complex`. Methods described below are re-implemented by `Dom::Complex`.

#### Entries

characteristic

  the characteristic of this field is 0.

one

  the unit element; it equals `1`.

zero

  The zero element; it equals `0`.

#### Method _divide: divide numbers

- `_divide(dom x, dom y)`
- - Behaves like the function `_divide`.

#### Method _invert: invert numbers

- `_invert(dom x)`
- - Behaves like the function `_invert`.

#### Method _mult: multiplies numbers

- `_mult(dom x, dom y...)`
- - Behaves like the function `_mult`.

#### Method _negate: negate numbers

- `_negate(dom x)`
- - Behaves like the function `_negate`.

#### Method _plus: add numbers

- `_plus(dom x, dom y...)`
- - Behaves like the function `_plus`.

#### Method _power: power operator

- `_power(dom x, dom y)`
- - Behaves like the function `_power`.

#### Method _unequal: inequalities

- `_unequal(dom x, dom y)`
- - Behaves like the function `_unequal`.

#### Method conjugate: conversion to a basic type

- `conjugate(dom x)`
- - Behaves like the function `conjugate`.

#### Method D: differential operator

- `D(dom x)`
- - This method returns 0.

#### Method diff: differentiates

- `diff(dom z, <, any x...> )`
- - This method returns `z` if it is called with only one argument. Otherwise it returns 0.

#### Method equal: equations

- `equal(dom x, dom y)`
- - Behaves like the function `_equal`.

#### Method expr: conversion to a basic type

- `expr(dom x)`
- - Behaves like the function `expr`.

#### Method iszero: zero test

- `iszero(dom x)`
- - Behaves like the function `iszero`.

#### Method norm: the absolute value of a number

- `norm(dom x)`
- - This method returns |x|.

#### Method random: random number generation

- `random()`
- - This method returns a randomly generated complex number where the real part and the imaginary part are positive integers between 0 and 1012-1 generated by `random`.

- `random(integer n)`
- - This method returns a random number generator which creates complex random numbers where the real parts and the imaginary parts are positive integers between 0 and n-1.

- `random(integer m..integer n)`
- - This method returns a random number generator which creates complex random numbers where the real parts and the imaginary parts are positive integers between m and n.

#### Method unequal: inequalities

- `unequal(dom x, dom y)`
- - Behaves like the function `_unequal`.

#### Method convert: conversion into this domain

- `convert(any x)`
- - This method tries to convert `x` to a number of type `Dom::Complex`. Currently this method can convert elements of type `DOM_INT`, `DOM_RAT`, `DOM_FLOAT`, `DOM_COMPLEX`. It also can convert constant identifier like `PI`, `EULER` and `CATALAN`.
  - An arithmetical expression can be converted if it only contains subexpression of the types just mentioned.
  - If the conversion fails, `FAIL` is returned.

#### Method convert_to: conversion to other domains

- `convert_to(dom x, any T)`
- - This method tries to convert the number `x` to an element of type `T`, or if `T` is not a domain, to the domain type of `T`.
  - If the conversion fails, `FAIL` is returned.
  - The following domains are allowed for `T`: `DOM_INT`, `Dom::Integer`, `DOM_RAT`, `Dom::Rational`, `DOM_FLOAT`, `Dom::Float`, `Dom::Numerical`, `DOM_COMPLEX` and `DOM_EXPR`.

#### Method normal: normal form of objects

- `normal(dom x)`
- - Behaves like the function `normal`.

#### Example 1

Creating some complex numbers using `Dom::Complex`:

    >> Dom::Complex(2/3)

                                        2/3

    >> Dom::Complex(2/3 + 4*I)

                                     2/3 + 4 I

#### Example 2

It's also possible to use expressions or constants for creating an element of `Dom::Complex`:

    >> Dom::Complex(PI)

                                        PI

    >> Dom::Complex(sin(2))

                                      sin(2)

    >> Dom::Complex(sin(2/3*I) + 3)

                                  I sinh(2/3) + 3

If the expression cannot be converted to an element of `Dom::Complex` we will get an error message:

    >> Dom::Complex(sin(x))

          Error: illegal arguments [Dom::Complex::new]

#### Super-Domain

`Dom::ArithmeticalExpression`

#### Axioms

`Ax::systemRep`

, `Ax::efficientOperation("_divide")`, `Ax::efficientOperation("_mult")`, `Ax::efficientOperation("_invert")`

#### Changes

- no changes

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000