Recipe 7.4. Exploring Exponential and
|
|
Function |
Syntax |
Description |
|---|---|---|
|
LOG |
=LOG( n , base ) |
Returns the log of the number n to the specified base |
|
LOG10 |
=LOG10( n ) |
Returns the log of the number n to the base 10 |
|
LN |
=LN( n ) |
Returns the natural logarithm of n |
|
EXP |
=EXP( n ) |
Returns e n |
|
POWER |
=POWER( n , p ) |
Returns n p and is the same as the syntax n ^ p using the ^ operator |
|
SINH |
=SINH( n ) |
Returns (e n - e -n )/2 |
|
COSH |
=COSH( n ) |
Returns (e n + e -n )/2 |
|
TANH |
=TANH( n ) |
Returns (e n - e -n ) / (e n + e -n ) |
|
ASINH |
=ASINH( n ) |
Returns the inverse hyperbolic sine, ln( n + sqrt( n 2 +1)), where n is any real number |
|
ACOSH |
=ACOSH( n ) |
Returns the inverse hyperbolic cosine, ln( n + sqrt( n 2 -1)); n must be greater than 1 |
|
ATANH |
=ATANH( n ) |
Returns the inverse hyperbolic tangent, ln((1+ n )/(1- n ))/2; n must be between -1 and 1 |
These functions pretty much do what you'd expect functions related to logarithms and natural logarithms to do. You may
Excel also provides the exponential function EXP( n ) to compute e n , which is of course the inverse of the natural logarithm function.
Aside from straightforward logarithmic and exponential
Excel also has a function called POWER that you may find useful. The syntax for POWER is =POWER( n , power ) , where n is a given number and power is the power to which n will be raised. You can also use the ^ operator to raise a number to a power, as discussed in Recipe 1.9. Conversely, you can use POWER to reverse a LOG operation on a value. For example =POWER(10, LOG(3)) simply returns a value of 3.
This all seems straightforward enough, and it is, but there's potential for confusion when working with Excel's built-in logarithmic functions and the Log function available in VBA (Visual Basic for Applications; see Chapter 2 for a quick introduction). VBA provides the function Log( n ) , which returns the natural logarithm of the given number n , not the base 10 logarithm as you might expect. This clearly is not consistent with Excel's built-in logarithmic functions, where LOG means base 10 log and LN means natural log.
VBA does not provide another function for computing the base 10 logarithm of a number (or any other base, for that matter). However, when working in VBA you can compute the logarithm of a number to any base by taking the ratio of the natural logarithm of the number to the natural logarithm of the desired base. For example, to compute the base 10 logarithm of
n
, you'd write
Logn = Log(
n
) / Log(10.0)
, where
Logn
is just a variable you'd define to store the result (you can
Take a peek at Recipe 7.13 for more information on Excel's support for taking logarithms of complex numbers.