The LOG function is categorized as a Math & Trigonometry function in Excel. Besides that, it is also a worksheet function; which means it can be used in combination with other functions in Excel. Moreover, this function is very simple and easy to use. This function is widely used in business analytics, statistics, and finance, etc. So, in this article, I am going to discuss the details of the LOG function and its application too.
Download the Practice Workbook
You can download the practice workbook that we have used to prepare this article.
Introduction to Excel LOG Function
Returns the logarithm of a number to the base you specify. According to mathematics, the logarithm is the inverse to exponentiation. That means the logarithm of any given number is the exponent to which the base has to be raised to get a specified number. For instance, if x is the exponent of base b to get the value y.
bx=y Then logby=x
|number||Required||The positive real number for which we want the logarithm (e.g. 64, 8, 2.1, etc.). This value is numeric and must be greater than zero.|
|base||Optional||This base is used to calculate the logarithm of a number. If this parameter is omitted, the function will use a base of 10.|
- Return Value
The LOG function returns a numeric value.
- Available in Version
Excel for Office 365, Excel 2019, Excel 2016, Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000.
5 Examples to Use Excel LOG Function
1. Apply Excel LOG Function Without Base Argument
When the second argument of the LOG function: [base] is not supplied, the function assumes the base value as 10 automatically. For example, we will find the logarithm of 10000. So, follow the below steps to get the result:
- First, type the following formula in Cell D5.
- As a consequence, you will get the logarithm value for 10000; which is 4.
Here, Excel calculates the logarithm value and returns as 4. It means the number 10 is multiplied 4 times to get 10000 (10*10*10*10).
- Next, use the Fill Handle (+) tool to copy the formula to the rest of the cells to get the logarithm value.
- Finally, here is the result for the rest of the cells.
Read More: How to Use Excel EXP Function (5 Examples)
2. Use LOG Function With Base Argument in Excel
Unlike Method 1, in this example, we will apply both arguments of the LOG function. Such as, we will find the logarithm value for 125 with the base value of 5.
- Initially, type the below formula in Cell D5.
- As a result, you will find that the logarithm value is 3.
Here, the result means base 5 raised to power 3 to get 125.
- Lastly, for the rest of the cells use the Fill Handle (+) to copy the formula.
3. Put Decimal Value as Base Argument
You can use variations in using the options [base] value. For instance, you can use decimal values as base values. In this method, we will find out the logarithm of 10, for the base value of .25. So, follow the steps associated with the method.
- In the beginning, type the following formula in Cell D5.
- Consequently, you will find the below result.
Here, the function calculates the logarithm for 10 with base value: .25 and returns -1.660964047. It means .25-1.660964047=10, and Log.25(10) = -1.660964047.
- At last, use the Fill Handle (+) to copy the formula to the rest of the cells.
- How to Use COS Function in Excel (2 Examples)
- VBA EXP Function in Excel (5 Examples)
- How to Use SIN Function in Excel (6 Easy Examples)
- 44 Mathematical Functions in Excel (Download Free PDF)
- How to Use MMULT Function in Excel (6 Examples)
4. Use VBA to LOG Function
Now we will use the VBA to get the logarithm for a particular number with a base value. For instance, we will find out the logarithm of 216 with the base value of 6. So, here are the steps associated with the process:
- First, go to the worksheet containing the data and right-click on the sheet name. Next, click on the View Code.
- Now, the Code Module window will show up. Then, write the below code on the module.
Option Explicit Function LogAny(b As Double, y As Double) As Double ' b: base y: a given number LogAny = Log(y) / Log(b) End Function Sub Log_VBA() MsgBox LogAny(6, 216) End Sub
- After that, Run the code.
- In conclusion, you will see that the formula returns 3 in the message box.
5. Application of LOG and POWER Functions in Excel
The POWER function is the inverse of the LOG function. For instance, we have a base value of 5 and exponent 3. So, we will follow the below steps to get the logarithm associated with the previously mentioned base and exponent value using both the POWER and LOG functions.
- First, type the below formula to Cell C7.
Here, the POWER function returns the result of a number raised to a power. The POWER formula will return 125. Later, we passed the POWER function to the LOG function to get the logarithm of 125 with the base 5.
- In the end, you will get the exponent 3, using the combination of functions.
LOG Function Errors
Although the LOG function is very easy to use, it returns errors at times. Such as, if you do not enter the base value properly, the function will return the following errors.
- #NUM!: It happens when the [base] is negative or zero, then the function returns this error.
- #VALUE!: If the [base] argument is non-numeric.
- #DIV/0!: This occurs when the [base] argument is supplied as 1.
In the above article, I have tried to discuss the methods elaborately. Hopefully, these methods and explanations will be enough to solve your problems. Please let me know if you have any queries.