## `numeric::complexRound` -- round a complex number towards the real or imaginary axis

#### Introduction

`numeric::complexRound``(z, ..)` discards small real or imaginary parts of complex floating point numbers `z`.

#### Call(s)

`numeric::complexRound(z <, eps>)`

#### Parameters

``z`` | - | an arbitrary MuPAD object

#### Options

``eps`` | - | a real number >= 10^(-DIGITS).

#### Returns

If `z` is a complex floating point number, then a real or complex floating point number is returned. For all other types `z` is returned unchanged.

#### Side Effects

The function is sensitive to the environment variable `DIGITS`.

#### Related Functions

`ceil`, `floor`, `frac`, `round`, `trunc`

#### Details

- If the real part of `z` satisfies `Re(z)<eps*abs(z)`, then it is replaced by zero and `Im(z)*I` is returned.

  If the imaginary part of `z` satisfies `Im(z)<eps*abs(z)`, then it is replaced by zero and `Re(z)` is returned.

- With the default of `eps`=10^(-DIGITS) this rounding changes a complex floating point number by less than the relative standard precision.
- This function removes small real or imaginary parts of complex floating points numbers generated by numerical round-off. It is used to simplify the floating point output of `numeric::fsolve`, `numeric::polyroots`, `numeric::polysysroots` and `numeric::sum`.

#### Option: `eps`

- The default value is `eps`=10^(-DIGITS).
- Only precisions `eps`>=10^(-DIGITS) are accepted.
- Numerical expressions such as `PI*sqrt(2)/10^10` etc. are accepted and converted to floats.

#### Example 1

Exact numbers are not changed:

    >> numeric::complexRound(2 + I/10^20)

                           2 + 1/100000000000000000000 I

Also the following number has an exact imaginary part and is not rounded:

    >> numeric::complexRound(2.0 + sqrt(2)*I/10^20)

                                                  1/2
                       1/100000000000000000000 I 2    + 2.0

Rounding occurs for complex floats, if this does not change its value significantly:

    >> numeric::complexRound(1.0 + 2.0*I/10^10),
       numeric::complexRound(1.0 + 2.0*I/10^11)

                             1.0 + 0.0000000002 I, 1.0

Note that rounding is based on relative precision, i.e., only the ratio of real and imaginary parts is relevant:

    >> numeric::complexRound((1.0 + 2.0*I)/10^100)

                              10.0e-101 + 2.0e-100 I

    >> numeric::complexRound((1.0 + 1.0/10^11*I)/10^100)

                                     10.0e-101

The relative precision for rounding may be reduced by the optional parameter `eps`:

    >> numeric::complexRound(2.0/10^10 + I),
       numeric::complexRound(2.0/10^10 + I, PI/10^5)

                            0.0000000002 + 1.0 I, 1.0 I

#### Changes

- new function

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