So I know that trigonometric equations show up here very often, but this one is particularly difficult and important to me, so that I was hoping to get some valuable hints from people who know more about equation solving than I do.
I would like to solve the following equations: $$f(x)=\sqrt{a \left(c^2-b \left(c^2+x^2\right)\right)+\left(c^2+x^2\right) \left((b-1) c^2+b x^2-e\right)}/\sqrt{-a+c^2+x^2}$$ $$x \cot (x\,d)=-f(x) \cot (f(x)\,d)$$ or in code form:
f[x_] = Sqrt[(c^2 + x^2) ((-1 + b) c^2 - e + b x^2) + a (c^2 - b (c^2 + x^2))]/Sqrt[-a + c^2 + x^2]
x Cot[x d] == -f[x] Cot[f[x] d]
where a, b, c, d and e are arbitrary constants which can become very small (~1e-30) or very large (~1e30).
I tried FindRoot[], which works very well for constants of the order of ~1e0 to ~1e1 but breaks down for extremely big or small numbers. In particular, I find multiple duplicates, and solutions that do not actually solve the equation above. To make the code more stable, I squared both sides of the second equation (the roots don't change), as FindRoot[] converges quicker for positive functions. Furthermore, looking at the graphs for the RHS and LHS of the second equation, one can see that the cotangent has a $\pi$-periodicity which helps determining the range in which FindRoot is supposed to look for solutions:
FR[n_] := FindRoot[(x Cot[x d])^2 == (-f[x] Cot[f[x] d])^2, {x,Pi*n/4 - 0.001, Pi*(n + 1)/4 - 0.001}]
sol = Map[FR, Range[0, 50, 1]];
p1 = Plot[{x Cot[x d],-f[x] Cot[f[x] d]}, {x, 1, 40}];
p2 = ListPlot[Transpose[{x /. sol, x Cot[x d] /. sol}]];
Show[p1, p2, PlotRange -> Automatic]
Unfortunately, this does not work so smoothly for extreme values such as
a = 10^14; b = 10^(-18); c = 10^6; d = 10; e = 10^(-18);
Could someone tell me how I can make this code more stable or suggest an alternative way of solving this equation?