GAMMALN.PRECISE in Google Sheets: How to Use It
In this article
GAMMALN.PRECISE returns the natural logarithm of the absolute value of the gamma function for a given number. In plain terms, it gives you a more accurate answer than the older GAMMALN function when you are working with large or very small inputs, and it is the function Google Sheets recommends when you need a reliable log-gamma value. To use it, type =GAMMALN.PRECISE(x) into a cell, replacing x with a positive number or a cell reference that contains one.
What You'll Need
- A Google account with access to Google Sheets (the free web version or the mobile app).
- A spreadsheet where you want to calculate the log-gamma value.
- A positive number as your input. GAMMALN.PRECISE does not accept zero or negative numbers.
Step-by-Step
- Open your spreadsheet. Go to Google Sheets in a browser or open the Google Sheets app on your phone or tablet. The function works the same on desktop and mobile, though the formula entry bar looks slightly different.
- Click the cell where you want the result. Pick an empty cell so you do not overwrite existing data. The result will appear in this cell.
- Start the formula. Type an equals sign
=to begin. Then typeGAMMALN.PRECISE(. As you type, Sheets may show a suggestion; you can press Tab or click the suggestion to complete the function name. If you type it manually, make sure the period is included exactly as shown. - Enter the input value. Type a positive number, for example
5, or click a cell that contains a positive number. You can also use a calculation, such as2+3, as long as the result is positive. Do not enter zero or a negative number; the function will return an error. - Close the parenthesis and press Enter. Your formula should look like
=GAMMALN.PRECISE(5)or=GAMMALN.PRECISE(A2). Press Enter (or the checkmark on mobile) to run it. The cell will show the natural logarithm of the gamma function for that value. - Copy the formula down if needed. If you have a column of inputs, drag the fill handle (the small square at the bottom-right of the cell) down to apply the same formula to other rows. Relative references will adjust automatically, so
A2becomesA3, and so on. - Check the result. For example,
=GAMMALN.PRECISE(5)returns approximately 3.178. If you see a number, the function worked. If you see an error, check the input value and the spelling of the function name.
Common Mistakes
- Using zero or a negative number. GAMMALN.PRECISE requires a positive input. Zero and negative numbers produce a #NUM! error because the gamma function is not defined there in the way this function expects.
- Misspelling the function name. The period between GAMMALN and PRECISE is required. Typing
GAMMALNPRECISEorGAMMALN PRECISEwill not work. - Confusing it with GAMMALN. The older GAMMALN function still exists and gives similar results, but GAMMALN.PRECISE is the more accurate version. If you need consistency with older spreadsheets, note which one you used.
- Forgetting the closing parenthesis. Sheets will usually offer to fix this, but a missing parenthesis can cause a formula parse error.
- Referencing a cell that contains text. If the referenced cell holds text instead of a number, the function returns a #VALUE! error. Make sure your input cells contain numbers only.
Tips
- Use cell references instead of hard-coded numbers when you plan to change inputs later. This makes your spreadsheet easier to update.
- Combine GAMMALN.PRECISE with EXP to get the gamma function value itself:
=EXP(GAMMALN.PRECISE(x))gives the gamma function for positive x. - For very large inputs, GAMMALN.PRECISE avoids overflow errors that can happen if you try to calculate the gamma function directly. That is one of its main advantages.
- If you are working with statistical distributions, check whether a dedicated function (such as GAMMADIST) already does what you need before building a custom formula.
- Keep your input values in a separate column so you can audit and change them without editing the formula each time.
Troubleshooting
If the function returns an error, work through these checks in order. First, confirm the input is a positive number. A #NUM! error almost always means zero or a negative value was passed. Second, check for a #VALUE! error, which means the referenced cell contains text or a blank that Sheets cannot interpret as a number. Third, verify the function name is spelled exactly GAMMALN.PRECISE with the period. Fourth, make sure you have not used a semicolon instead of a comma between arguments; GAMMALN.PRECISE takes only one argument, so there should be no separator at all. If the formula still fails, try typing it into a fresh cell with a simple number like =GAMMALN.PRECISE(2) to confirm the function itself works in your sheet. If that works, the problem is with your original input or reference. On mobile, the formula bar may hide part of the formula; tap the cell and check the full text in the formula bar to spot typos.
Frequently Asked Questions
What is the difference between GAMMALN and GAMMALN.PRECISE?
Both return the natural logarithm of the absolute value of the gamma function. GAMMALN.PRECISE is the more accurate version and is the one Google Sheets recommends for new formulas. For most everyday inputs the results are very close, but GAMMALN.PRECISE is the safer choice when precision matters.
Can GAMMALN.PRECISE handle negative numbers?
No. The function requires a positive input. Passing zero or a negative number returns a #NUM! error. If you need the gamma function for negative non-integer values, you would need a different approach, but GAMMALN.PRECISE itself does not support them.
Does GAMMALN.PRECISE work in the Google Sheets mobile app?
Yes. The function is available in the Google Sheets app on Android and iOS, as well as in the browser version. The formula syntax is the same; only the interface for entering it differs.
Why does my formula return a #VALUE! error?
A #VALUE! error usually means the input is text rather than a number. Check the cell you referenced and make sure it contains a numeric value with no stray spaces or letters. You can use the ISNUMBER function to test a cell before feeding it into GAMMALN.PRECISE.
Can I use GAMMALN.PRECISE with very large numbers?
Yes, that is one of its strengths. Because it returns a logarithm, it can handle inputs that would cause the direct gamma function to overflow. The result will be a large number, but it will still be a valid numeric value in Sheets.
Is GAMMALN.PRECISE available in Excel?
Excel has a function called GAMMALN.PRECISE with the same purpose, so formulas using it are generally compatible between the two programs. However, always test your spreadsheet after importing or exporting to confirm the results match.