此为 Mathematica 4 文档,内容基于更早版本的 Wolfram 语言
查看最新文档(版本11.2)

FindRoot

Usage

FindRoot[lhsEqualrhs,  x,   ] x= 开始搜索方程 lhsEqualrhs的数值解。


Notes

FindRoot[lhsEqualrhs,  x,   ,    ]   作为 x的前两个值搜索一个解。如果不能找到方程的符号导数时必须使用这种形式。
FindRoot[lhsEqualrhs,  x, xstart, xmin, xmax ]搜索一个解,如果 x 超出了xminxmax范围则停止搜索。
FindRoot[  ,  , ...  ,  x,   ,  y,   , ... ] 搜索联立方程  的一个数值解。
FindRoot 返回一个替换 x, y, ... 的列表,这种替换有从Solve获得的相同的形式
FindRoot 有属性 HoldAll.
• 如果仅指定 x的一个初始值, FindRoot用牛顿法搜索一个解。如果指定两个初始值,FindRoot 用割线的一个变体。
• 如果所有的方程和初始点都是实的,则FindRoot仅搜索实根。如果任何一个是复的,它也搜索复根。
• 可以通过加0. I 到初始值告诉FindRoot搜索复根。
• 给出了下面的选项:
"\!\(\*StyleBox[\"\\\"AccuracyGoal\\\"\", \"MR\"]\) ""\!\(\*StyleBox[\"\\\"Automatic\\\"\", \"MR\"]\) "精确搜索函数的根
"\!\(\*StyleBox[\"\\\"Compiled\\\"\", \"MR\"]\) ""\!\(\*StyleBox[\"\\\"True\\\"\", \"MR\"]\) "是否函数应当被编译
"\!\(\*StyleBox[\"\\\"DampingFactor\\\"\", \"MR\"]\) ""\!\(\*StyleBox[\"\\\"1\\\"\", \"MR\"]\) "牛顿法的阻尼系数
"\!\(\*StyleBox[\"\\\"Jacobian\\\"\", \"MR\"]\) ""\!\(\*StyleBox[\"\\\"Automatic\\\"\", \"MR\"]\) "系统的Jacobian
"\!\(\*StyleBox[\"\\\"MaxIterations\\\"\", \"MR\"]\) ""\!\(\*StyleBox[\"\\\"15\\\"\", \"MR\"]\) "使用的最大迭代数
"\!\(\*StyleBox[\"\\\"WorkingPrecision\\\"\", \"MR\"]\) ""\!\(\*StyleBox[\"\\\"$MachinePrecision\\\"\", \"MR\"]\) "用在内部计算的数字数目
AccuracyGoal的缺省设置是小于WorkingPrecision的 10 个数位。
• 如果FindRoot用在MaxIterations中指定的精度求一个解失败,它返回它找到的最接近的一个解。可以再次用这个近似作为一个初始点应用FindRoot
• 在牛顿法中每一步的大小用由DampingFactor给出的设置相乘。
• 参见Mathematica 全书: 1.5.7节, 1.6.3节 和 3.9.6节.
• 实现注释: 参见 A.9.4.
• 同时参见: NSolve, Solve, FindMinimum.
• 相关的包: NumericalMath`InterpolateRoot`.
Further Examples

These two curves intersect at one point.

Evaluate the cell to see the graphic.

In[1]:=  

This finds a numerical approximation to the x coordinate of the intersection point. The  is the initial guess.

In[2]:=  

Out[2]=

Trigonometric equations typically have an infinite number of roots. If you start sufficiently close to a particular root of an equation, FindRoot will find that root.

In[3]:=  

Out[3]=

Starting closer to another root will give different solution.

In[4]:=  

Out[4]=

You can restrict FindRoot to a region in which to look for solutions. Here the initial guess is  and the solution is supposed to be between  and  . There is no such solution.

In[5]:=  

Out[5]=

This is what happens when FindRoot can find no solutions at all.

In[6]:=  

Out[6]=

If you want FindRoot to use complex values in its search, then you need to give a complex starting value.

In[7]:=  

Out[7]=

For this equation, FindRoot has difficulty using Newton's method with only the default setting.

In[8]:=  

Out[8]=

When you specify the Jacobian (derivative), Newton's method can be used.

In[9]:=  

Out[9]=

When you don't know the Jacobian or it cannot be expressed by a formula, you can use the secant method by giving two starting values.

In[10]:=  

Out[10]=

Here is a way to count the number of times FindRoot evaluates the function.

In[11]:=  

In[12]:=  

In[13]:=  

Out[13]=

In[14]:=  

The advantage of Newton's method is that it usually converges faster and takes fewer steps than the secant method.

In[15]:=  

In[16]:=  

In[17]:=  

Out[17]=

In[18]:=  

This finds a solution to a set of simultaneous equations. It is a good idea to avoid taking the starting values for x and y to be equal or to take any other "special" combinations of values.

In[19]:=  

Out[19]=

If you specify the Jacobian in a problem with several variables, you need to make sure the rows and columns are ordered properly.

In[20]:=  

Out[20]=

The criterion FindRoot uses for convergence to a root is how close the function is to zero. If the function is very flat it may be close to zero before the variable is close enough to the root.

In[21]:=  

Out[21]=

Here FindRoot stopped when the value of the function was within the default AccuracyGoal (6 digits) of zero, but the root is only good to one decimal place.

In[22]:=  

Out[22]=

To get closer to the actual value of the root, increase the setting of the AccuracyGoal option. It is often also necessary to increase the setting of the WorkingPrecision option. In this case, FindRoot does not make it to the specified AccuracyGoal. The convergence to this root is very slow; we get  decimal places.

In[23]:=  

Out[23]=

If you think that FindRoot is getting close to a root but may need more steps to get there, increase the setting of the MaxIterations option.

In[24]:=  

Out[24]=