# Logarithms

## Definitions for Logarithms

Option variable: %e_to_numlog
Default value: `false`

When `true`, `r` some rational number, and `x` some expression, `%e^(r*log(x))` will be simplified into `x^r` . It should be noted that the `radcan` command also does this transformation, and more complicated transformations of this ilk as well. The `logcontract` command "contracts" expressions containing `log`.

Function: log (x)
Represents the natural logarithm of x.

Simplification and evaluation of logarithms is governed by several global flags:

`logexpand` - causes `log(a^b)` to become `b*log(a)`. If it is set to `all`, `log(a*b)` will also simplify to `log(a)+log(b)`. If it is set to `super`, then `log(a/b)` will also simplify to `log(a)-log(b)` for rational numbers `a/b`, `a#1`. (`log(1/b)`, for `b` integer, always simplifies.) If it is set to `false`, all of these simplifications will be turned off.

`logsimp` - if `false` then no simplification of `%e` to a power containing `log`'s is done.

`lognumer` - if `true` then negative floating point arguments to `log` will always be converted to their absolute value before the `log` is taken. If `numer` is also `true`, then negative integer arguments to `log` will also be converted to their absolute value.

`lognegint` - if `true` implements the rule `log(-n)` -> `log(n)+%i*%pi` for `n` a positive integer.

`%e_to_numlog` - when `true`, `r` some rational number, and `x` some expression, `%e^(r*log(x))` will be simplified into `x^r` . It should be noted that the `radcan` command also does this transformation, and more complicated transformations of this ilk as well. The `logcontract` command "contracts" expressions containing `log`.

Option variable: logabs
Default value: `false`

When doing indefinite integration where logs are generated, e.g. `integrate(1/x,x)`, the answer is given in terms of `log(abs(...))` if `logabs` is `true`, but in terms of `log(...)` if `logabs` is `false`. For definite integration, the `logabs:true` setting is used, because here "evaluation" of the indefinite integral at the endpoints is often needed.

Option variable: logarc
Default value: `false`

If `true` will cause the inverse circular and hyperbolic functions to be converted into logarithmic form. `logarc(exp)` will cause this conversion for a particular expression exp without setting the switch or having to re-evaluate the expression with `ev`.

Option variable: logconcoeffp
Default value: `false`

Controls which coefficients are contracted when using `logcontract`. It may be set to the name of a predicate function of one argument. E.g. if you like to generate SQRTs, you can do ```logconcoeffp:'logconfun\$ logconfun(m):=featurep(m,integer) or ratnump(m)\$``` . Then `logcontract(1/2*log(x));` will give `log(sqrt(x))`.

Function: logcontract (expr)
Recursively scans the expression expr, transforming subexpressions of the form `a1*log(b1) + a2*log(b2) + c` into `log(ratsimp(b1^a1 * b2^a2)) + c`

```(%i1) 2*(a*log(x) + 2*a*log(y))\$
(%i2) logcontract(%);
2  4
(%o2)                     a log(x  y )

```

If you do `declare(n,integer);` then `logcontract(2*a*n*log(x));` gives `a*log(x^(2*n))`. The coefficients that "contract" in this manner are those such as the 2 and the `n` here which satisfy `featurep(coeff,integer)`. The user can control which coefficients are contracted by setting the option `logconcoeffp` to the name of a predicate function of one argument. E.g. if you like to generate SQRTs, you can do ```logconcoeffp:'logconfun\$ logconfun(m):=featurep(m,integer) or ratnump(m)\$``` . Then `logcontract(1/2*log(x));` will give `log(sqrt(x))`.

Option variable: logexpand
Default value: `true`

Causes `log(a^b)` to become `b*log(a)`. If it is set to `all`, `log(a*b)` will also simplify to `log(a)+log(b)`. If it is set to `super`, then `log(a/b)` will also simplify to `log(a)-log(b)` for rational numbers `a/b`, `a#1`. (`log(1/b)`, for integer `b`, always simplifies.) If it is set to `false`, all of these simplifications will be turned off.

Option variable: lognegint
Default value: `false`

If `true` implements the rule `log(-n)` -> `log(n)+%i*%pi` for `n` a positive integer.

Option variable: lognumer
Default value: `false`

If `true` then negative floating point arguments to `log` will always be converted to their absolute value before the `log` is taken. If `numer` is also `true`, then negative integer arguments to `log` will also be converted to their absolute value.

Option variable: logsimp
Default value: `true`

If `false` then no simplification of `%e` to a power containing `log`'s is done.

Function: plog (x)
Represents the principal branch of the complex-valued natural logarithm with `-%pi` < `carg(x)` <= `+%pi` .