178
CHAPTER 6
Equations
By default, 100 iterations are performed before FindRoot is aborted. The number of iterations performed before quitting is controlled by the option MaxIterations. •
MaxIterations ã n instructs Mathematica to use a maximum of n iterations in the iterative process before aborting.
The equation e2x – 2ex + 1 = 0 has x = 0 as its only root. However, because its multiplicity is 2, Newton’s method converges very slowly.
EXAMPLE 17
FindRoot[Exp[2 x] – 2 Exp[x] + 1 0,{x, 100}] FindRoot õ cvmit : Failed to converge to the requested accuracy or precision within 100 iterations. {x
→ 50.}
FindRoot[Exp[2 x] – 2 Exp[x] + 1 0, {x, 100}, MaxIterations ã 300] {x
→ 4.54676 × 10–9}
FindRoot attempts to find real solutions. However, if a complex initial value is specified, or if the equation contains complex numbers, complex solutions will be sought. The equation in the next example has no real solutions. EXAMPLE 18
FindRoot[x2 + x + 1 0,{x, 2}] 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. {x
→ –0.500002}
FindRoot[x2 + x + 1 0,{x, I}] {x
→ –0.5 + 0.866025}
FindRoot[x2 + x + 1 0,{x, –I}] {x
→ –0.5 – 0.866025 }
There are three options that control the calculation in FindRoot and other numerical algorithms. • •
•
WorkingPrecision is an option that specifies how many digits of precision should be maintained internally in computation. The default is WorkingPrecision ã 16. AccuracyGoal is an option that specifies how many significant digits of accuracy are to be obtained. The default is AccuracyGoal ã Automatic, which is half the value of WorkingPrecision. AccuracyGoal effectively specifies the absolute error allowed in a numerical procedure. PrecisionGoal is an option that specifies how many effective digits of precision should be sought in the final result. The default is PrecisionGoal ã Automatic, which is half the value of WorkingPrecision. PrecisionGoal effectively specifies the relative error allowed in a numerical procedure.
( )
EXAMPLE 19 We wish to obtain a 10-decimal place approximation to the solution of the equation cos 100 = x , x x +1 nearest to 5,000. ⎡ ⎤ FindRoot ⎢ Cos ⎡⎢ 100 ⎤⎥ x , {x, 5000}⎥ x +1 ⎣ x ⎦ ⎣ ⎦ {x
→ 5000.83}