MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
ln function in MATLAB®, see
ln(x) represents the natural logarithm of
Natural logarithm is defined for all complex arguments x ≠ 0.
ln applies the following simplification rules
to its arguments:
x is of the type
Type::Numeric, then .
k is an integer, such that the imaginary part
of the result lies in the interval .
Similar simplifications occur for .
x is a negative integer or a
negative rational, then ln(x)
= i π + ln(- x).
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,
returns unresolved function calls.
If an argument is a floating-point value,
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
= i π + ln(- x), x <
0. See Example 3.
If an argument is a floating-point interval of type
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(x y)
= ln(x) + ln(y) are
not valid throughout the complex plane. Use properties to mark identifiers
as real and apply functions such as
simplify to manipulate expressions involving
See Example 5.
When called with a floating-point argument, the function is
sensitive to the environment variable
DIGITS which determines
the numerical working precision.
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(123.4), ln(5.6 + 7.8*I), ln(1.0/10^20)
ln applies special simplification rules to
ln(1), ln(-1), ln(exp(-5)), ln(exp(5 + 27/4*I))
float(ln(PI + I))
limit(ln(x)/x, x = infinity)
series(x*ln(sin(x)), x = 0, 10)
The negative real axis is a branch cut. The imaginary part of
the values returned by
ln jump when crossing this
ln(-2.0), ln(-2.0 + I/10^1000), ln(-2.0 - I/10^1000)
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)
simplify react to properties
The following call does not produce an expanded result, because the
arithmetical rule ln(x y)
= ln(x) + ln(y) does
not hold for arbitrary complex x, y:
If one of the factors is real and positive, the rule is valid:
assume(x > 0): expand(ln(x*y))
simplify(ln(x^3*y) - ln(x))
For further computations, clear the assumption: