5
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!

Chen Stats Yu
  • 4,986
  • 2
  • 24
  • 50
  • After observing the plot you can numerically solve the equation using FindRoot[f[x] == 0, {x, #}] & /@ {-0, 6} in this case. Also look at the interesting answers here http://mathematica.stackexchange.com/questions/5663/about-multi-root-search-in-mathematica-for-transcendental-equations – PlatoManiac Oct 10 '14 at 00:13

2 Answers2

9

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

Nasser
  • 143,286
  • 11
  • 154
  • 359
5

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

halirutan
  • 112,764
  • 7
  • 263
  • 474