Next: Trigonometric and Hyperbolic Functions, Previous: Scientific Functions, Up: Scientific Functions

### 9.1 Logarithmic Functions

The shift-`L` (`calc-ln`) [`ln`] command computes the natural logarithm of the real or complex number on the top of the stack. With the Inverse flag it computes the exponential function instead, although this is redundant with the `E` command.

The shift-`E` (`calc-exp`) [`exp`] command computes the exponential, i.e., ‘`e`’ raised to the power of the number on the stack. The meanings of the Inverse and Hyperbolic flags follow from those for the `calc-ln` command.

The `H L` (`calc-log10`) [`log10`] command computes the common (base-10) logarithm of a number. (With the Inverse flag [`exp10`], it raises ten to a given power.) Note that the common logarithm of a complex number is computed by taking the natural logarithm and dividing by ‘`ln(10)`’.

The `B` (`calc-log`) [`log`] command computes a logarithm to any base. For example, `1024 <RET> 2 B` produces 10, since ‘`2^10 = 1024`’. In certain cases like ‘`log(3,9)`’, the result will be either ‘`1:2`’ or ‘`0.5`’ depending on the current Fraction mode setting. With the Inverse flag [`alog`], this command is similar to `^` except that the order of the arguments is reversed.

The `f I` (`calc-ilog`) [`ilog`] command computes the integer logarithm of a number to any base. The number and the base must themselves be positive integers. This is the true logarithm, rounded down to an integer. Thus `ilog(x,10)` is 3 for all ‘`x`’ in the range from 1000 to 9999. If both arguments are positive integers, exact integer arithmetic is used; otherwise, this is equivalent to ‘`floor(log(x,b))`’.

The `f E` (`calc-expm1`) [`expm1`] command computes ‘`exp(x)-1`’, but using an algorithm that produces a more accurate answer when the result is close to zero, i.e., when ‘`exp(x)`’ is close to one.

The `f L` (`calc-lnp1`) [`lnp1`] command computes ‘`ln(x+1)`’, producing a more accurate answer when ‘`x`’ is close to zero.