MathGroup Archive 2006

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

Search the Archive

Re: newton raphson plot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70530] Re: newton raphson plot
  • From: Peter Pein <petsie at dordos.net>
  • Date: Thu, 19 Oct 2006 03:21:37 -0400 (EDT)
  • References: <eh205p$2di$1@smc.vnet.net>

bjarke schrieb:
> Hi everyone.
> 
> We working on newton-raphson methods in mathematica. We want to plot the funktion f[z_] = z^3 - 1 how do we do it??
> 
> All help is good help :-)
> 

Hello,

maybe you had the following in mind:

In[6]:=
BasinsOfAttractionOfz3[zll_, zur_, w_, h_] :=
  Module[{grid = N[Table[x + I*y, {y, Im[zll], Im[zur], Im[zur - zll]/(h - 1)},
       {x, Re[zll], Re[zur], Re[zur - zll]/(w - 1)}]], z0 = z /. NSolve[z^3 -
1 == 0]},
   grid = FixedPoint[Compile[{{g, _Complex, 2}}, ((1/3)*(1/#1^2 + 2*#1) & )[
        Map[Piecewise[{{(Complex[Random[], Random[]])/10^5, #1 == 0}}, #1] & , g,
         {2}]]], grid, 256];
    Show[Graphics[RasterArray[Map[RGBColor @@ (Boole[#1 < 1/10^5] & ) /@
           Abs[z0 - #1] & , grid, {2}]]], AspectRatio -> Automatic, ImageSize
-> {w, h}]]
In[7]:=
BasinsOfAttractionOfz3[-1-I,1+I,500,500]//Timing
--- graphics omitted ---
Out[7]=
{15.078 Second,\[SkeletonIndicator]Graphics\[SkeletonIndicator]}

(without compilation the evaluation of In[7] lasts ~47 seconds)

Please excuse the malformatted posting. I am too lazy to edit this in the
email. It is InputForm => Copy/Paste should work. And I wrote it q&d.

There are surely a lot of possibilities to improve this code -
have fun, finding them ;-)

Peter


  • Prev by Date: Re: damped oscilations data fit
  • Next by Date: Re: "particle" sliding along a curve
  • Previous by thread: Re: newton raphson plot
  • Next by thread: A plot inside another plot