Wolfram mathematica Mathematica:FindRoot错误

Wolfram mathematica Mathematica:FindRoot错误,wolfram-mathematica,equation-solving,Wolfram Mathematica,Equation Solving,收敛到解决方案{x->-0.0918521},但如何让Mathematica在解决方案之前避免以下错误消息: FindRoot[ 27215. - 7.27596*10^-12 x + 52300. x^2 - 9977.4 Log[1. - 1. x] == 0 , {x, 0.000001} ] In[30]:= x /. Table[FindRoot[ 27215. - 7.27596*10^-12 x + 52300. x^2 - 9977.4 Log[1. - 1.

收敛到解决方案
{x->-0.0918521}
,但如何让Mathematica在解决方案之前避免以下错误消息:

FindRoot[
 27215. - 7.27596*10^-12 x + 52300. x^2 - 9977.4 Log[1. - 1. x] == 0
 , 
 {x, 0.000001}
]
In[30]:= x /. 
 Table[FindRoot[
   27215. - 7.27596*10^-12 x + 52300. x^2 - 9977.4 Log[1. - 1. x] == 
    0, {x, y}], {y, -0.01, 0.01, 0.0002}]



During evaluation of In[30]:= FindRoot::nlnum: The function value {Indeterminate} is not a list of numbers with dimensions {1} at {x} = {1.}. >>

During evaluation of In[30]:= FindRoot::nlnum: The function value {Indeterminate} is not a list of numbers with dimensions {1} at {x} = {1.}. >>

During evaluation of In[30]:= FindRoot::nlnum: The function value {Indeterminate} is not a list of numbers with dimensions {1} at {x} = {1.}. >>

During evaluation of In[30]:= General::stop: Further output of FindRoot::nlnum will be suppressed during this calculation. >>

During evaluation of In[30]:= FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances. >>

During evaluation of In[30]:= FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances. >>

During evaluation of In[30]:= FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances. >>

During evaluation of In[30]:= General::stop: Further output of FindRoot::lstol will be suppressed during this calculation. >>

Out[30]= {-0.0883278, -0.0913649, -0.0901617, -0.0877546, -0.0877383, \
-0.088508, -0.0937041, -0.0881606, -0.0912122, -0.0899562, \
-0.0876965, -0.0879619, -0.0877441, -0.101551, -0.0915088, \
-0.0880611, -0.0959972, -0.0930364, -0.0902243, -0.0877198, \
-0.0881157, -0.107205, -0.103746, -0.100439, -0.0972646, -0.094208, \
-0.0912554, -0.0878633, -0.089473, -0.0884659, -0.0876997, \
-0.0876936, -0.0879112, -0.104396, -0.100987, -0.0976638, -0.0879892, \
-0.087777, -0.0881334, -0.0880071, -0.0880255, -0.0880285, \
-0.0880345, -0.0911966, -0.0879797, -0.0890295, -0.087701, \
-0.0952537, -0.0941312, -0.0929994, -0.0918578, -0.0885677, \
-0.0895444, -0.0883719, -0.103914, -0.102701, -0.0885007, -0.0915083, \
-0.098988, -0.0963068, -0.0891533, -0.0907357, -0.0881215, \
-0.0893928, -0.108191, -0.104756, -0.101456, -0.0982737, -0.0951949, \
-0.0922072, -0.0892996, -0.0878794, -0.0877164, -0.0896659, \
-0.0886859, -0.0876952, -0.0909219, -0.0899049, -0.0888758, \
-0.0878343, -0.0952044, -0.0941281, -0.0887345, -0.0919322, \
-0.0886726, -0.0876955, -0.0877232, -0.0878879, -0.0877578, \
-0.101642, -0.0916633, -0.0991254, -0.0877255, -0.0936139, \
-0.0907846, -0.0877205, -0.0877454, -0.0881589, -0.0893507, \
-0.0878747, -0.0876961}
我正在使用FindRoot解决一些相当混乱的表达式。我有时也会收到以下错误,尽管Mathematica仍然会给出答案,但我想知道是否有办法避免它:

FindRoot::nlnum: The function value {Indeterminate} is not a list of numbers with dimensions {1} at {x} = {1.}. >>

这个方程没有真正的解。Mathematica最终得到了接近函数最小值的结果,并报告了这一点,因为这是算法收敛的地方

FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances. >> 

Mathematica确实警告过您:

Plot[27215. - 7.27596*10^-12 x + 52300. x^2 - 9977.4 Log[1. - 1. x],
 {x, -2, 0.09}, AxesOrigin -> {0, 0}]

您得到的解决方案不是实际的解决方案。该消息表示有问题,并且
FindRoot
返回
x
的最后一个值。这是
FindRoot
的“更多信息”下的最后一项:

  • 如果FindRoot未能成功找到符合您在
    MaxIterations
    步骤中指定精度的解决方案,它将返回找到的解决方案的最新近似值。然后可以再次应用FindRoot,并以此近似值为起点
例如,在这种情况下,也没有解决方案:

FindRoot[
 27215. - 7.27596*10^-12 x + 52300. x^2 - 9977.4 Log[1. - 1. x] == 0
 , 
 {x, 0.000001}
]
In[30]:= x /. 
 Table[FindRoot[
   27215. - 7.27596*10^-12 x + 52300. x^2 - 9977.4 Log[1. - 1. x] == 
    0, {x, y}], {y, -0.01, 0.01, 0.0002}]



During evaluation of In[30]:= FindRoot::nlnum: The function value {Indeterminate} is not a list of numbers with dimensions {1} at {x} = {1.}. >>

During evaluation of In[30]:= FindRoot::nlnum: The function value {Indeterminate} is not a list of numbers with dimensions {1} at {x} = {1.}. >>

During evaluation of In[30]:= FindRoot::nlnum: The function value {Indeterminate} is not a list of numbers with dimensions {1} at {x} = {1.}. >>

During evaluation of In[30]:= General::stop: Further output of FindRoot::nlnum will be suppressed during this calculation. >>

During evaluation of In[30]:= FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances. >>

During evaluation of In[30]:= FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances. >>

During evaluation of In[30]:= FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances. >>

During evaluation of In[30]:= General::stop: Further output of FindRoot::lstol will be suppressed during this calculation. >>

Out[30]= {-0.0883278, -0.0913649, -0.0901617, -0.0877546, -0.0877383, \
-0.088508, -0.0937041, -0.0881606, -0.0912122, -0.0899562, \
-0.0876965, -0.0879619, -0.0877441, -0.101551, -0.0915088, \
-0.0880611, -0.0959972, -0.0930364, -0.0902243, -0.0877198, \
-0.0881157, -0.107205, -0.103746, -0.100439, -0.0972646, -0.094208, \
-0.0912554, -0.0878633, -0.089473, -0.0884659, -0.0876997, \
-0.0876936, -0.0879112, -0.104396, -0.100987, -0.0976638, -0.0879892, \
-0.087777, -0.0881334, -0.0880071, -0.0880255, -0.0880285, \
-0.0880345, -0.0911966, -0.0879797, -0.0890295, -0.087701, \
-0.0952537, -0.0941312, -0.0929994, -0.0918578, -0.0885677, \
-0.0895444, -0.0883719, -0.103914, -0.102701, -0.0885007, -0.0915083, \
-0.098988, -0.0963068, -0.0891533, -0.0907357, -0.0881215, \
-0.0893928, -0.108191, -0.104756, -0.101456, -0.0982737, -0.0951949, \
-0.0922072, -0.0892996, -0.0878794, -0.0877164, -0.0896659, \
-0.0886859, -0.0876952, -0.0909219, -0.0899049, -0.0888758, \
-0.0878343, -0.0952044, -0.0941281, -0.0887345, -0.0919322, \
-0.0886726, -0.0876955, -0.0877232, -0.0878879, -0.0877578, \
-0.101642, -0.0916633, -0.0991254, -0.0877255, -0.0936139, \
-0.0907846, -0.0877205, -0.0877454, -0.0881589, -0.0893507, \
-0.0878747, -0.0876961}
您将得到一个
FindRoot::jsing
警告,Mathematica返回
{x->0.}
(这是最新的近似值)

类似的情况如下,但具有
Log
功能:

FindRoot[x^2 + 1 == 0, {x, 1}]
给出与您看到的内容类似的
FindRoot::nlnum
,并返回
{x->0.000269448}
(这是本例中最新的近似值)

这是一个相同功能的图,用于说明:

如果您想包含复杂的根,请考虑文档的这部分内容:<代码> FindRoot <代码>(在“更多信息”下):

  • 您可以通过将0.I添加到起始值来告诉FindRoot搜索复数根
例如,可以在一个复数根附近取一个起始值,如下所示:

FindRoot[1 + Log[1 + x]^2 == 0, {x, 2}]
它(没有消息)聚合到
{x->8.46358*10^-23+1.I}
(因此基本上
I

或者在另一个复数根附近有一个起始值:

FindRoot[x^2 + 1 == 0, {x, 1 + 1. I}]

你基本上会得到
-I
(准确地说,你得到
{x->8.46358*10^-23-1.I}
)。

你尝试过不同的起点吗?这实际上不是一个解决方案,是吗?看起来这个方程没有(真实的)解。(不知道为什么Mathematica会给你一个。)同意@Jefromi,你得到的是一个数字,但这不是一个解决方案。似乎没有真正的解决办法。您可以使用评估监视器跟踪正在发生的事情,我认为您可能会发现剧烈振荡,直到它吐出这个数字,甚至没有打印警告!(OP担心的问题可能可以通过指定搜索范围来避免,不包括日志爆炸的位置。)我猜无论何时使用FindRoot,您都必须手动检查它提供给您的是否是解决方案?实际上它会打印警告-抱歉,我只是没有复制它们。