更新时间:2023-02-26 16:24:48
我看到的主要问题是你是否真的可以找到所有根——正如评论中已经提到的那样,这并不总是可能的.如果你确定你的函数不是完全病态的(sin(1/x)
已经提到过),下一个是你对丢失一个或几个根的容忍度.换句话说,它是关于你准备走多长时间以确保你没有错过任何一个——据我所知,没有通用的方法来为你隔离所有的根,所以你必须自己做.你展示的已经是合理的第一步.一些评论:
The main problem I see with this is if you can actually find all roots --- as have already been mentioned in comments, this is not always possible. If you are sure that your function is not completely pathological (sin(1/x)
was already mentioned), the next one is what's your tolerance to missing a root or several of them. Put differently, it's about to what length you are prepared to go to make sure you did not miss any --- to the best of my knowledge, there is no general method to isolate all the roots for you, so you'll have to do it yourself. What you show is a reasonable first step already. A couple of comments:
x_1
和 x_2
,在区间 [x_1+epsilon> 中再次运行搜索, x_2-epsilon]
.继续直到找不到更多的根(布伦特的方法保证收敛到 a 根,前提是有一个).x
不要只检查 f(x)
很大,检查一下,例如|f(x-epsilon/2)|>|f(x-epsilon)| 用于 epsilon
的几个值(1e-8、1e-9、1e-10 之类的).x_e
,检查 f 的值(x_e)
.x_1
and x_2
, run the search again in the interval [x_1+epsilon, x_2-epsilon]
. Continue until no more roots are found (Brent's method is guaranteed to converge to a root, provided there is one). x
don't just check that f(x)
is large, check that, e.g. |f(x-epsilon/2)| > |f(x-epsilon)|
for several values of epsilon
(1e-8, 1e-9, 1e-10, something like that).x_e
, check the value of f(x_e)
.