numerically approximate the real roots of an expression using an iterative method - Maple Help

Home : Support : Online Help : Education : Student Package : Numerical Analysis : Visualization : Student/NumericalAnalysis/Roots

Student[NumericalAnalysis][Roots] - numerically approximate the real roots of an expression using an iterative method

 Calling Sequence Roots(f, x=[a, b], opts) Roots(f, [a,b], opts) Roots(f, x=a, opts) Roots(f, a, opts)

Parameters

 f - algebraic; expression in the variable x representing a continuous function x - name; the independent variable of f a - numeric; in the first two calling sequences, one of two initial approximates to the root; in the remaining calling sequences, the initial approximate root b - numeric; in the first two calling sequences, one of two initial approximates to the root opts - (optional) equation(s) of the form keyword=value, where keyword is one of fixedpointiterator, functionoptions, lineoptions, maxiterations, method, output, pointoptions, showfunction, showlines, showpoints, showverticallines, stoppingcriterion, tickmarks, caption, tolerance, verticallineoptions, view; the options for approximating the roots of f

Description

 • The Roots command numerically approximates the roots of an algebraic function, f, using the specified method and returns the specified outputs.
 • Given an expression f and an initial approximate a or a pair of initial approximates [a, b], the Roots command computes a sequence ${p}_{k}$, $k$=$0..n$, of approximations to a root of f, where $n$ is the number of iterations taken to reach a stopping criterion.
 • See method in the Options section to see which methods require one initial approximate (and hence the last two calling sequences) and which methods require a pair of initial approximates (and hence the first two calling sequences).
 • If method = fixedpointiteration or method = steffensen is specified, the first argument f may be substituted with an option of the form fixedpointiterator = fpexpr. See method = fixedpointiteration in the Options section for details.

Notes

 • Both Newton's method and the secant method have the limitation that they may produce a divergent sequence of approximates if the initial approximates a and b are not sufficiently close to the root.

Examples

 > $\mathrm{with}\left(\mathrm{Student}[\mathrm{NumericalAnalysis}]\right):$
 > $f:={x}^{3}-7{x}^{2}+14x-6$
 ${f}{:=}{{x}}^{{3}}{-}{7}{}{{x}}^{{2}}{+}{14}{}{x}{-}{6}$ (1)
 > $\mathrm{Roots}\left(f,x=3.2,\mathrm{tolerance}={10}^{-2}\right)$
 ${3.416190743}$ (2)
 > $\mathrm{Roots}\left(f,x=\left[2.7,3.2\right],\mathrm{method}=\mathrm{bisection},\mathrm{tolerance}={10}^{-2},\mathrm{output}=\mathrm{information}\right)$
 $\left[\begin{array}{cccccc}{n}& {{a}}_{{n}}& {{b}}_{{n}}& {{p}}_{{n}}& {f}{}\left({{p}}_{{n}}\right)& {\mathrm{relative error}}\\ {1}& {2.7}& {3.2}& {2.950000000}& {0.054875000}& {0.08474576271}\\ {2}& {2.950000000}& {3.2}& {3.075000000}& {-}{0.063328125}& {0.04065040650}\\ {3}& {2.950000000}& {3.075000000}& {3.012500000}& {-}{0.012185547}& {0.02074688797}\\ {4}& {2.950000000}& {3.012500000}& {2.981250000}& {0.019446526}& {0.01048218029}\\ {5}& {2.981250000}& {3.012500000}& {2.996875000}& {0.003144514}& {0.005213764338}\end{array}\right]$ (3)
 > $f:={x}^{2}-3x-2:$
 > $\mathrm{Roots}\left(f,x=1,\mathrm{output}=\mathrm{sequence}\right)$
 ${1.}{,}{-}{3.000000000}{,}{-}{1.222222222}{,}{-}{0.6417233560}{,}{-}{0.5630533137}{,}{-}{0.5615533585}{,}{-}{0.5615528128}$ (4)
 > $\mathrm{Roots}\left(f,x=0.3,\mathrm{method}=\mathrm{modifiednewton},\mathrm{output}=\mathrm{plot},\mathrm{stoppingcriterion}=\mathrm{absolute}\right)$
 > $\mathrm{Roots}\left(f,x=0.3,\mathrm{method}=\mathrm{modifiednewton},\mathrm{output}=\mathrm{plot},\mathrm{stoppingcriterion}=\mathrm{absolute},\mathrm{verticallineoptions}=\left[\mathrm{color}=\mathrm{gold},\mathrm{linestyle}=\mathrm{dash}\right]\right)$
 > $\mathrm{Roots}\left(f,x=\left[1.3,5\right],\mathrm{method}=\mathrm{secant},\mathrm{output}=\mathrm{animation},\mathrm{stoppingcriterion}=\mathrm{function_value},\mathrm{tickmarks}=\left[5,5\right]\right)$