Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

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

Search the Archive

Re: Optimizing fixed point iteration

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83128] Re: Optimizing fixed point iteration
  • From: m.r at inbox.ru
  • Date: Mon, 12 Nov 2007 05:14:05 -0500 (EST)
  • References: <fh1ckb$csj$1@smc.vnet.net>

On Nov 9, 4:26 am, Yaroslav Bulatov <yarosla... at gmail.com> wrote:
> Can anyone see the trick to speed up the following code significantly?
>
> depth;step=.02;
> Table[(c = 0;
>    NestWhile[-4 (# - a) (# - b) &, .51, (c++; Abs[#1 - #2] > .1) &, 2,
>      depth]; c), {a, -1., 0., step}, {b, 0., 1., step}] // ArrayPlot
>
> This makes a plot of the number of iterations needed for the quadratic
> fixed point iterations to converge, as a function of quadratic
> parameters, however it's too slow to get sufficient granularity

Here's a compiled version:

f = Compile[{a, b, {d, _Integer}},
  Module[{c = 1, x = .51, x2},
   While[x2 = -4 (x - a) (x - b); c < d - 1 && Abs[x - x2] > .1,
    If[Abs[x] > 1.5, Return[d - 1]];
    c++; x = x2];
   c]]

DynamicModule[{d = 50, u, gr},
 gr = Graphics[Raster[
    Reverse[
     d - 1 - Table[f[a, b, d], {a, -1, 0, .001}, {b, 0, 1, .001}]],
    {{0, 0}, {1, 1}}, Dynamic@{u, d - 1}]];
 Manipulate @@ {gr, {u, 1, d - 2, 1}}
 ]

Maxim Rytin
m.r at inbox.ru



  • Prev by Date: Re: Optimizing fixed point iteration
  • Next by Date: Latex export in 6.0 problems
  • Previous by thread: Re: Optimizing fixed point iteration
  • Next by thread: Functional Integration