# Solving an equation with the Brent method [closed]

How do I write correct code to use the Brent method to solve an equation? My code is

p[R_] := R/(1 + R); q[R_] := 1/(1 + R);
a = 0.001; t = 100;
e = 0.491;
al[g_] := ArcCos[(a * Cos[q[t] * Sinh[g]/(g/a - p[t])] - Cosh[g])];
FindRoot[
al[x] - 2 * Pi * e == a * Sin[al[x]]/(Cosh[x] + Cos[al[x]]),
{x, 0, 4},
Method -> "Brent"
]


I get the error message

FindRoot::bbrac: Method -> Brent is only applicable to univariate real functions and requires two real starting values that bracket the root.

## closed as off-topic by MarcoB, happy fish, gwr, Young, yohbsMar 22 '17 at 2:06

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, happy fish, gwr, Young, yohbs
If this question can be reworded to fit the rules in the help center, please edit the question.

• Try Plot[{al[x] - 2*Pi*e, a*Sin[al[x]]/(Cosh[x] + Cos[al[x]])}, {x, 0, 4}, PlotRange -> All]... – MikeLimaOscar Mar 17 '17 at 16:47
• Thanks but I need something different. How to write the script correctly. – user2272592 Mar 17 '17 at 16:53
• Look at where the lines cross in the plot. The upper limit of your bracket is two orders of magnitude above that point (and the values at higher x are tending to ±infinity) so try reducing the bracket, e.g. {x,0,0.04}. – MikeLimaOscar Mar 17 '17 at 16:56
• Ah, ok. That was working. Good luck – user2272592 Mar 17 '17 at 16:58

Your functions return complex values, hence the error message:

{al[x] - 2*Pi*e, a*Sin[al[x]]/(Cosh[x] + Cos[al[x]])} /. x -> 4

{0.05654866776461631 - 3.9999633557579153 I, 0. + 27.288916588244273 I}


You should restrict the range to the real domain:

FindRoot[al[x] - 2*Pi*e == a*Sin[al[x]]/(Cosh[x] + Cos[al[x]]), {x, 0, .04},
Method -> "Brent"]

{x -> 0.03464662602138138}
`