# what to do when NSolve does not solve

f = 696.1125540355472 + 3.9668099604385043 x + LogGamma[1 + x] - LogGamma[169 + x]

Plot[f, {x, 0, 10}]

Solve[f == 0, x, Reals]
NSolve[f == 0, x]


I know that the LogGamma probably is causing problems, but is there a way to solve this type of equations? In fact, I have all my functions involve LogGamma, and these need to be solved numerically, for x>0.

Thanks!

An additional option, that might not be known (I did not know about this until Daniel mentioned this on another post), is that if one have an idea about the range of values of the variable being solved for, and possibly other parameters, then NSolve and Solve will now be able to find solutions.

At least from the examples I've tried so far

f = 696.1125540355472 +3.9668099604385043 x +LogGamma[1 + x] -LogGamma[169 + x];
Solve[{f == 0 && (0 <=  x <= 10)}, x]
NSolve[{f == 0 && (0 <=  x <= 10)}, x]


Both of the above produce the solution If you only need a numerical solution, then FindRoot should be one option:

FindRoot[f, {x, 4}]
(* {x -> 6.91844} *)


and

Plot[f, {x, 0, 10},
Epilog -> {Red, PointSize[.03], Point[{x, f}] /. FindRoot[f, {x, 4}]}] • Very detailed and pretty answer. Thanks too! – Chen Stats Yu Oct 12 '14 at 11:57