log
-- the logarithm to an arbitrary
baselog
(b, x)
represents the logarithm of
x to the base b.
log(b, x)
b |
- | either an identifier of domain type DOM_IDENT or a real numerical value of type
Type::Positive . |
x |
- | an arithmetical expression |
an arithmetical expression.
x
When called with a floating point argument, the function is
sensitive to the environment variable DIGITS
which determines the numerical
working precision.
Type::Real
, ii)
b is numerical and y is integer or rational.log(b, 1) = 0, log(b, -1) = I*PI/ln(b), log(b, +/- I) = +/- I*PI/2/ln(b).
expand
or simplify
to manipulate
expressions involving log
. Cf. example 5.We demonstrate some calls with exact and symbolic input data:
>> log(b, 2), log(2, 3), log(10, 10^2), log(10, 2*10^2), log(2, I), log(b, x^2)
1/2 I PI 2 log(b, 2), log(2, 3), 2, log(10, 200), --------, log(b, x ) ln(2)
Note that the base may be a symbolic identifier. However, expressions are not accepted:
>> log(b + 1, 2)
Error: base must be an identifier or of Type::Positive [log]
>> log(PI^2, 2)
Error: base must be an identifier or of Type::Positive [log]
Floating point values are computed for floating point arguments:
>> log(2, 123.4), log(2.0, 5.6 + 7.8*I), log(10.0, 2/10^20)
6.947198584, 3.263347423 + 1.367856012 I, -19.69897
Some special symbolic simplifications are implemented:
>> log(b, 1), log(b, -1), log(2/3, (4/9)^10), log(b, b^(-5))
I PI 0, -----, 20, -5 ln(b)
The negative real axis is a branch cut. The imaginary
part of the values returned by log
jump when crossing this
cut:
>> log(10, -2.0), log(10, -2.0 + I/10^1000), log(10, -2.0 - I/10^1000)
0.3010299957 + 1.364376354 I, 0.3010299957 + 1.364376354 I, 0.3010299957 - 1.364376354 I
Use rewrite
to rewrite log
in terms of ln
:
>> rewrite(log(b, x), ln), rewrite(log(10, 200), ln)
ln(x) ln(200) -----, ------- ln(b) ln(10)
The functions diff
, float
, limit
, series
etc. handle expressions
involving log
:
>> diff(log(b, x^2), x), float(log(10, PI + I))
2 -------, 0.5181068691 + 0.133836127 I x ln(b)
>> limit(log(10, x)/x, x = infinity), series(x*log(x, sin(x)), x = 0)
3 5 x x 6 0, x - ------- - --------- + O(x ) 6 ln(x) 180 ln(x)
The functions expand
and simplify
react to properties set
via assume
. The
following call does not produce an expanded result, because the
arithmetical rule log(b, x*y) = log(b, x) + log(b, y) does
not hold for arbitrary complex x,y. Note, however, that
expand
rewrites
log
in terms of ln
:
>> expand(log(10, x*y))
ln(x y) ------- ln(10)
However, the rule is valid, if one of the factors is real and positive:
>> assume(x > 0): expand(log(b, x*y))
ln(x) ln(y) ----- + ----- ln(b) ln(b)
>> simplify(log(b, x^3*y) - log(b, x) - log(b, y))
2 log(b, x)
>> unassume(x):