How to use the LN function
What is the LN function?
The LN function calculates the natural logarithm of a number.
Table of Contents
1. Introduction
What is ln?
Ln is an abbreviation of natural logarithm are based on the constant e. It is the inverse of the exponential function.
How is the natural logarithm defined?
The natural logarithm, or log base e, is defined using the following limit:
ln(x) = lim (n->infinity) (x(1/n) - 1) * n
What are the four key natural logarithm rules?
The following rules are essential to learn if you want to solve various equations involving natural logarithms effectively.
1. Product rule
ln(x*y) = ln(x) + ln(y)
The natural log of the multiplication of x and y is the sum of the ln x and ln y.
Example, ln (5*10) = ln(5) + ln(10)
2. Quotient rule
ln(x/y) = ln(x) - ln(y)
The natural log of the division of x and y is the difference of the ln x and ln y.
Example, ln (5/10) = ln(5) - ln(10)
3. Reciprocal rule
ln(1/x) = − ln(x)
The natural log of the reciprocal of x is similar to the quotient rule. ln(1/x) = ln(1) - ln(x) = 0 - ln x = - ln x
Example, ln(1/5) = - ln(5)
4. Power rule
ln(xy) = y * ln(x)
The natural log of x raised to the power of y is y multiplied by the ln x.
Example, ln(510) = 10 * ln(5)
Some key properties of the natural logarithm:
- The natural log of 1 is 0.
- LN is undefined for negative numbers.
- LN is the inverse of the EXP function
LN(EXP(x)) = x.
What is e?
E stands for Euler's constant and it is the base of the natural logarithm shortened to ln. This means that ln e = 1
Excel has the function named EXP that returns e raised to the power of a given number.
What is a base?
In logarithms, the base is the number that is raised to a power to produce the desired output. It is the foundation of the logarithmic function.
For example, the logarithm log10(100):
- 10 is the base
- 100 is the input number
- 2 is the exponent that makes 10 return 100 because 102 = 100
The most common bases are
- 10
- e (natural log), and
- 2 (for computers).
But any positive number besides 1 can be a base.
How is e defined?
e is defined to be the limit of (1 + 1/n) raised to the nth power as n approaches infinity.
In equation form: e = lim (1 + 1/n)n as n -> infinity
The limit of this exponential growth pattern is the unique number e. Here are some examples:
(1 + 1/1)1 = 2
(1 + 1/2)2 = 2.25
(1 + 1/3)3 = 2.37037
The limit of this exponential growth pattern is the unique number e.
e = e1 equals 2.71828182845904.
e2 equals 7.389056099
What are the other logarithmic functions in Excel?
Excel function | Description |
---|---|
LOG | Returns the logarithm with a given base. |
LN | Returns the natural logarithm (base e) of a number |
LOG10 | Returns the base-10 logarithm of a number |
LOG2 | Returns the base-2 logarithm of a number |
The corresponding inverse functions for the logarithm functions in Excel:
Logarithm | Power to |
---|---|
LOG | Arbitrary base, basex or POWER(number, power) |
LN | EXP(number) |
LOG10 | 10x or POWER(10,x) |
LOG2 | 2x or POWER(2,x) |
What applications does the natural logarithm have?
Natural logs have applications in math, science, and finance for calculating compound growth, diffusion, acidity, and more. LN is useful whenever natural exponential growth or decay is involved.
What is the difference between the natural logarithm (ln) and the base 10 logarithm (log10)?
The difference between natural logarithm and the base 10 logarithm is the base being used. The natural logarithm uses e as the base whereas the log10 uses 10 as the base.
2. Syntax
LN(number)
number | Required. The positive numerical value for which you want the natural logarithm. |
3. Example 1
This example shows the different logarithms on an Excel chart, the logarithms are log2, ln, and log10
The logarithms return a negative result if the x value is larger than 0 (zero) and smaller than 1. The logarithm for 0 (zero) is undefined resulting in a #NUM error. The logarithms return a positive result if the x value is larger than 1.
x | log2 | ln | log10 |
---|---|---|---|
0 | #NUM! | #NUM! | #NUM! |
1 | 0.000 | 0.000 | 0.000 |
2 | 1.000 | 0.693 | 0.301 |
3 | 1.585 | 1.099 | 0.477 |
4 | 2.000 | 1.386 | 0.602 |
5 | 2.322 | 1.609 | 0.699 |
6 | 2.585 | 1.792 | 0.778 |
7 | 2.807 | 1.946 | 0.845 |
8 | 3.000 | 2.079 | 0.903 |
9 | 3.170 | 2.197 | 0.954 |
10 | 3.322 | 2.303 | 1.000 |
The table above is rounded to three decimals.
Formula in cell B3:
The result of ln(1) is 0 (zero), the image above shows a graph containing the natural logarithm. The curve has the color orange, find 1 on the x axis. It intersects the x-axis at 1 which equals 0 (zero) on the y-axis.
The chart also plots the log2 and log10 curves:
- The log2x curve (blue) grows the fastest among the three, meaning for any given x value, log2x has the largest y-value.
- The ln curve (orange) has a slower growth rate than log2x but faster than log10x.
- The log10x curve (grey) grows the slowest, having the smallest y-values for any given x.
All three curves share some common characteristics:
- They are increasing functions, meaning their values increase as x increases along the x-axis.
- They have a vertical asymptote at x = 0, meaning they approach negative infinity as x approaches 0 from the positive side.
- They are concave downwards, with the rate of increase gradually slowing down as x grows larger.
4. Example 2
How many years will it take to compound 3300, based on 5% interest rate, to a future value of 6900?
The LN function allows us to calculate how many periods ( or years in this example) based on the following data:
- r - interest rate (This value is specified in cell C19)
- PV - present value (This value is found in cell C18)
- FV - future value (This value is in cell C17)
The formula for calculating the number of periods (n) needed is:
n = ln( FV / PV ) / ln(1+r)
Formula in cell C21:
The formula returns 15.1177794886966 periods, lets see if we can calculate this value.
n = ln (6900 / 3300)/ ln(1 + 0.05)
n = 0.737598943130779/0.048790164169432
n = 15.1177794886966
The chart above shows a orange curve representing the the interest rate and a blue curve representing the cumulative compounded value across periods. The data points in the graph are based on data in cell range B25:D41
5. How to graph the natural logarithm in Excel?
To create the chart above I started entering x values in one column, to get a finer curve I entered x values with smaller and smaller increments as I got closer to 0 (zero), see the table below.
The next column has the result of the natural logarithm, this will be the y (vertical) values of the line on the chart.
x | LN |
0.04 | -3.2188758248682 |
0.05 | -2.99573227355399 |
0.06 | -2.81341071676004 |
0.07 | -2.65926003693278 |
0.08 | -2.52572864430826 |
0.09 | -2.40794560865187 |
0.1 | -2.30258509299405 |
0.2 | -1.6094379124341 |
0.3 | -1.20397280432594 |
0.4 | -0.916290731874155 |
0.5 | -0.693147180559945 |
0.6 | -0.510825623765991 |
0.7 | -0.356674943938732 |
0.8 | -0.22314355131421 |
0.9 | -0.105360515657826 |
1 | 0 |
1.1 | 0.0953101798043249 |
1.2 | 0.182321556793955 |
1.3 | 0.262364264467491 |
1.4 | 0.336472236621213 |
1.5 | 0.405465108108164 |
1.6 | 0.470003629245736 |
1.7 | 0.53062825106217 |
1.8 | 0.587786664902119 |
1.9 | 0.641853886172395 |
2 | 0.693147180559945 |
3 | 1.09861228866811 |
4 | 1.38629436111989 |
5 | 1.6094379124341 |
6 | 1.79175946922806 |
7 | 1.94591014905531 |
8 | 2.07944154167984 |
9 | 2.19722457733622 |
10 | 2.30258509299405 |
Select both columns and then go to "Insert" tab on the ribbon.
6. Function not working
The LN function returns
- #VALUE! error if you use a non-numeric input value.
- #NAME? error if you misspell the function name.
- propagates errors, meaning that if the input contains an error (e.g., #VALUE!, #REF!), the function will return the same error.
6.1 Troubleshooting the error value
When you encounter an error value in a cell a warning symbol appears, displayed in the image above. Press with mouse on it to see a pop-up menu that lets you get more information about the error.
- The first line describes the error if you press with left mouse button on it.
- The second line opens a pane that explains the error in greater detail.
- The third line takes you to the "Evaluate Formula" tool, a dialog box appears allowing you to examine the formula in greater detail.
- This line lets you ignore the error value meaning the warning icon disappears, however, the error is still in the cell.
- The fifth line lets you edit the formula in the Formula bar.
- The sixth line opens the Excel settings so you can adjust the Error Checking Options.
Here are a few of the most common Excel errors you may encounter.
#NULL error - This error occurs most often if you by mistake use a space character in a formula where it shouldn't be. Excel interprets a space character as an intersection operator. If the ranges don't intersect an #NULL error is returned. The #NULL! error occurs when a formula attempts to calculate the intersection of two ranges that do not actually intersect. This can happen when the wrong range operator is used in the formula, or when the intersection operator (represented by a space character) is used between two ranges that do not overlap. To fix this error double check that the ranges referenced in the formula that use the intersection operator actually have cells in common.
#SPILL error - The #SPILL! error occurs only in version Excel 365 and is caused by a dynamic array being to large, meaning there are cells below and/or to the right that are not empty. This prevents the dynamic array formula expanding into new empty cells.
#DIV/0 error - This error happens if you try to divide a number by 0 (zero) or a value that equates to zero which is not possible mathematically.
#VALUE error - The #VALUE error occurs when a formula has a value that is of the wrong data type. Such as text where a number is expected or when dates are evaluated as text.
#REF error - The #REF error happens when a cell reference is invalid. This can happen if a cell is deleted that is referenced by a formula.
#NAME error - The #NAME error happens if you misspelled a function or a named range.
#NUM error - The #NUM error shows up when you try to use invalid numeric values in formulas, like square root of a negative number.
#N/A error - The #N/A error happens when a value is not available for a formula or found in a given cell range, for example in the VLOOKUP or MATCH functions.
#GETTING_DATA error - The #GETTING_DATA error shows while external sources are loading, this can indicate a delay in fetching the data or that the external source is unavailable right now.
6.2 The formula returns an unexpected value
To understand why a formula returns an unexpected value we need to examine the calculations steps in detail. Luckily, Excel has a tool that is really handy in these situations. Here is how to troubleshoot a formula:
- Select the cell containing the formula you want to examine in detail.
- Go to tab “Formulas” on the ribbon.
- Press with left mouse button on "Evaluate Formula" button. A dialog box appears.
The formula appears in a white field inside the dialog box. Underlined expressions are calculations being processed in the next step. The italicized expression is the most recent result. The buttons at the bottom of the dialog box allows you to evaluate the formula in smaller calculations which you control. - Press with left mouse button on the "Evaluate" button located at the bottom of the dialog box to process the underlined expression.
- Repeat pressing the "Evaluate" button until you have seen all calculations step by step. This allows you to examine the formula in greater detail and hopefully find the culprit.
- Press "Close" button to dismiss the dialog box.
There is also another way to debug formulas using the function key F9. F9 is especially useful if you have a feeling that a specific part of the formula is the issue, this makes it faster than the "Evaluate Formula" tool since you don't need to go through all calculations to find the issue..
- Enter Edit mode: Double-press with left mouse button on the cell or press F2 to enter Edit mode for the formula.
- Select part of the formula: Highlight the specific part of the formula you want to evaluate. You can select and evaluate any part of the formula that could work as a standalone formula.
- Press F9: This will calculate and display the result of just that selected portion.
- Evaluate step-by-step: You can select and evaluate different parts of the formula to see intermediate results.
- Check for errors: This allows you to pinpoint which part of a complex formula may be causing an error.
The image above shows cell reference B3 converted to hard-coded value using the F9 key. The LN function requires numerical values which is not the case in this example. We have found what is wrong with the formula.
Tips!
- View actual values: Selecting a cell reference and pressing F9 will show the actual values in those cells.
- Exit safely: Press Esc to exit Edit mode without changing the formula. Don't press Enter, as that would replace the formula part with the calculated value.
- Full recalculation: Pressing F9 outside of Edit mode will recalculate all formulas in the workbook.
Remember to be careful not to accidentally overwrite parts of your formula when using F9. Always exit with Esc rather than Enter to preserve the original formula. However, if you make a mistake overwriting the formula it is not the end of the world. You can “undo” the action by pressing keyboard shortcut keys CTRL + z or pressing the “Undo” button
6.3 Other errors
Floating-point arithmetic may give inaccurate results in Excel - Article
Floating-point errors are usually very small, often beyond the 15th decimal place, and in most cases don't affect calculations significantly.
Functions in 'Math and trigonometry' category
The LN function function is one of 62 functions in the 'Math and trigonometry' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form