MathGroup Archive 2008

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

Search the Archive

Re: Find roots in a limited interval

  • To: mathgroup at smc.vnet.net
  • Subject: [mg86767] Re: Find roots in a limited interval
  • From: "David Park" <djmpark at comcast.net>
  • Date: Thu, 20 Mar 2008 02:56:46 -0500 (EST)
  • References: <frqpvr$5be$1@smc.vnet.net>

Viktor,

Ted Ersek has a very nice package called RootSearch that you can obtain from 
MathSource.

http://library.wolfram.com/infocenter/MathSource/4482/

Although the Mathematica FindRoot function is more general, RootSearch is by 
far better and more convenient for cases of searching for a root of a single 
real function within an interval. These are probably 95% of root finding 
cases and why WRI doesn't make this a standard part of Mathematica is beyond 
me. Here is an example. All you have to do is give the equation and the 
interval in which you want the roots and Ted's routine will find all the 
roots in the interval in order.

Needs["Ersek`RootSearch`"]

f[x_] := 1/2 Sinc[x] - 2 Sinc[3 x]

xroots = x /. RootSearch[f[x] == 0, {x, 0, 5}]
{0.848062,2.29353,3.14159,3.98965}

Using the Presentations package, the following plots the function, the roots 
as small filled circles and marks the root values along the x-axis along 
with faint vertical grid lines marking the root locations. In Presentations, 
one can make believe one is plotting in the complex plane and give point 
locations as simple complex numbers.

Needs["Presentations`Master`"]

With[
 {xticks = CustomTicks[Identity, databased[xroots]]},
 Draw2D[
  {Draw[f[x], {x, 0, 5}],
   {Gray, ComplexLine[{0, 5}]},
   ComplexCirclePoint[#, 3, Black, White] & /@ xroots},
  Frame -> True,
  FrameTicks -> {xticks, Automatic, xticks // NoTickLabels,
    Automatic},
  GridLines -> {CustomGridLines[Identity,
     databased@xroots, {LightGray}], None},
  PlotLabel -> Row[{"Roots of ", f[x]}],
  BaseStyle -> {FontSize -> 12},
  ImageSize -> 400]
 ]


-- 
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/


<viktor.albers at gmail.com> wrote in message news:frqpvr$5be$1 at smc.vnet.net...
> Dear all,
>
> Being a Mathematica beginner I struggle to find a solution to a fairly
> simple problem. I have a function (superposition of several weighted
> sinc functions) which in principle has infinitely many roots.
>
> However I am interested only in lets say roots that are to be found
> within the limited interval between 0 and 5.
>
> I tried to define a system of inequalities of the type
>
> Solve[f[t] && t>0 && t<5, t] but no success.
> I played around with the function Reduce but did not have any success
> and I am also not sure if this is the right way forward.
>
> So the question: Is it possible to define an interval in Mathematica
> in which I am looking for the roots?
>
> Thank you for your time.
>
> Regards,
> Viktor
>
> 



  • Prev by Date: Re: choose elements from list based on elements in different list
  • Next by Date: Re: choose elements from list based on elements in different list
  • Previous by thread: Re: Find roots in a limited interval
  • Next by thread: Exceptions Style Problem