Cap*_*esh 3 wolfram-mathematica equation-solving
FindRoot[
27215. - 7.27596*10^-12 x + 52300. x^2 - 9977.4 Log[1. - 1. x] == 0
,
{x, 0.000001}
]
Run Code Online (Sandbox Code Playgroud)
收敛到解决方案{x -> -0.0918521}但是如何让Mathematica在解决方案之前避免以下错误消息:
FindRoot::nlnum: The function value {Indeterminate} is not a list of numbers with dimensions {1} at {x} = {1.}. >>
Run Code Online (Sandbox Code Playgroud)
我正在使用FindRoot来解决一些非常混乱的表达式.我有时也收到以下错误,虽然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. >>
Run Code Online (Sandbox Code Playgroud)
您获得的解决方案不是实际的解决方案.该消息表明出现了错误并FindRoot返回了最后一个值x.这是"更多信息"下的最后一项FindRoot:
MaxIterations步骤中指定的精度的解决方案,则会返回它找到的解决方案的最新近似值.然后,您可以再次应用FindRoot,并将此近似值作为起点.例如,在这种情况下,也没有解决方案:
FindRoot[x^2 + 1 == 0, {x, 1}]
Run Code Online (Sandbox Code Playgroud)
您将收到FindRoot::jsing警告并返回Mathematica{x -> 0.}(这是最近的近似值).
像这样的类似情况,但有一个Log功能:
FindRoot[1 + Log[1 + x]^2 == 0, {x, 2}]
Run Code Online (Sandbox Code Playgroud)
给出FindRoot::nlnum类似于您所看到和返回的内容{x -> 0.000269448}(在这种情况下,这是最近的近似值).
这是一个相同功能的图,用于说明目的:

如果要包含复杂的根,请考虑文档的这一部分FindRoot(在"更多信息"下):
因此,例如,您可以在一个复杂的根附近取一个起始值,如下所示:
FindRoot[x^2 + 1 == 0, {x, 1 + 1. I}]
Run Code Online (Sandbox Code Playgroud)
哪个收敛(没有消息){x -> 8.46358*10^-23 + 1. I}(基本上I).
或者在其他复杂根附近有一个起始值:
FindRoot[x^2 + 1 == 0, {x, 1 - 1. I}]
Run Code Online (Sandbox Code Playgroud)
基本上你会得到-I(准确地说你得到{x -> 8.46358*10^-23 - 1. I}).