Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: sorting list of roots af a transcendental function

  • To: mathgroup at
  • Subject: [mg65283] Re: sorting list of roots af a transcendental function
  • From: "David W. Cantrell" <DWCantrell at>
  • Date: Fri, 24 Mar 2006 00:59:40 -0500 (EST)
  • References: <dvu43i$866$>
  • Sender: owner-wri-mathgroup at

"David Park" <djmp at> 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

> 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
> From: Dule [mailto:dule23 at]
To: mathgroup at
> 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}]


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}]


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.

David Cantrell

  • Prev by Date: Re: A question concerning Show and PlotLegend
  • Next by Date: Re: Plot equations and inequalities together
  • Previous by thread: Re: Re: sorting list of roots af a transcendental function
  • Next by thread: How to sample a 2-dim. r.v. with known density function?