Re: sorting list of roots af a transcendental function
- To: mathgroup at smc.vnet.net
- Subject: [mg65283] Re: sorting list of roots af a transcendental function
- From: "David W. Cantrell" <DWCantrell at sigmaxi.org>
- Date: Fri, 24 Mar 2006 00:59:40 -0500 (EST)
- References: <dvu43i$866$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"David Park" <djmp at earthlink.net> wrote: > Try using Ted Ersek's RootSearch from MathSource. I had supposed that someone would mention RootSearch. I see now that you and Paul Abbott did. Having never used RootSearch before myself, I thought that now would be a good time to give it a try. Please see my comments below. > Needs["Ersek`RootSearch`"] > func[a_] := Cot[x] == x/a - a/(4*x) > plotf[a_] := Cot[x] - (x/a - a/(4*x)) > > RootSearch[func[100], {x, 0.1, 50}] > > {{x -> 3.0209}, {x -> 6.04265}, {x -> 9.06603}, {x -> 12.0918}, {x -> > 15.1206}, {x -> 18.153}, {x -> 21.1895}, {x -> 24.2302}, {x -> > 27.2756}, {x -> 30.3255}, {x -> 33.3802}, {x -> 36.4395}, {x -> > 39.5034}, {x -> 42.5716}, {x -> 45.6441}, {x -> 48.7206}} > > Plot[plotf[100], {x, 0.1, 50}, > ImageSize -> 500] > > David Park > djmp at earthlink.net > http://home.earthlink.net/~djmp/ > > From: Dule [mailto:dule23 at gmx.de] To: mathgroup at smc.vnet.net > > Dear group, > > for calculating a model i need values for x which are given by the > transcendental function Cot[x] == x/a - a/(4*x). a is a parameter > 0<a<200. i obtained the roots with Table and FindRoot: > Table[FindRoot[Cot[x] == x/a - a/(4*x), {x, i}], {i, 1, 50}]] > > I have two questions: > 1. Is there a better way to do this? > 2. How can i construct a list, where the values for x, which appear > multiple are dropped? I'll assume that you're interested in the positive roots only. (But of course the negative roots can be obtained by symmetry from the positive ones, if desired.) If you plot Cot[x] and x/a - a/(4*x) for a few values of parameter a (say, 0.01, 1 and 100), it should be clear that your equation will have exactly one root in each open interval of the form (n Pi, (n+1) Pi), where n is a nonnegative integer. (This is due, among other things, to the periodicity of Cot[x].) Furthermore, when a is small, that root will be close to the left endpoint of that interval, and when a is large, that root will be close to the right endpoint. With this knowledge, your original idea can be modified very easily to get the roots when a = 0.01: a = 0.01; Table[FindRoot[Cot[x] == x/a - a/(4*x), {x, i}], {i, 10^-6, 50, Pi}] {{x->0.0999584},{x->3.14477},{x->6.28478},{x->9.42584},{x->12.5672}, {x->15.7086},{x->18.8501},{x->21.9916},{x->25.1331},{x->28.2747}, {x->31.4162},{x->34.5578},{x->37.6994},{x->40.8409},{x->43.9825}, {x->47.1241}} I was somewhat surprised that RootSearch did not find many of those roots: a = 0.01; RootSearch[Cot[x] == x/a - a/(4*x), {x, 10^-6, 50}] {{x->0.0999584},{x->3.14477},{x->6.28478},{x->12.5672}} But please bear in mind that I'm a complete novice at using RootSearch. There is probably some simple Option which can be changed so that it will find them all easily. It certainly found all the roots in the example given by David P. above with a = 100. Regards, David Cantrell