Re: Re: Find many Roots
- To: mathgroup at smc.vnet.net
- Subject: [mg32107] Re: [mg32103] Re: Find many Roots
- From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
- Date: Thu, 27 Dec 2001 03:34:08 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
In fact in this particular case one does not really need to look at the graph. It is enough to observe that function: f[x_] := Tan[x] - 1/x is undefined at In[2]:= l=Prepend[Table[(k*Pi)/2,{k,1,24/Pi,2}],0] Out[2]= {0, Pi/2, (3*Pi)/2, (5*Pi)/2, (7*Pi)/2} Moreover it's derivative: In[3]:= D[f[x],x] Out[3]= 1/x^2 + Sec[x]^2 is strictly positive wherever the function is defined. It follows that there can be just a single root in each of the open intervals that make up the domain. Thus we can find all the roots as follows: In[4]:= FindRoot[Evaluate[f[x]==0],{x,#}]&/@(Plus@@@Partition[N[l],2,1]/2) Out[4]= {{x -> 0.8603336747802416}, {x -> 3.4256184594916825}, {x -> 6.437298362730657}, {x -> 9.529334419122055}} Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ On Tuesday, December 25, 2001, at 01:44 PM, Tom Burton wrote: > Hello, > > On Mon, 24 Dec 2001 08:33:36 +0000 (UTC), in comp.soft- > sys.math.mathematica you wrote: > >> Tan[x]==1/x, {x,0,12}] > > For this particular problem, I would select: > > Step 1: Find the approximate roots visually: > > p1 = Plot[Tan[x]-1/x, {x,0,12}, PlotRange -> {-1,1}]; > > approx = {1, 3, 6, 10}; > > Step 2: Refine these approximations: > > answers = FindRoot[Tan[x] == 1/x, {x,#}] & /@ approx > > Step 3: Verify solutions > > (Tan[x] - 1/x) /. answers > > Step 4: Check for missing solutions > > Show[ p1, Graphics[{Hue[0], PointSize[0.03], Point[{x,0}] /. answers}] ] > > I higly recommend a visual method, but iff you need a more automated > method, I would suggest something like > > answers = FindRoot[Tan[x] == 1/x, {x,#}] & /@ Range[1,12] > > xx = Select[ > Union[ x /. answers, SameTest -> (Abs[#1-#2]<10^-6 &) ], > 0 <= # <= 12 &] > > Tom Burton > > >