## `conjugate` -- complex conjugation

#### Introduction

`conjugate(`z`)` computes the conjugate Re(z) - I*Im(z) of a complex number z = Re(z) + I*Im(z).

#### Call(s)

`conjugate(z)`

#### Parameters

`z` | - | an arithmetical expression

#### Returns

an arithmetical expression.

### Overloadable:

`z`

#### Side Effects

`conjugate` is sensitive to properties of identifiers set via `assume`.

#### Related Functions

`abs`, `assume`, `Im`, `Re`, `rectform`, `sign`

#### Details

- For numbers of type `DOM_INT`, `DOM_RAT`, `DOM_FLOAT`, or `DOM_COMPLEX`, the conjugate is computed directly and very efficiently.

- `conjugate` can handle symbolic expressions. Properties of identifiers are taken into account (see `assume`). An identifier `z` without any property is assumed to be complex, and the symbolic call `conjugate(`z`)` is returned. See example 2.
- `conjugate` knows how to handle special mathematical functions, such as:

      _mult   _plus   _power  abs     cos     cosh    cot
      coth    csc     csch    erf     erfc    exp     gamma
      igamma  sec     sech    sin     sinh    tan     tanh

  See example 1.
- If `conjugate` does not know how to handle a special mathematical function, then a symbolic `conjugate` call is returned. See example 3.

#### Example 1

`conjugate` knows how to handle sums, products, the exponential function and the sine function:

    >> conjugate((1 + I)*exp(2 - 3*I))

                               (1 - I) exp(2 + 3 I)

    >> delete z: conjugate(z + 2*sin(3 - 5*I))

                           conjugate(z) + 2 sin(3 + 5 I)

#### Example 2

`conjugate` reacts to properties of identifiers:

    >> delete x, y: assume(x, Type::Real):
       conjugate(x), conjugate(y)

                                  x, conjugate(y)

#### Example 3

If the input contains a function that the system does not know, then a symbolic `conjugate` call is returned:

    >> delete f, z: conjugate(f(z) + I)

                                conjugate(f(z)) - I

Now suppose that `f` is some user-defined mathematical function, and that conjugate(f(z)) = f(conjugate(z)) holds for all complex numbers z. To extend the functionality of `conjugate` to `f`, we embed it into a function environment and suitably define its `"`conjugate" slot:

    >> f := funcenv(f):
       f::conjugate := u -> f(conjugate(u)):

Now, whenever `conjugate` is called with an argument of the form `f(u)`, it calls `f::conjugate(u)`, which in turn returns `f(conjugate(u))`:

    >> conjugate(f(z) + I), conjugate(f(I))

                            f(conjugate(z)) - I, f(- I)

#### Background

- If a subexpression of the form `f(u,..)` occurs in `z` and `f` is a function environment, then `conjugate` attempts to call the slot `"`conjugate" of `f` to determine the conjugate of `f(u,..)`. In this way, you can extend the functionality of `conjugate` to your own special mathematical functions.

  The slot `"`conjugate" is called with the arguments `u,..` of `f`.

  If `f` has no slot `"`conjugate", then the subexpression `f(u,..)` is replaced by the symbolic call `conjugate(`f(u...)`)` in the returned expression.

  See example 3.

- Similarly, if an element `d` of a library domain `T` occurs as a subexpression of `z`, then `conjugate` attempts to call the slot `"`conjugate" of that domain with `d` as argument to compute the conjugate of `d`.

  If `T` does not have a slot `"`conjugate", then `d` is replaced by the symbolic call `conjugate(`d`)` in the returned expression.

  The same happens for objects of kernel domains that are not arithmetical expressions, such as lists, arrays, tables, sets, or polynomials.

#### Changes

- `conjugate` now reacts to properties of identifiers.

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