## `_invert` -- the reciprocal of an expression

#### Introduction

`_invert``(x)` computes the reciprocal `1/x` of `x`.

#### Call(s)

1/x `_invert(x)`

#### Parameters

`x` | - | an arithmetical expression or a set

#### Returns

an arithmetical expression or a set.

### Overloadable:

`x`

#### Related Functions

`_divide`, `_negate`, `^`, `/`, `*`, `+`, `-`

#### Details

- `1/x` is equivalent to the function call `_invert(x)`. It represents the inverse of the element `x` with respect to multiplication, i.e., `x * (1/x) = 1`.
- The reciprocal of a number of type `Type::Numeric` is returned as a number.
- `1/x` is overloaded for matrix domains (`matrix`) and returns the inverse of the matrix `x`.
- If `x` is not an element of a library domain with an `"_invert"` method, `1/x` is internally represented as `x^(-1)` = `_power(x, -1)`.
- If `x` is an element of a domain with a slot `"_invert"`, then this method is used to compute `1/x`. Many library domains overload the `/` operator by an appropriate `"_invert"` slot. Note that `a/x` calls the overloading slot `x::dom::_invert(x)` only for `a = 1`.
- If neither `x` nor `y` overload the binary operator `/` by a `"_divide"` method, the quotient `x/y` is equivalent to `x * y^(-1)` = `_mult(x, _power(y, -1))`.
- For finite sets, `1/X` is the set {1/x; x in X}.
- `_invert` is a function of the system kernel.

#### Example 1

The reciprocal of an expression is the inverse with respect to `*`:

    >> _invert(x), x * (1/x) = x * _invert(x)

                                     1
                                     -, 1 = 1
                                     x

    >> 3 * y * x^2 / 27 / x

                                        x y
                                        ---
                                         9

Internally, a symbolic expression `1/x` is represented as `x^(-1)` = `_power(x, -1)`:

    >> type(1/x), op(1/x, 0), op(1/x, 1), op(1/x, 2)

                              "_power", _power, x, -1

#### Example 2

For finite sets, `1/X` is the set {1/x; x in X}:

    >> 1/{a, b, c}

                                    { 1  1  1 }
                                    { -, -, - }
                                    { a  b  c }

#### Example 3

Various library domains such as matrix domains or residue class domains overload `_invert`:

    >> x := Dom::Matrix(Dom::IntegerMod(7))([[2, 3], [3, 4]]):
       x, 1/x, x * (1/x)

          +-                  -+  +-                  -+
          |  2 mod 7, 3 mod 7  |  |  3 mod 7, 3 mod 7  |
          |                    |, |                    |,
          |  3 mod 7, 4 mod 7  |  |  3 mod 7, 5 mod 7  |
          +-                  -+  +-                  -+

             +-                  -+
             |  1 mod 7, 0 mod 7  |
             |                    |
             |  0 mod 7, 1 mod 7  |
             +-                  -+

    >> delete x:

#### Changes

- no changes

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