Previous Page Next Page Contents

log -- the logarithm to an arbitrary base

Introduction

log(b, x) represents the logarithm of x to the base b.

Call(s)

log(b, x)

Parameters

b - either an identifier of domain type DOM_IDENT or a real numerical value of type Type::Positive.
x - an arithmetical expression

Returns

an arithmetical expression.

Overloadable:

x

Side Effects

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

Related Functions

dilog, ln, polylog

Details

Example 1

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)

Example 2

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

Example 3

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)

Example 4

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)

Example 5

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):

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000