Re: Searching list for closest match to p
- To: mathgroup at smc.vnet.net
- Subject: [mg79595] Re: Searching list for closest match to p
- From: mcmcclure at unca.edu
- Date: Tue, 31 Jul 2007 05:59:41 -0400 (EDT)
- References: <f81m5q$ll1$1@smc.vnet.net>
I'm surprised that no one has mentioned Nearest, which is new to V6. Here's a solution to the problem as originally posted. z0 = Exp[Pi*I/3]; series = Normal[Series[Log[1 + z], {z, 0, 100}]]; seq = Flatten[Table[ Nearest[z /. NSolve[Take[series, n] == 0, z, WorkingPrecision -> 20], z0], {n, 1, 100}]]; ListPlot[{Re[#], Im[#]} & /@ seq, Epilog -> {Circle[{0, 0}, 1], Red, PointSize[0.03], Point[{Re[z0], Im[z0]}]}, AspectRatio -> Automatic, PlotRange -> 1.3] You will note that this is slower than Peter's code but it runs a shade faster, if you remove the WorkingPrecision option of NSolve. Of course, then some numerical inaccuracies creep in. On the other hand, given the correct statement of the theorem as mentioned by Dan and Andrzej, it might make more sense to simply illustrate the entire circle as the set of limit points. ListPlot[{Re[#], Im[#]} & /@ (z /. NSolve[Normal[Series[Log[1 + z], {z, 0, 200}]] == 0, z, WorkingPrecision -> 20]), Epilog -> Circle[{0, 0}, 1], AspectRatio -> Automatic] Mark