MathGroup Archive 2007

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

Search the Archive

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



  • Prev by Date: Re: Module inside Module. Conflict between inner Module local variable with outer module parameter
  • Next by Date: Is Save As->HTML broken in 6.0?
  • Previous by thread: Re: Re: Searching list for closest match to p
  • Next by thread: Re: New graphics primitive: "Curve"?