Mathematica 上修正牛顿拉夫森法的问题

Problem with Modified Newton Raphson method on Mathematica

我正在尝试使用修改后的 newton raphson 方法求函数的根,但是在第二次迭代时 xi+1 的值爆炸到 -393,它不是应该更接近预期吗根的价值? (即 0.34997)。此外,我正在尝试获取 "error" 低于 "eS" 标准的根。请帮忙

n = 50;
eS = 10^-4;
f[x_] := (x^2 - 10 x + 25) (x - Exp[-3 x])
Plot[f[x], {x, -1, 2}]
xi = 0.5;
Do[
 f[xi]; f'[xi]; f''[xi];
 xi1 = xi - (f[xi]*f'[xi]/(f'[xi])^2 - f[xi]*f''[xi]);
 If[Abs[f[xi]] < 10^-7,
  Print["The root is approx= ", xi1 // N, " iterations needed: ", i];
  Break[]];
 eA = Abs[(xi1 - xi)/xi1];
 If[eA < eS,
  Print["The root is approx= ", xi1 // N, " iterations needed: ", i];
  Break[]];
 xi = xi1;
 If[i == n, Print["Did not converge in ", n, " iteration(s)"]];
 , {i, 1, n}
 ]

有许多不同的"Modified Newton Raphson"方法。我比较熟悉的是

u[x_] := f[x]/f'[x]

Do[
 xi1 = xi - u[xi]/u'[xi];
 If[Abs[f[xi]] < 10^-7, 
  Print["The root is approx= ", xi1 // N, " iterations needed: ", i];
  Break[]];
 eA = Abs[(xi1 - xi)/xi1];
 If[eA < eS, 
  Print["The root is approx= ", xi1 // N, " iterations needed: ", i];
  Break[]];
 xi = xi1;
 If[i == n, Print["Did not converge in ", n, " iteration(s)"]];, {i, 1, n}]

这是一个更实用的方法(没有 Do 循环)

FixedPointList[# - u[#]/u'[#] &, .5]
(* {0.5, 0.372215, 0.350544, 0.34997, 0.34997, 0.34997, 0.34997} *)