Re: Re: FindRoot anomaly (example from Mathematica

*To*: mathgroup at smc.vnet.net*Subject*: [mg72221] Re: [mg72201] Re: [mg72118] FindRoot anomaly (example from Mathematica*From*: Carl Woll <carlw at wolfram.com>*Date*: Fri, 15 Dec 2006 07:05:50 -0500 (EST)*References*: <200612131138.GAA23570@smc.vnet.net> <200612141049.FAA00623@smc.vnet.net>

gardyloo wrote: >And yet the solutions you get from that FindRoot are mostly incorrect. >Apparently, the default method that FindRoot is using gets hung up when >Cos[x] is approximately +/- 1 (after all, the Newton's method is >expected to go wonky at these particular points). So, for example, the >"root" x->56.542772508541205` (just to pick one at random) does NOT >satisfy the original equation. > Ersek's RootSearch function finds only seven roots to the equation >between x = 1 and x = 100: > >sol = RootSearch[3*Cos[x] == Log[x], {x, 1, 100}] > >{{x -> 1.447258617277903}, {x -> 5.301987341712279}, > {x -> 7.13951454299577}, {x -> 11.970165552607465}, > {x -> 13.10638768062491}, {x -> 18.624716143898215}, > {x -> 19.0387370100137}} > > > An alternative method is possible using IntervalBisection: Needs["NumericalMath`IntervalRoots`"] IntervalBisection[3*Cos[x]-Log[x], x, Interval[{0,Infinity}], 10^-6, MaxRecursion->30] Interval[{1.44726, 1.44726}, {5.30199, 5.30199}, {7.13951, 7.13951}, {11.9702, 11.9702}, {13.1064, 13.1064}, {18.6247, 18.6247}, {19.0387, 19.0387}] The nice thing about IntervalBisection is that we were able to use an initial range of {0,Infinity} instead of {1,100}. The other nice thing about IntervalBisection is that we are guaranteed that all roots lie in the interval given in the result, something that is not true with RootSearch. The price you pay is that the only transcendental functions allowed in the input are trigonometric/exponential functions and their inverses, i.e., only functions which support Interval arguments. Carl Woll Wolfram Research >Possibly ( I haven't tried it) forcing FindRoot to use the secant method >by supplying different starting conditions might make for a more >stringent search. > > Regards, > C.O. > >howardfink at gmail.com wrote: > > >>FindRoot[3Cos[x] == Log[x], {x, 1}] is on page 12 of the tutorial that >>starts up in Mathematica 5. >>I was interested in how the seed affects the answer, so I made a table >> >>sol = Table[FindRoot[3Cos[x] == Log[x], {x, b}], {b, 100}]; >> >>and then plotted the solutions >> >>ListPlot[x /. sol] >> >>I got a nice table, but the seed of 22 returns {x -> -207.932 + >>1.39227 i]} >> >>so the plot returns the error: >>Graphics::gptn: Coordinate -207.932 + 1.39227\\[ImaginaryI] in {22, >>-207.932 \ >>+ 1.39227\\[ImaginaryI]} is not a floating-point number. >> >>The other 99 results make a nice plot. >> >> >> >> >> > > >

**References**:**FindRoot anomaly (example from Mathematica Tutorial)***From:*howardfink@gmail.com

**Re: FindRoot anomaly (example from Mathematica Tutorial)***From:*gardyloo <gardyloo@mail.wsu.edu>