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


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


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?

  • 1
    $\begingroup$ 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. $\endgroup$ – Bill Watts Nov 3 '17 at 0:39
  • 1
    $\begingroup$ 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[]. $\endgroup$ – J. M.'s technical difficulties Nov 3 '17 at 3:39
f[n_, q_] := Log[(n + q - 1)!/(q!*(n - 1)!)]

Maybe one these will work for you.

f[650, 110] // N



f[650., 110.]


|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.