Re: FindRoots?
- To: mathgroup at smc.vnet.net
- Subject: [mg112136] Re: FindRoots?
- From: Andrzej Kozlowski <akozlowski at gmail.com>
- Date: Wed, 1 Sep 2010 06:28:41 -0400 (EDT)
On 31 Aug 2010, at 10:17, David Park wrote:
> True, Sin[1/x] will eventually break any root finding algorithm because we
> will always run out of time or space to store the answers if we push too
> close to zero.
>
> However, this does provide a good example to show how well Ted's algorithm
> works. In this case the exact roots are 1/(n Pi) where n is a positive
> interger that runs between limits that span the region we are searching.
>
> So, let's try some cases numerically. To search for roots between 0.01 and
> 0.1 n runs from 4 to 21 and there are 28 roots. Here are the results from
> RootSearch.
>
> Needs["Ersek`RootSearch`"]
>
> RootSearch[Sin[1/x] == 0, {x, 0.01, 0.1}]
> Length[%]
>
> {{x -> 0.0102681}, {x -> 0.0106103}, {x -> 0.0109762}, {x ->
> 0.0113682}, {x -> 0.0117893}, {x -> 0.0122427}, {x ->
> 0.0127324}, {x -> 0.0132629}, {x -> 0.0138396}, {x ->
> 0.0144686}, {x -> 0.0151576}, {x -> 0.0159155}, {x ->
> 0.0167532}, {x -> 0.0176839}, {x -> 0.0187241}, {x ->
> 0.0198944}, {x -> 0.0212207}, {x -> 0.0227364}, {x ->
> 0.0244854}, {x -> 0.0265258}, {x -> 0.0289373}, {x ->
> 0.031831}, {x -> 0.0353678}, {x -> 0.0397887}, {x ->
> 0.0454728}, {x -> 0.0530516}, {x -> 0.063662}, {x -> 0.0795775}}
>
> 28
>
> For the domain from 0.001 to 0.01 n runs from 32 to 318 and there are 287
> roots.
>
> RootSearch[Sin[1/x] == 0, {x, 0.001, 0.01}, InitialPrecision :> 40,
> InitialSamples -> 5000, MaxBrentSteps -> 1000,
> MaxSecantSteps -> 1000, PrecisionGoal :> 10];
> Length[%]
>
> 287
>
> For the domain from 0.0001 to 0.001 n runs from 319 to 3183 and there are
> 2865 roots. RootSearch took about 20 minutes on this. (I'm not certain if I
> picked optimum values for the parameters to get the best efficiency.)
>
> results3 =
> RootSearch[Sin[1/x] == 0, {x, 0.0001, 0.001},
> InitialPrecision :> 40, InitialSamples -> 30000,
> MaxBrentSteps -> 1000, MaxSecantSteps -> 1000, PrecisionGoal :> 10];
> Length[%]
>
> 2865
>
> I would consider this pretty good performance.
>
Perhaps. But note that:
sols =
N[Reduce[Sin[1/x] == 0 && 10^-4 < x < 10^-3, x], 10]; // Timing
{2.88873,Null}
Length[List @@ sols]
2865
So what do you need RootSearch for?
Andrzej Kozlowski