5
$\begingroup$
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!

$\endgroup$
7
$\begingroup$

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

Mathematica graphics

$\endgroup$
5
$\begingroup$

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}]}]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Very detailed and pretty answer. Thanks too! $\endgroup$ – Chen Stats Yu Oct 12 '14 at 11:57

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.