# Why does this FindRoot code only trace one of two roots?

I have written the following code to trace the roots (in terms of f) of the shown equation as n rises. There are two roots for a given value of n. For example for n = 2, the roots are {f -> 0.171573}, {f -> 5.82843}. However, (after some error messages) the script only traces the lower roots. Why?

With[{V1 = 1}, ListPlot@Table[{n,f /. FindRoot[V1/4 + (f V1)/4 + 1/(4 (-1 + n) Gamma[1/2 (-1 + n)]^2) n^(1/2 (-3 - n)) (f V1)^(1/2 (-1 + n)) ((-1 + n) n^(3/2) V1^(3/2) Gamma[1/2 (-1 + n)]^2 (2 Sqrt[f] (-1 + n) (n/(f V1))^(n/2) - (1 + n) (n/V1)^(n/2) Hypergeometric2F1[1/2 (-1 + n), -1 + n, n, 1 - f]) - 2 (-1 + n)^2 Sqrt[n] (n/V1)^(n/2) V1^(3/2) Gamma[1/2 (-1 + n)] Gamma[(1 + n)/2] Hypergeometric2F1[n, (1 + n)/2, 1 + n, 1 - f] + (-5 + n) V1 Gamma[1/2 (-5 + n)] (n Gamma[(3 + n)/2] (2 (-1 + n) (n/(f V1))^((1 + n)/2) V1 - f (-3 + n) (n/V1)^((1 + n)/2) V1 Hypergeometric2F1[-1 + n, (3 + n)/2, n, 1 - f]) - 2 f (-1 + n) (n/V1)^((1 + n)/2) V1 Gamma[(5 + n)/2] Hypergeometric2F1[n, (5 + n)/2,1 + n, 1 - f])) == 0, {f, 1}]}, {n, 2., 10., 0.1}]]


FindRoot only gives one root, not all of them. To find the other, use a different initial guess:

V1 = 1;
ListPlot@Table[{n, f /. FindRoot[
V1/4 + (f V1)/4 + 1/(4 (-1 + n) Gamma[1/2 (-1 + n)]^2) n^(1/2 (-3 - n))
(f V1)^(1/2 (-1 + n)) ((-1 + n) n^(3/2) V1^(3/2) Gamma[1/2 (-1 + n)]^2 (2 Sqrt[f] (-1 + n) (n/(f V1))^(n/2)
- (1 + n) (n/V1)^(n/2) Hypergeometric2F1[1/2 (-1 + n), -1 + n, n, 1 - f]) -
2 (-1 + n)^2 Sqrt[n] (n/V1)^(n/2) V1^(3/2) Gamma[1/2 (-1 + n)] Gamma[(1 + n)/2] Hypergeometric2F1[n, (1 + n)/2, 1 + n, 1 - f]
+ (-5 + n) V1 Gamma[1/2 (-5 + n)] (n Gamma[(3 + n)/2] (2 (-1 + n) (n/(f V1))^((1 + n)/2) V1
- f (-3 + n) (n/V1)^((1 + n)/2) V1 Hypergeometric2F1[-1 + n, (3 + n)/2, n, 1 - f])
- 2 f (-1 + n) (n/V1)^((1 + n)/2) V1 Gamma[(5 + n)/2] Hypergeometric2F1[n, (5 + n)/2, 1 + n, 1 - f]))
== 0, {f, 6}]}
, {n, 2.001, 10.001, 0.1}] The error messages you saw arose because Gamma is ComplexInfinity, which happens with n == 3 and n == 5. I displaced n a little to avoid that.

If you're confident about the range of values you expect for the two roots, you can see them both this way:

expr[n_] := V1/4 + (f V1)/4 + 1/(4 (-1 + n) Gamma[1/2 (-1 + n)]^2) n^(1/2 (-3 - n)) (f V1)^(1/2 (-1 + n)) ((-1 + n) n^(3/2) V1^(3/2) Gamma[1/2 (-1 + n)]^2 (2 Sqrt[f] (-1 + n) (n/(f V1))^(n/2) - (1 + n) (n/V1)^(n/2) Hypergeometric2F1[1/2 (-1 + n), -1 + n, n,1 - f]) - 2 (-1 + n)^2 Sqrt[n] (n/V1)^(n/2) V1^(3/2) Gamma[1/2 (-1 + n)] Gamma[(1 + n)/2] Hypergeometric2F1[n, (1 + n)/2,1 + n, 1 - f] + (-5 + n) V1 Gamma[1/2 (-5 + n)] (n Gamma[(3 + n)/2] (2 (-1 + n) (n/(f V1))^((1 + n)/2) V1 - f (-3 + n) (n/V1)^((1 + n)/2) V1 Hypergeometric2F1[-1 + n, (3 + n)/2, n, 1 - f]) - 2 f (-1 + n) (n/V1)^((1 + n)/2) V1 Gamma[(5 + n)/2] Hypergeometric2F1[n, (5 + n)/2, 1 + n, 1 - f]));

With[{V1 = 1},
r = Table[
{n, f /. FindRoot[expr[n] == 0, {f, 1}], f /. FindRoot[expr[n]== 0, {f, 10}]},
{n, Complement[Range[2, 10, .1], {3., 5.}]}]];

ListPlot[{r[[All, {1, 2}]], r[[All, {1, 3}]]}] 