Find all complex root in a region
- To: mathgroup at smc.vnet.net
- Subject: [mg38067] Find all complex root in a region
- From: mutte75 at hotmail.com (Massimiliano Casaletti)
- Date: Thu, 28 Nov 2002 14:09:43 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Hi all,
i have to find all the roots in a region of this equation for a sweep
of value in w :
function[z_,w_]:=Module[{k0,sl},k0=w/(3*10^8);sl=(Sqrt[k0^2-z^2])/(377*k0)-(I*Sqrt[e*k0^2-z^2])/(377*k0*Tan[o*Sqrt[e*k0^2-z^2]])+I
w a (1 - b t w^2)/((1 - b t w^2)*(1 - g a w^2) - b a w^2)];
where a,b,g,t,o,e are costs:
o=0.00406
e=1.001
b=0.048*10^(-9)
t=0.4521*10^(-12)
g=0.396*10^(-9)
a=0.176*10^(-12)
I've tried with the following function posted by Selwyn Hollis:
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)&]
]
It works fine with some function but not with the mine.
Does anybody know how to change it, to make it works fine?
Thanks,
Massimiliano Casaletti
P.S. Sorry for my english