FindRoot Secant Method

*To*: mathgroup at smc.vnet.net*Subject*: [mg64866] FindRoot Secant Method*From*: "Marcelo Mayall" <mmayall at bol.com.br>*Date*: Mon, 6 Mar 2006 05:01:15 -0500 (EST)*Sender*: owner-wri-mathgroup at wolfram.com

FindRoot Strange Results, As mentioned in the Advanced Documentation, "the idea of the secant method is to use the slope of the line between two consecutive search points to compute the step instead of the derivative at the latest point": In[1]:= fcalls={}; f[x_?NumericQ]:=(AppendTo[fcalls,x];Cos[x]); FindRoot[f[x]==0,{x,0,2},Method->"Secant"] fcalls Out[2]= {x->1.57079632679} Out[3]= {0., 2., 1.9999999, 1.41228292, 1.41228296, 1.57390632, 1.57390631, 1.570783521, 1.570783522, 1.5707963268154, 1.5707963268150, 1.57079632679} With a symbolic function we have the same kind of solution: In[4]:= Reap[FindRoot[Cos[x]==0, {x,0,2}, EvaluationMonitor:>Sow[x], Method->"Secant"]] Out[4]= {{x->1.5708}, {{0., 2., 1.9999999, 1.41228292, 1.41228296, 1.57390632, 1.57390631, 1.570783521, 1.570783522, 1.5707963268154, 1.5707963268150, 1.5707963267948}}} However, looking at the structure of the iterations it seems that the Secant Method is calculating the derivatives at the latest point when it shouldn't. And this reduces significantly the efficiency of the code. I think that, for this simple example, the Secant Method should work in similar way as the Brent Method. In[5]:= Reap[FindRoot[Cos[x]==0, {x, 0, 2}, EvaluationMonitor:>Sow[x], Method->"Brent"]] Out[5]= {{x->1.5708},{{0.,2.,1.41228,1.57391,1.57078,1.5708,1.5708}}} Any Ideas ??? Marcelo Mayall