# Formatting Display Precision

I have defined the following function in Mathematica,

f[n_,q_] = Log[(n+q-1)!/(q!*(n-1)!)];


When putting in a large number, say f[650,110], the result is

Log[10408292...]


when I want the output to give me the evaluation of the natural logarithm (which ends up being about 310 in this case). I have made several attempts including changing the display precision in the settings - didn't work, setting the precision in the function,

f[n_,q_] = SetPrecision[Log[(n+q-1)!/(q!*(n-1)!)],15];


which gives this output

Log[1.040829240901916×10^135]


as well as specifically telling it to display in scientific notation,

f[n_,q_] = ScientificForm[Log[(n+q-1)!/(q!*(n-1)!)]];


which gives the same display as setting the precision. Could anyone help me with this display problem, please?

• I am not sure what display you are going for, but if you just want a simple number, use real input instead of exact input, such as f[650.,110] or you could use N[f[650,110]]. Also you are missing ) after ! in your second 2 equations. I get a simple decimal number when executing your SetPrecision equation after correction. Commented Nov 3, 2017 at 0:39
• Binomial[] is built-in, so you can use Log[Binomial[n + q - 1, q]]. Nevertheless, that can still overflow, so consider using the expression in terms of LogGamma[]. Commented Nov 3, 2017 at 3:39

f[n_, q_] := Log[(n + q - 1)!/(q!*(n - 1)!)]


Maybe one these will work for you.

f[650, 110] // N


310.889

or

f[650., 110.]


310.889005296658