ln

Natural logarithm

For the `ln` function in MATLAB®, see `log`.

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

```ln(`x`)
```

Description

`ln(x)` represents the natural logarithm of `x`.

Natural logarithm is defined for all complex arguments x ≠ 0.

`ln` applies the following simplification rules to its arguments:

• If `x` is of the type `Type::Numeric`, then . Here `k` is an integer, such that the imaginary part of the result lies in the interval . Similar simplifications occur for .

• If `x` is a negative integer or a negative rational, then ln(x) = i π + ln(- x).

• If `x` is an integer, then .

• `ln` uses the following special values:

ln(1) = 0, ln(- 1) = i π, , , ln(∞) = ∞, ln(- ∞) = i π + ∞.

For exact numeric and symbolic arguments, `ln` typically returns unresolved function calls.

If an argument is a floating-point value, `ln` returns a floating-point result. The imaginary part of the result takes values in the interval . The negative real axis is a branch cut; the imaginary part of the result jumps when crossing the cut. On the negative real axis, the imaginary part is π according to ln(x) = i π + ln(- x), x < 0. See Example 3.

If an argument is a floating-point interval of type `DOM_INTERVAL`, `ln` returns the results of type `DOM_INTERVAL`, properly rounded outwards. This implies that the result contains only real numbers. See Example 4.

Arithmetical rules such as ln(xy) = ln(x) + ln(y) are not valid throughout the complex plane. Use properties to mark identifiers as real and apply functions such as `expand`, `combine` or `simplify` to manipulate expressions involving `ln`. See Example 5.

Environment Interactions

When called with a floating-point argument, the function is sensitive to the environment variable `DIGITS` which determines the numerical working precision.

Examples

Example 1

Compute the natural logarithms of these numeric and symbolic values:

`ln(2), ln(-3), ln(1/4), ln(1 + I), ln(x^2)`

For floating-point arguments, `ln` returns floating-point results:

`ln(123.4), ln(5.6 + 7.8*I), ln(1.0/10^20)`

`ln` applies special simplification rules to its arguments:

`ln(1), ln(-1), ln(exp(-5)), ln(exp(5 + 27/4*I))`

Example 2

`diff`, `float`, `limit`, `series` and similar functions handle expressions involving `ln`:

`diff(ln(x^2), x)`

`float(ln(PI + I))`

`limit(ln(x)/x, x = infinity)`

`series(x*ln(sin(x)), x = 0, 10)`

Example 3

The negative real axis is a branch cut. The imaginary part of the values returned by `ln` jump when crossing this cut:

`ln(-2.0), ln(-2.0 + I/10^1000), ln(-2.0 - I/10^1000)`

Example 4

The natural logarithm of an interval is the image set of the logarithm function over the set represented by the interval:

`ln(1 ... 2)`

`ln(-1 ... 1)`

This definition extends to unions of intervals:

`ln(1 ... 2 union 3 ... 4)`

Example 5

`expand`, `combine`, and `simplify` react to properties set via `assume`. The following call does not produce an expanded result, because the arithmetical rule ln(xy) = ln(x) + ln(y) does not hold for arbitrary complex x, y:

`expand(ln(x*y))`

If one of the factors is real and positive, the rule is valid:

`assume(x > 0): expand(ln(x*y))`

`combine(%, ln)`

`simplify(ln(x^3*y) - ln(x))`

For further computations, clear the assumption:

`unassume(x):`

Parameters

 `x`

Return Values

Arithmetical expression

`x`