Re: Searching list for closest match to p
- To: mathgroup at smc.vnet.net
- Subject: [mg79301] Re: Searching list for closest match to p
- From: Peter Pein <petsie at dordos.net>
- Date: Tue, 24 Jul 2007 06:01:01 -0400 (EDT)
- References: <f81m5q$ll1$1@smc.vnet.net>
chuck009 schrieb: > I'm working on an interesting theorem in Complex Analysis called Jentzsch's Theorem in which the zeros of the partial sums of a Taylor series for an analytic function in the unit disk, all converge to values on the unit disk. So I choose a point on the unit disk, p=Cos[pi/3]+iSin[pi/3], calculate the normal series for f[x]=Log[1+x] for n ranging from 1 to 100, calculate the zeros, then for each polynomial, search the zeros for the one closest to the point. Here's my code. I feel the Table part is messy with the First[First[Position... construct in it. Can anyone recommend a more concise way of searching the zero lists and finding the one closest to p3? > > Thanks, > > > p3color = Red; > p3 = Cos[Pi/3] + I*Sin[Pi/3]; > > p3mintable = > Table[zlist = x /. N[Solve[Normal[Series[Log[1 + x], {x, 0, nval}]] == 0], > 6]; minz = zlist[[First[First[Position[mins = (Abs[#1 - p3] & ) /@ > zlist, Min[mins]]]]]], {nval, 1, 100}]; > > p3vals = ({Re[#1], Im[#1]} & ) /@ p3mintable; > > lp3 = ListPlot[p3vals, PlotRange -> {{-1.4, 1.4}, {-1.4, 1.4}}, > AspectRatio -> 1]; > > Show[{lp3, Graphics[{p3color, PointSize[0.03], Point[{Re[p3], Im[p3]}]}], > Graphics[Circle[{0, 0}, 1]]}] > Hi Chuck, if I undersand you correctly, your problem with Position[[1,1]] is of esthetical nature? Maybe this version using Pick[] is more pleasant? p3color = Red; circleColor = Blue; p3 = Exp[I*Pi/3]; s100 = SeriesCoefficient[Series[Log[1 + x], {x, 0, 100}], #]x^# & /@ Range[100]; p3vals = Through[{Re, Im}[#]] & @@@ Table[ zlist = x /. NSolve[Total[Take[s100, nval]] == 0]; Pick[zlist, #, Min[#]] &[Abs[zlist - p3]], {nval, 100}]; lp3 = ListPlot[p3vals, PlotRange -> All, AspectRatio -> Automatic, Epilog -> {circleColor, Circle[{0, 0}, 1, {0, Pi/2}], p3color, PointSize[.03], Point[Through[{Re, Im}[p3]]]}] Peter