Re: Finding many complex roots
- To: mathgroup at smc.vnet.net
- Subject: [mg37777] Re: [mg37757] Finding many complex roots
- From: Selwyn Hollis <selwynh at earthlink.net>
- Date: Tue, 12 Nov 2002 03:13:50 -0500 (EST)
- References: <200211111010.FAA16126@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Marco, Here a piece of code that might do what you want. It's hardly an elegant solution, but it works fairly well. This indicates the arguments (and the name suggests the method): shotgun[ fn, {z, z1, z2, dz}, tol, fuzz] It returns a list of zeros of fn in the rectangle whose lower-left and upper-right corners are z1 and z2. I hope the other arguments are explained by the comments within the code. shotgun[fn_, {z_Symbol, z1_?NumericQ, z2_?NumericQ, dz_?NumericQ}, tol_?NumericQ, fuzz_?NumericQ]:= Module[{gridpts,shot,solns}, (* Construct a list of grid points. The mesh size is dz.*) gridpts = Table[x + I*y, {x,Re[z1],Re[z2],dz}, {y,Im[z1],Im[z2],dz}]; (* It's a bit faster if we compile Abs[fn]. *) fc = Compile[{{z,_Complex,2}}, Abs[fn]]; (* Keep only the grid points where Abs[fn] < tol. *) starters = Extract[gridpts, Position[fc[gridpts], _?(#<tol&)]]; (* Map FindRoot through the list of starting points.*) shot = Chop@FindRoot[fn,{z,#}]&/@starters; (* Sort by magnitude and remove "repetitions". A "repetition" occurs when consecutive solutions differ by less than fuzz. *) solns = Sort[shot,(Abs[z/.#1] < Abs[z/.#2])&]; solns = First/@Split[solns,(Abs[(z/.#1)-(z/.#2)] < fuzz)&]; (* Sort again and remove "repetitions". *) First/@Split[Sort[solns],(Abs[(z/.#1)-(z/.#2)] < fuzz)&] ] Example: This seems to catch all the zeros of Sin[Sin[Sin[z]]] in the rectangle 0<=Re[z]<=Pi, 0<=Im[z]<=2: shotgun[ Sin[Sin[Sin[z]]], {z, 0, Pi+2*I, .01}, .2, 10^(-5)] Of course, being "sure" that all the zeros are found will require some experimenting with the parameters. ---- Selwyn Hollis Marco wrote: > Hi, > I have to find many complex roots of complex function like > f[z]=0 where z is complex. > I try first the graphical approch: > ImplicitPlot[{Re[f[a+ Ib]]==0,Im[f[a+I b]]==0},{a,amin,amax},{b,bmin,bmax}] > or somethink else, and it works good and I visualize the solution in the > specificated region. > Now I'd like to compute the finding automaticaly. > I' seen other posts which illustrates how find many roots of real function > of real varible but I'm unable to genaralize in 2D case. > Some one can help me? > > P.S. sorry for my english > > Thanks x1000 > > > > >
- References:
- Finding many complex roots
- From: "Marco" <caiazzo@ieee.org>
- Finding many complex roots